Bug in automation using template? (no)

I found that a automation had not been running as it should. A value template to check that the current month is not december or january fails. If I test the template in developer tools, it shows true. But in my automation template, it is false.

I also tried via developer tools to show current month and it shows ‘4’. Both expressions below (I also now tried a simpler version) will show true in developer tools. But not in automation.

- condition: template
  #value_template: '{{ now().month in [2, 3, 4, 5, 6, 7, 8, 9, 10, 11] }}'
  value_template: '{{ now().month == 4 }}'

Bug?

I used this in developer tools to show current month:

Month: {{ now().month }}

Where are you seeing that? Three dots and “Test” gives me “CONDITION PASSES”.

Please explain how you are creating this automation, why you think this step is failing, and share the entire YAML.

1 Like


Entire yaml for condition:

condition:
  - condition: and
    conditions:
      - condition: time
        after: "6:30:00"
        before: "12:00:00"
      - condition: state
        entity_id: group.trivselbelysning
        state: "on"
      - condition: template
        value_template: |-
          - condition: template
            value_template: '{{ now().month in [2, 3, 4, 5, 6, 7, 8, 9, 10, 11] }}'
      - condition: numeric_state
        entity_id: sensor.hall_inne_motion_illuminance
        above: 100

I don’t know why I had “the extra stuff” but if I trim it down to this, it works

condition: template
value_template: '{{ now().month in [2,3,4,5,6,7,8,9,10,11] }}'

I suppose I have gotten “value_template: |-” for example from copy-paste.

You posted the entire YAML for a template confusion in the template field, where you should have only pasted the template

1 Like

Just to illustrate @TheFes’s answer for anyone that stumbles on this thread in the future… The condition should look as follows when set up in the UI Automation Editor: