Wondering if someone can have a look at this template data by copy + pasting https://pastebin.com/kwJAq3kd into the template tool.
Im wanting to search through a json table to find a certain value in the table.
When you copy + paste into the template editor you get the below code:
{% set my_json = [... see the pastebin above ...] %}
Find the raw value for id 5
eg. ID{{ my_json[3].id }} = {{ my_json[3].raw.value }}
{% for i in my_json %}
# if (my_json[i].id == 5)
# my_json[i].raw.value
{% endfor %}
I’m just stuck on creating the if command inside a for loop inside a template as this part is not valid
{% for i in my_json %}
{% if my_json[{{ loop.index }}].id|int == 5 %}
my_json[{{ loop.index }}].raw.value
{% endif %}
{% endfor %}
You can copy/paste your json at try.jsonata.org and look at the doc.
The syntax of jsonata is a bit dark magic to me… But, parsing json with this tool is really fantastic !
My bad… I am using it in node-red. In HA template, it seems it is only jinja2 (which is another magic). I don’t practice jinja2 as all my automation/trigger/… are in node-red and not HA directly.