Need ideas for creating a high availability Template sensor that combines multiple values

The problem that I am trying to solve is creating a device redundant sensor. I want to use multiple humidity sensors in a way if one of them fails the sensor keeps working. I am automating a humidifier, and if it gets stuck β€˜on’ due to a sensor failure it could have pretty serious consequences. My original premise was that I would do a template sensor that would average the values of multiple sensors. If there are 3 sensors, and I sum and divide by three, I think this would go poorly if one of them becomes unavailable. I’m looking for better ideas that would be more tolerant of sensor unavailability, more like a primary/secondary fail over.

Use the appropriate filters and functions to avoid errors and provide defaults where needed.

{% set sensor_list = expand(
['sensor.example1', 'sensor.example2', 'sensor.example3', 
'sensor.example4'] | select('has_value')) %} 
{{ sensor_list | map(attribute='state') | map('float') | average if sensor_list | count > 0 else 100 }}
1 Like

Thank you! Will try this