I would like to configure a sensor that checks that all temperature sensors are working correctly.
I wrote this but the sensor value is always “unavailable” where am I wrong? Thank you
`- platform: template
sensors:
sensori_casa:
friendly_name: “Sensori casa”
value_template: >-
{% if states.sensor.rm_cucina_temperature != ‘unavailable’
and is_state(‘sensor.rm_sala_temperature’ != ‘unavailable’)
and is_state(‘sensor.rm_camera_temperature’ != ‘unavailable’)
%}
ok
value_template: >-
{% if 'unavailable' in
[states('sensor.rm_cucina_temperature'),
states('sensor.rm_sala_temperature'),
states('sensor.rm_camera_temperature')]
%}
ko
{% else %}
ok
{% endif %}
value_template: >-
{% if [states('sensor.rm_cucina_temperature'),
states('sensor.rm_sala_temperature'),
states('sensor.rm_camera_temperature')]
|map('int')|select('eq',0)|list|length > 0
%}
ko
{% else %}
ok
{% endif %}
It will apply the int filter to each element, keep only those that are zero, turn it into a list and calculate the length of that list. If there are any items left, one of your sensors is returning a string.
This relies on your rooms staying above 0°C of course.