31.10.2022, 10:48
Hello,
i nedd to know how may mm of rain done. I modify the script:
require('json')
https = require('ssl.https')
escape = require('socket.url').escape
key = 'xxxxxxxxxxxx'
location = 'Mandello del Lario'
latitude = 45.921373
longitude = 9.314482
args = 'lat=' .. latitude .. '&lon=' .. longitude
url = 'https://api.apixu.com/v1/forecast.json?key=%s&q=%s&days=2'
url = string.format(url, key, escape(arg))
res = https.request(url)
data = json.pdecode(res)
if type(data) ~= 'table' then
alert('Informazioni meteo non pervenute')
return
end
if data.error then
log('error', data.error)
return
end
current = data.current
today = data.forecast.forecastday[ 1 ].day
tomorrow = data.forecast.forecastday[ 2 ].day
-- log(current, today, tomorrow)
-- temperature in C
grp.write('32/2/1', current.temp_c)
-- total precipitation in millimeters
grp.write('32/2/8', today.totalprecip_mm)
But don't function. Can someone help me please.
i nedd to know how may mm of rain done. I modify the script:
require('json')
https = require('ssl.https')
escape = require('socket.url').escape
key = 'xxxxxxxxxxxx'
location = 'Mandello del Lario'
latitude = 45.921373
longitude = 9.314482
args = 'lat=' .. latitude .. '&lon=' .. longitude
url = 'https://api.apixu.com/v1/forecast.json?key=%s&q=%s&days=2'
url = string.format(url, key, escape(arg))
res = https.request(url)
data = json.pdecode(res)
if type(data) ~= 'table' then
alert('Informazioni meteo non pervenute')
return
end
if data.error then
log('error', data.error)
return
end
current = data.current
today = data.forecast.forecastday[ 1 ].day
tomorrow = data.forecast.forecastday[ 2 ].day
-- log(current, today, tomorrow)
-- temperature in C
grp.write('32/2/1', current.temp_c)
-- total precipitation in millimeters
grp.write('32/2/8', today.totalprecip_mm)
But don't function. Can someone help me please.