Value Template in Automation Always TRUE ... why?

I have a simple value template shown below as part of an automation condition that always returns True yet when testing the exact template in “Developer Tools” it behaves correctly, returns “False”.
I simply look for the string “snow” in the current weather. The entity “sensor.openweathermap_weather” provides this information accurately. It’s an entity I can depend on (maybe not) to turn on my heating mats to melt the snow.

condition:
  - condition: template
    value_template: "{{ 'snow' in states('sensor.openweathermap_weather') }}"
action:
  - service: switch.turn_on

When testing the condition using the 3 dots within the Automation UI it does not pass (False) as shown below, the same result as in “Developer Tools”. It should not pass because the current weather does not have snow.

The trigger does not matter. I have also moved the template from a condition to a trigger and it still doesn’t behave correctly. It’s always being evaluated as being “True”.

Any suggestions or help would be appreciated. Thank you

What test are you performing that confirms the condition is reporting true?

For example, does the automation’s trace show the condition is reporting true?

Or are you testing the automation by executing its Run command and discovering it always executes the actions, regardless of the condition’s reported state, and concluding the condition must be always reporting true? Because that would be an erroneous conclusion; the Run command only executes the actions and skips the automation’s trigger and condition.

Reference

Testing your automation

Stupid me …I was always under the impression the Run command evaluated the trigger and conditions. Thank you… I feel like an idiot.

1 Like

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.

1 Like