Failover sensor methods

i have been unable to find a method for setting up a failover sensor. i use a thermostat integration that is able to use sensors like outside temperature and door/window sensors to regulate the heat. but if a sensor for some reason is unavailable. the whole integration becomes unavailable. because it expects the values from those sensors…

that made me think if it is possible to for example use my own local temperature sensor outside my house as the primary sensor to get the temperature to the integration. but if thta one fails i can fall back to the regional less local weatherservice. for some close enough values to use with the integration.

You could use a Template sensor. There are many ways to approach it, here is one option:

{% set therm_list = ['sensor.therm_1', 'sensor.therm_2', 'sensor.therm_3'] %}
{{ states(therm_list | select('has_value') | first) }}
2 Likes

Hi Jacob_Hansen,

Another way…
Add a default filter or use a float filter on the sensor value, and use the state of the back-up sensor as the value of the default.

{{ 'sensor.therm_1' | float('sensor.therm_2') }}
1 Like

Thank you very much.
just what i needed. i dont mess that much with the code to be familiar with it. but i do understand what is going on in the code snippets you provided.
And it solved my problem.

Cool.
Perhaps select one of them as the solution to close the thread?

Thanks.