Hi there,
i tried to get some info with restful integration.
All is working fine, but i need sth like template in the json_attributes_path.
This is what i have:
- resource: http://opendata.dwd.de/climate_environment/health/alerts/uvi.json
scan_interval: 604800 #a week in seconds
sensor:
- name: "DWD UV-Index Hannover"
unique_id: dwd_uvi_hannover
json_attributes_path: "$.content.7.forecast"
json_attributes:
- "today"
- "tomorrow"
- "dayafter_to"
icon: mdi:sun-wireless
Every 24h the id (7) changes… It could be every number.
I need sth like this:
- resource: http://opendata.dwd.de/climate_environment/health/alerts/uvi.json
scan_interval: 604800 #a week in seconds
sensor:
- name: "DWD UV-Index Hannover"
unique_id: dwd_uvi_hannover
json_attributes_path: >-
{% for x in range(value_json.content | length) %}
{% if value_json.content[x].city == 'Hannover' %}
{{ "$.content.**x**.forecast" }}
{% endif %}
{% endfor %}
json_attributes:
- "today"
- "tomorrow"
- "dayafter_to"
icon: mdi:sun-wireless
How to solve it?
Thanks