For the life of me I cannot figure out why this isn’t working. I just need a different set of eyes on it. I’m trying to change the color of a state label based on the battery level of my vacuum. I made a sensor in my config:
Try to use states('sensor.vac_batt') instead of is_state.
is_state requires 2 arguments, the first one should be the entity_id and the second one should be the value to compare to, but that is an equal comparison, while you are trying a higher than, so probably in your case the states will work better, or even the state_attrib, as in this last case you don’t need that template sensor.
No, that works because I did it the exact same way with the status of the vac. There is something wrong with the way it’s testing the sensor values. I can test in Node Red and tell that the value is a number so I’m not sure what’s wrong.
Probably the sensor is returning a string, then you are comparing to a number. By using the float(0) it forces the conversion to a number and will be 0 in case the string cannot be converted to a number.
And you probably wouldn’t have had this problem if you have created your vac_battery sensor using a device_class (and using the new format for template sensors):