weather forecast

Moderator: leecollings

Post Reply
DeepB
Posts: 9
Joined: Wednesday 10 December 2014 16:42
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

weather forecast

Post 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
pj-r
Posts: 140
Joined: Wednesday 17 December 2014 17:30
Target OS: Linux
Domoticz version: V3.8650
Location: Jyväskylä, Finland
Contact:

Re: weather forecast

Post 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
LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors
Thomasdc
Posts: 133
Joined: Wednesday 11 March 2015 19:13
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: weather forecast

Post 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...
civil1415
Posts: 1
Joined: Thursday 16 November 2017 14:39
Target OS: -
Domoticz version:
Contact:

Re: weather forecast

Post by civil1415 »

Hi
Does it work for you guys?
thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest