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

Can you template from an array of attributes?

$
0
0

@klogg wrote:

Is it possible to template on arrays of attributes? (I think I have the terminology right :wink: )

I know I can do this:

{% set sensor_id= '1' %}
{% set my_value = state_attr('sensor.my_sensor_' ~ sensor_id, 'my_attribute') %}

But what if the attributes are an array? As far as I am aware the only way to extract these is to use the form:

{% set my_value = states.sensor.my_sensor_1.attributes.array[0].my_attribute %}

What I’d like to be able to do is this (which obviously doesn’t work and neither do the many other forms I’ve tried)

{% set my_value = states.sensor.my_sensor_{{ sensor_id }}.attributes.array[0].my_attribute %}

Is there a way to do this?
Thanks

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



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