@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