11.02.2022, 08:18
(This post was last modified: 11.02.2022, 08:20 by pioneersteffen.)
Hi Admin,
many thanks for your help!
I want to include a repeat loop to write the next 12h into group addresses. Unfortunately my actual code doesn’t work. Can you please give me a hint for the loop?
Many thanks for your help!
Best Regards
Steffen
many thanks for your help!
I want to include a repeat loop to write the next 12h into group addresses. Unfortunately my actual code doesn’t work. Can you please give me a hint for the loop?
Many thanks for your help!
Best Regards
Steffen
Code:
require('json')
https = require 'ssl.https'
appid = 'XXX'
lat = '52.436225'
lon ='10.42526'
azi = '170'
hours = '24'
format = 'json'
tilt = '33'
capa = '8'
url = 'https://api.solcast.com.au/world_pv_power/forecasts?latitude=%s&longitude=%s&hours=%s&format=%s&tilt=%s&capacity=%s&azimuth=%s&api_key=%s'
url = string.format(url, lat, lon, hours, format, tilt, capa, azi, appid)
res, code, headers, status = ssl.https.request(url)
log (code, status, headers, res)
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
data = data.forecasts
i=1
repeat
grp.write('45/1/'..i, data[i].pv_estimate)
i = i + 1
until i>24