Meldj
(Jake)
September 26, 2023, 9:41am
1
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:
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?
pcwii
(Pcwii)
September 26, 2023, 9:46am
2
Your second entity in the first picture of the template editor is missing the states(
Your comparison does not look correct.
Meldj
(Jake)
September 26, 2023, 10:01am
3
Yup - I’m an idiot. Thank you, I knew there was something very simple I was overlooking. Time to make more coffee!
1 Like
tom_l
September 26, 2023, 10:28am
4
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