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
weather forecast
Moderator: leecollings
-
- Posts: 140
- Joined: Wednesday 17 December 2014 17:30
- Target OS: Linux
- Domoticz version: V3.8650
- Location: Jyväskylä, Finland
- Contact:
Re: weather forecast
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.
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
LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors
-
- Posts: 133
- Joined: Wednesday 11 March 2015 19:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Contact:
Re: weather forecast
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...
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...
Who is online
Users browsing this forum: No registered users and 1 guest