Template runs, but not under configuration.yaml

Hi,

I designed the following template, working in the template development card. The desired output should be:

  • between time 00:30 and 06:30 = 2000
  • between time 06:30 and 1700 = 6500
  • else formula as below
  - sensor:
      - name: "2000K-6500K Bulb Temperatur Timer"
        state: >
        {% if 0.5 < now().hour+now().minute/60 < 6.5 %}
        2000
        {% elif 6.5 < now().hour+now().minute/60 < 17 %}
        6500
        {% else %}
        {{int(6500-4500*1.2*(now().hour + now().minute/60-17)/(1.5+now().hour + now().minute/60-17))}}
        {% endif %}

When I save it under configuration.yaml, I get the following error:

missed comma between flow collection entries (25:10)

 22 |   - sensor:
 23 |       - name: "2000K-6500K Bulb Temperat ...
 24 |         state: >
 25 |         {% if 0.5 < now().hour+now().min ...
---------------^
 26 |         2000

I tried using “set” to define the value with the formula, before the if-else block. But this also did not work.

BW

J

Incorrect indentation.

Indent all lines below
state: >
by an additional two spaces.

Example:

  - sensor:
      - name: "2000K-6500K Bulb Temperatur Timer"
        state: >
          {% set t = now().hour + now().minute/60 %}
          {% if 0.5 < t < 6.5 %}
          2000
          {% elif 6.5 < t < 17 %}
          6500
          {% else %}
          {{int(6500-4500*1.2*(t-17)/(1.5+t-17))}}
          {% endif %}
1 Like

Working! Excellent. I knew, I was hunting the wrong bug with missing comma.