I am using restfull to iterate through a json file (see below) and the result for ‘state’ is fine.
However, I also want to add some other values in the attributes of the same, but I cannot find out how this works or… maybe this does not work at all? Can I set a value_template for the attributes in the same way?
- name: 530_bus_outgoing
value_template: >
{% set y = value_json.entity | count %}
{% for x in range(0,y) %}
{% set trip = value_json["entity"][x]["trip_update"]["trip"]["trip_id"] %}
{% if trip[:6] == "LR530A" %}
{% set y2 = value_json["entity"][x]["trip_update"]["stop_time_update"] | count %}
{% for x2 in range(0,y2) %}
{% set stop = value_json["entity"][x]["trip_update"]["stop_time_update"][x2]["stop_id"] %}
{% if stop == "STOPPOINT:00812" %}
{{ as_local(as_datetime(value_json["entity"][x]["trip_update"]["stop_time_update"][x2]["departure"]["time"] + value_json["entity"][x]["trip_update"]["stop_time_update"][x2]["departure"]["delay"])) }}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}