Hello,
I have a problem when running a conky script I have this error:
modules/weather/scripts/fetch-weather.lua:71: attempt to index a nil value (field 'main')
here is the portion of the script:
if file_exists(cache_file) then
cache = io.open(cache_file,"r+")
data = json.decode(cache:read())
timepassed = os.difftime(currenttime, data.timestamp)
else
cache = io.open(cache_file, "w")
timepassed = 6000
end
makecache = function (s)
s.timestamp = currenttime
save = json.encode(s)
cache:write(save)
end
if timepassed < 3600 then
response = data
else
weather = http.request(("%sid=%s&units=%s&APPID=%s"):format(api_url, cityid, cf, apikey))
if weather then
response = json.decode(weather)
makecache(response)
else
response = data
end
end
math.round = function (n)
return math.floor(n + 0.5)
end
temp = response.main.temp <----- error here
conditions = response.weather[1].main
icon = response.weather[1].icon:sub(1, 2)