I found a website providing some kind of solar forecast which I want to use in domoticz with a (simple) dzVents script.
The API is free to use for basic information (hourly 2 days forecast for watts, watt hours and watt hours/day ) and restricted to 12 calls per hour.
The problem I'm facing is, that the data for that 2 days comes as one single json string and I have no idea how to deal with this.
I assume I have to store the data in a temporary file and process that file every hour to feed a virtual sensor.
I would really appreciate if someone could push me in the right direction on how to do this. Or maybe there is an even simpler way to deal with this.
Any ideas?
The description of API calls can be found here: http://doc.forecast.solar/doku.php?id=api:estimate
The relevant parameters for the example below are:
51.3 - lat - latitude of location, -90 (south) … 90 (north)
12.4 - lon - longitude of location, -180 (west) … 180 (east)
45 - dec - plane declination, 0 (horizontal) … 90 (vertical)
0 - az - plane azimuth, -180 … 180 (-180 = north, -90 = east, 0 = south, 90 = west, 180 = north)
0.03 (for my 30W panel) kwp - installed modules power in kilo watt
Here is an example of the API call from bash:
Code: Select all
curl -H "Accept: text/json" https://api.forecast.solar/estimate/51.3/12.4/45/0/0.03
Code: Select all
{
"result": {
"watts": {
"2019-04-08 06:22:00": 0,
"2019-04-08 06:56:00": 0.18,
"2019-04-08 07:30:00": 1.2,
"2019-04-08 08:00:00": 2.19,
"2019-04-08 09:00:00": 4.98,
"2019-04-08 10:00:00": 8.37,
"2019-04-08 11:00:00": 11.88,
"2019-04-08 12:00:00": 14.64,
"2019-04-08 13:00:00": 21.75,
"2019-04-08 14:00:00": 21.48,
"2019-04-08 15:00:00": 19.5,
"2019-04-08 16:00:00": 14.52,
"2019-04-08 17:00:00": 8.73,
"2019-04-08 18:00:00": 3.63,
"2019-04-08 19:01:00": 0.51,
"2019-04-08 20:02:00": 0,
"2019-04-09 06:20:00": 0,
"2019-04-09 06:55:00": 0.24,
"2019-04-09 07:30:00": 1.74,
"2019-04-09 08:00:00": 3.45,
"2019-04-09 09:00:00": 8.31,
"2019-04-09 10:00:00": 13.89,
"2019-04-09 11:00:00": 18.96,
"2019-04-09 12:00:00": 22.41,
"2019-04-09 13:00:00": 23.76,
"2019-04-09 14:00:00": 22.68,
"2019-04-09 15:00:00": 19.17,
"2019-04-09 16:00:00": 14.22,
"2019-04-09 17:00:00": 8.49,
"2019-04-09 18:00:00": 3.54,
"2019-04-09 19:02:00": 0.51,
"2019-04-09 20:03:00": 0
},
"watt_hours": {
"2019-04-08 06:22:00": 0,
"2019-04-08 06:56:00": 0.09,
"2019-04-08 07:30:00": 0.78,
"2019-04-08 08:00:00": 1.89,
"2019-04-08 09:00:00": 6.87,
"2019-04-08 10:00:00": 15.24,
"2019-04-08 11:00:00": 27.12,
"2019-04-08 12:00:00": 41.76,
"2019-04-08 13:00:00": 63.51,
"2019-04-08 14:00:00": 84.99,
"2019-04-08 15:00:00": 104.49,
"2019-04-08 16:00:00": 119.01,
"2019-04-08 17:00:00": 127.74,
"2019-04-08 18:00:00": 131.37,
"2019-04-08 19:01:00": 131.88,
"2019-04-08 20:02:00": 131.88,
"2019-04-09 06:20:00": 0,
"2019-04-09 06:55:00": 0.15,
"2019-04-09 07:30:00": 1.17,
"2019-04-09 08:00:00": 2.88,
"2019-04-09 09:00:00": 11.19,
"2019-04-09 10:00:00": 25.08,
"2019-04-09 11:00:00": 44.04,
"2019-04-09 12:00:00": 66.45,
"2019-04-09 13:00:00": 90.21,
"2019-04-09 14:00:00": 112.89,
"2019-04-09 15:00:00": 132.06,
"2019-04-09 16:00:00": 146.28,
"2019-04-09 17:00:00": 154.77,
"2019-04-09 18:00:00": 158.31,
"2019-04-09 19:02:00": 158.85,
"2019-04-09 20:03:00": 158.85
},
"watt_hours_day": {
"2019-04-08": 131.88,
"2019-04-09": 158.85
}
},
"message": {
"code": 0,
"type": "success",
"text": "",
"info": {
"place": "04328 Sellerhausen-St\u00fcnz, Kreisfreie Stadt Leipzig, Sachsen, DE",
"distance": 6.36,
"pid": "4th683nz"
},
"ratelimit": {
"limit": 12,
"remaining": 2
}
}
}