Does anybody knows a more direct way without loop to get item 1 from splitted value hsv?
First (L1) you see the hole content of the value. Second (L2) the result i would like.
Code:
L1: {{ states.sensor.dingz_markise1_state.attributes['led']['hsv'] }}
L2: {% set hsv = states.sensor.dingz_markise1_state.attributes['led']['hsv'] %}
{%- for item in hsv.split(';') %}
{%- if loop.index == 1 %}
{{ item.split(' ')[0] }}
{%- endif %}
{%- endfor %}
Result:
L1: 180;100;3
L2:
180
Is there a way to address directly the value I need? Without looping through all the values?
No, state_attr doesn’t work. {{ state_attr('sensor.dingz_markise1_state', 'led')['hsv'] }}
… delivers … 180;100;3
… thats ok. When I add split, like … {{ state_attr('sensor.dingz_markise1_state', 'led')['hsv']|split(';')[0] }}
… I get no result anymore.