Template based on state evaluating incorrectly

Hi All,

I’m trying to use a template as a conditional action but it seems to be evaluating to an unexpected value and I’m not sure why

As you can see here, I’m trying to check if Sim Shack Current Temp is higher than the Sim Shack High Threshold which evaluates to false:

You can see here that the Sim Shack Current Temp is in fact higher than the Sim Shack High Threshold:
image

I can also verify this by looking at each individual state that I’m using:


I’m certain that I’m overlooking something - but I’m not sure what?

Your second entity in the first picture of the template editor is missing the states(
Your comparison does not look correct.

Yup - I’m an idiot. Thank you, I knew there was something very simple I was overlooking. Time to make more coffee!

1 Like

Also,

State values are always strings. So you are comparing strings instead of numbers. Strings are evaluated left to right, so ‘2’ is greater than ‘100000’.

Convert your states to numbers before making the comparison.

{{ states(foo)|float(0) > states(bar)|float(0) }}
1 Like