Value template for input numbers

in an automation, with the condition type “Template”, this value template:

value_template: “{{ states(‘input_number.fake_rack_upper_temp.state’) | float >
states(‘input_number.rack_limit_temperature_high.state’) | float }}”

is never true and the automation never activates

There are two ways to get an entity’s state value. Here’s one way:


Here’s the other way:


The second way, using the states() function, is the preferred way. Why? Because if you mistype the entity’s name, or the entity simply doesn’t exist, the states() function will gracefully handle the mistake. If you mistype the first way, it will result in an error.

In your example, you sort of used a combination of both, which was a mistake, but the states() function handled it gracefully (no error message, the condition simply failed).

What you want to do is this:

value_template: "{{ states('input_number.fake_rack_upper_temp') | float > states('input_number.rack_limit_temperature_high') | float }}"

thanks, it worked!

Great! Glad to hear it.

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 an accepted solution. This helps users find answers to similar questions.