I can get this code to work in dzVents 2.2.0 any ideas?
I got this error : "Error: dzVents: Error: /home/pi/domoticz/scripts/dzVents/scripts/weather.lua:26: attempt to call a nil value"
Code: Select all
fetchWeatherForecast = function()
json = (loadfile "/home/pi/domoticz/scripts/lua/json.lua")() --<<Line 26>>--
local city = "ECDF"
local wuAPIkey = "xxxxxxxxxxx" -- Your Weather Underground API Key
local file=assert(io.popen('curl http://api.wunderground.com/api/'..wuAPIkey..'/forecast/q/'..city..'.json'))
local raw = file:read('*all')
file:close()
local jsonForecast = json:decode(raw)
domoticz.data.recentForecast=jsonForecast.forecast.txt_forecast.forecastday[1].fcttext_metric -- complete forecast
--domoticz.data.recentForecast=jsonForecast.forecast.simpleforecast.forecastday[1].conditions -- small forecast
print("fetchWeatherForecast: " .. domoticz.data.recentForecast)
end]