From cb245ba88045eb6f1d23fea2a802c656be2b352e Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Tue, 22 Sep 2015 19:38:48 +0200 Subject: [PATCH] Actually cache the new sunrise/sunset data of the correct day --- lib/hued/rule.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/hued/rule.rb b/lib/hued/rule.rb index 016d0c6..b317096 100644 --- a/lib/hued/rule.rb +++ b/lib/hued/rule.rb @@ -131,9 +131,10 @@ module Hued # Retrieve new sunrise/sunset data if cache is too old if @@sun_data.nil? or @@sun_data[:day] != Date.today lat, lon = cond_value - url = "http://api.sunrise-sunset.org/json?lat=%s&lng=%s&formatted=0" % - [lat, lon] - @log.debug "Retreiving sunrise/sunset data from #{url}..." + today = Date.today.strftime("%Y-%m-%d") + url = "http://api.sunrise-sunset.org/json?lat=%s&lng=%s&date=%s&formatted=0" % + [lat, lon, today] + @log.debug "Retreiving sunrise/sunset data from #{url} for #{today}..." begin data = Net::HTTP.get(URI(url)) json_data = JSON(data)