Hope someone can help here, basically I have a few template sensors setup with the following value_template:
value_template: >-
{% if states('sensor_battery_level') | float < 15 %}
on
{% else %}
off
{% endif %}
When home assistant is up and running etc this works fine and gives on and off just as it should, the problem is that during a restart or if there is an issue with a sensor and the sensors state is “unavailable” my template above sets my sensor to “on” which causes major issues. I need it to default to “off” all the time unless the sensor drops below 15
I think I would put the “unavailable” test first since the first thing to return true is what gets returned. So if it’s unavailable but the < 15 test gets evaluated first it will be true and it won’t get past that point and will return ‘on’ instead of the desired ‘off’.