Problem with if then else not listening for events

In an automation, I can’t get:

{% if "{{states('input_number.propane_left')|float(0) < 20}}" %} red {% else %} black {% endif %}

to listen to changes in the input_number

Please help!

That is just an if statement en like the dev tools says: it will not react to a change. You will need a trigger for that. (if any bit of code isnt working, throw it in the dev tools… :wink: )
Post the whole automation so we can see whats missing.

What tom_l said :flushed:

Should be:

{% if states('input_number.propane_left')|float(0) < 20 %} red {% else %} black {% endif %}

1 Like

If you’re interested, you can use an Immediate If (introduced in version 2022.2).

{{ iif(states('input_number.propane_left')|float(0) < 20,  'red',  'black') }}
1 Like

Brilliant! Thank you!

Neat. Thanks!