Binary Sensor Template

I have a few leak sensors throughout the house and plan to get some more. Instead of setting up an alert for each individual sensor I wanted to combine them all into a single binary sensor and use that to trigger the alert.

This is what I have:

- platform: template 
  sensors:
    h2o:
      friendly_name: 'Water'
      sensor_class: 'moisture'
      value_template: >-
        {% if is_state("binary_sensor.water_heater_liquid_detected", "on") 
            or is_state("binary_sensor.under_kitchen_sink_liquid_detected", "on")
            or is_state("binary_sensor.guest_bathroom_liquid_detected", "on") %}
        On
        {% else %}
        Off
        {% endif %}
      entity_id:
        - binary_sensor.under_kitchen_sink_liquid_detected
        - binary_sensor.guest_bathroom_liquid_detected
        - binary_sensor.water_heater_liquid_detected

I get no errors at all, the sensor is created, and when I put the value_template part into the template into the Jinja2 template jawn it appears like it should work. If I manually change one of the sensors to on, it gives me an output of β€˜on’; otherwise it shows as β€˜off’.

However, the sensor itself never changes. Am I missing something here?

It may be easier to just put all the sensors in a group.water_sensors. The group.water_sensors will turn on when anyone of the binary_sensor will turn on.

2 Likes