Automation condition strange behavior


can someone explain to me, why this is working:

condition: template
value_template: 'is_state(''sensor.wasser_weiss_unten'',''ON'')'

and this doesn’t:

condition: state
entity_id: sensor.wasser_weiss_unten
state: 'ON'

Whats the difference?


No, I can’t explain it. They should have the same effect.

Try the automation trace to see what is happening.

What do you mean by automation trace?

Go to Configuration / Automation and find your automation. Click on the clock icon on the right hand side. You can then see what conditions were true or false and why.

Actually, that should not work because it’s an invalid template. This would be valid (note the use of double braces to enclose the statement):

condition: template
value_template: '{{ is_state(''sensor.wasser_weiss_unten'',''ON'') }}'
1 Like

Further to @123’s observation, is it really a sensor with a state of 'ON' or a binary sensor with a state of 'on'?

The original incorrect un-braced “template” probably evaluates true because it is a string rather than something undefined/null.

Can we see a screenshot of Developer Tools / States showing that sensor please?


thank you for the many replies and help.

@123, You are right with the double braces it works correct.

Now also the state condition works, don’t know what 's been the problem. So the issue is solved for me.