08.02.2022, 21:21
(This post was last modified: 08.02.2022, 21:25 by pioneersteffen.)
Hi @all,
I need your help please. I want to use the solcast API to get a forecast for my photovoltaic system. In detail I want to get the hourly forecasts for the next 24 hours and write them to group addresses.
Here is the link for the API documentation: https://docs.solcast.com.au/?_ga=2.24121...i-pv-power
Here is my actual code:
I getting the following failure message:
Where is my failure? Can you help me please?
Many thanks for help!
Best Regards
Steffen
I need your help please. I want to use the solcast API to get a forecast for my photovoltaic system. In detail I want to get the hourly forecasts for the next 24 hours and write them to group addresses.
Here is the link for the API documentation: https://docs.solcast.com.au/?_ga=2.24121...i-pv-power
Here is my actual code:
Code:
require('json')
https = require 'ssl.https'
appid = 'XX'
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)
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
-- forecast +30min
grp.write('45/1/1', data.pv_estimate)
I getting the following failure message:
Code:
Solcast 08.02.2022 22:01:35
User script:36: attempt to index field 'pv_estimate' (a nil value)
stack traceback:
User script:36: in main chunk
Where is my failure? Can you help me please?
Many thanks for help!
Best Regards
Steffen