Page 1 of 1
weather forecast
Posted: Monday 30 May 2016 22:29
by DeepB
Hello,
I would like to use the weather forecast for the current day in a Lua script.
Anyone doing this? Can anyone point me in the right direction how to do this, or even better is there a tutorial?
I found the wiki page on forecast.io, unfortunately it seems I only get the current values.
Thank you
Daniel
Re: weather forecast
Posted: Tuesday 31 May 2016 9:19
by pj-r
I'm using WU to get what the weather is after 4 hours.. this way I can adjust underfloor heating setpoint.
Only problem is that it freezes domoticz while its doing http call on lua script. So its not the best way.
I think best way would be to run separate script that collects needed data to file and read from that in lua script.
for this you need to install io, socket.http and json lua libraries.
Code: Select all
function getWUForecast(hoursToSeek)
io = require('io')
http = require('socket.http')
json = require('json')
b, c, h = http.request("http://api.wunderground.com/api/YOUR_API_KEY/hourly/q/LAND_CODE/Location.json")
-- print("Response status: "..c) -- status.. should be 200
local lua_value = json:decode(b) -- decode json response to lua table format
-- print_r(lua_value)
resultTable = lua_value["hourly_forecast"] -- contains datetime and temp values
result = resultTable[hoursToSeek]["temp"]["metric"]
hour = resultTable[hoursToSeek]["FCTTIME"]["hour"]
-- print("Hour: "..hour.." Index: "..hoursToSeek.." Value: "..result)
return result
end
Re: weather forecast
Posted: Thursday 03 August 2017 14:26
by Thomasdc
Hi!
I would like to get the weather forecast for the day..
is there an way to get this?
i would like to see the temperature that it's going to be that day
that way i can create a rgb-light that shows me in the morning how hot it will be that day.
but i dont know how to get this temperature...
Re: weather forecast
Posted: Thursday 16 November 2017 14:52
by civil1415
Hi
Does it work for you guys?
thanks