Actually cache the new sunrise/sunset data of the correct day
This commit is contained in:
parent
48004beb92
commit
cb245ba880
|
@ -131,9 +131,10 @@ module Hued
|
||||||
# Retrieve new sunrise/sunset data if cache is too old
|
# Retrieve new sunrise/sunset data if cache is too old
|
||||||
if @@sun_data.nil? or @@sun_data[:day] != Date.today
|
if @@sun_data.nil? or @@sun_data[:day] != Date.today
|
||||||
lat, lon = cond_value
|
lat, lon = cond_value
|
||||||
url = "http://api.sunrise-sunset.org/json?lat=%s&lng=%s&formatted=0" %
|
today = Date.today.strftime("%Y-%m-%d")
|
||||||
[lat, lon]
|
url = "http://api.sunrise-sunset.org/json?lat=%s&lng=%s&date=%s&formatted=0" %
|
||||||
@log.debug "Retreiving sunrise/sunset data from #{url}..."
|
[lat, lon, today]
|
||||||
|
@log.debug "Retreiving sunrise/sunset data from #{url} for #{today}..."
|
||||||
begin
|
begin
|
||||||
data = Net::HTTP.get(URI(url))
|
data = Net::HTTP.get(URI(url))
|
||||||
json_data = JSON(data)
|
json_data = JSON(data)
|
||||||
|
|
Reference in New Issue