Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 117711

For loop within json table

$
0
0

@kiwijunglist wrote:

Hi

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 (it only has about 30 maximal entries) 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 range(0, 30) %}
  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.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 117711

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>