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

Help with Sensor Template please

$
0
0

@IsaTTeN wrote:

Hello!

I´m trying to build a sensor using templates but I´m stucked because the set instruction isn´t working inside a for loop.

This is not the real sensor but reproduces the problem that I´m getting. In this example I never get the Hello World in the test variable. Why???

{% set number = 3 %}

{% for x in range(number | int) -%}
   {{ x }}
   {%- if x==2 %}
     {% set test = 'Hello World!' %}  
   {% endif %}
{% endfor %}

{{ test }}

I get this in the Template Editor:

0
1
2

Thank you in advance

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 99036

Trending Articles



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