Hello , I recently ran into issues with reading data from a json file.
The raw data:
{
"result": {
"2023-04-28 06:28:05": 0,
"2023-04-28 07:00:00": 367,
"2023-04-28 08:00:00": 1946,
"2023-04-28 09:00:00": 2922,
"2023-04-28 10:00:00": 3440,
"2023-04-28 11:00:00": 3519,
"2023-04-28 12:00:00": 3377,
"2023-04-28 13:00:00": 2921,
"2023-04-28 14:00:00": 2095,
"2023-04-28 15:00:00": 1208,
"2023-04-28 16:00:00": 680,
"2023-04-28 17:00:00": 528,
"2023-04-28 17:39:49": 166,
"2023-04-29 06:28:35": 0,
"2023-04-29 07:00:00": 347,
"2023-04-29 08:00:00": 1891,
"2023-04-29 09:00:00": 2865,
"2023-04-29 10:00:00": 3479,
"2023-04-29 11:00:00": 3590,
"2023-04-29 12:00:00": 3403,
"2023-04-29 13:00:00": 2950,
"2023-04-29 14:00:00": 2114,
"2023-04-29 15:00:00": 1226,
"2023-04-29 16:00:00": 612,
"2023-04-29 17:00:00": 380,
"2023-04-29 17:39:02": 114
},
"message": {
"code": 0,
"type": "success",
"text": "",
"info": {
"distance": 0,
"timezone": "Africa/Johannesburg",
"time": "2023-04-28T23:23:23+02:00",
"time_utc": "2023-04-28T21:23:23+00:00"
},
"ratelimit": {
"period": 3600,
"limit": 12,
"remaining": 4
}
}
}
My code is as follows:
- platform: rest
resource: 'https://api.forecast.solar/estimate/watthours/period/30/-17/11.88'
name: 'Forecast Solar'
scan_interval: 10800
value_template: '{{ value_json.states }}'
json_attributes:
- result
- message
- platform: template
sensors:
forecast_result:
value_template: '{{ states.sensor.forecast_solar.attributes.result }}'
friendly_name: "Total Results"
forecast_message:
value_template: "{{ states.sensor.forecast_solar.attributes.message.get('ratelimit') }}"
friendly_name: "Message"
The odd part is that my forecast_message
sensor works just fine but my forecast_result
throws unavailable
everywhere but in the developer tools template tab. The forecast_result
sensor worked 3 days ago but now its just unavailable and refuses to show the data for result.
Any advice?