22.10.2021, 09:27
(This post was last modified: 22.10.2021, 09:54 by pioneersteffen.)
Many thanks for the help, it works fine now!
Here is the finished script for other users to continue with it:
One last rookie question. I want to combine current.temp + current.humidity + current.wind_speed to one string and send this via a 14 byte ASCII group adress.
How would this look like?
Many thanks for your help!
Found the solution on my own, here is a line to combine the values:
wetterprognose = daily.temp.min.."/"..daily.temp.max
Here is the finished script for other users to continue with it:
Code:
require('json')
http = require('socket.http')
appid = 'XXX'
lat = 'XXX'
lon ='XXX'
lang = 'de'
units = 'metric'
url = 'http://api.openweathermap.org/data/2.5/onecall?lat=%s&lon=%s&units=%s&lang=%s&appid=%s'
url = string.format(url, lat, lon, units, lang, appid)
res, code, headers, status = http.request(url)
log (code, status, headers)
data = json.pdecode(res)
--Fault messages:
if not data then
alert('Error converting data')
return
end
if not res then
alert('Error collecting data')
return
end
current = data.current
daily = data.daily[1]
-- current temperature
grp.write('41/1/1', current.temp)
--current Humidity
grp.write('41/1/3', current.humidity)
--current wind speed
grp.write('41/1/6', current.wind_speed)
--daily forecast Temperature min
grp.write('41/1/4', daily.temp.min)
--daily forecast Temperature max
grp.write('41/1/5', daily.temp.max)
-- daily Weather condition
grp.write('41/1/2', daily.weather[1].description)
One last rookie question. I want to combine current.temp + current.humidity + current.wind_speed to one string and send this via a 14 byte ASCII group adress.
How would this look like?
Many thanks for your help!
Found the solution on my own, here is a line to combine the values:
wetterprognose = daily.temp.min.."/"..daily.temp.max