Most automations save a few seconds. This one is meant to save a floor. A slow leak under a sink or a failed water heater can do a remarkable amount of damage before anyone notices, especially in a basement. The plan is to notice within seconds and stop the water automatically.

The hardware

The five sensors are also combined into a binary sensor group helper, binary_sensor.any_leak, which is on if any of them is wet. That one entity is what the kitchen dashboard shows.

Shut it off, then tell everyone

- alias: "Leak: shut off water"
  mode: single
  triggers:
    - trigger: state
      entity_id:
        - binary_sensor.kitchen_sink_leak
        - binary_sensor.bathroom_vanity_leak
        - binary_sensor.washer_leak
        - binary_sensor.water_heater_leak
        - binary_sensor.basement_drain_leak
      to: "on"
  actions:
    - action: valve.close_valve
      target:
        entity_id: valve.main_water
    - action: notify.household
      data:
        title: "Water leak"
        message: >-
          {{ trigger.to_state.name }} detected water.
          The main water valve has been closed.
        data:
          push:
            sound:
              name: default
              critical: 1
              volume: 1.0
          ttl: 0
          priority: high
          channel: alarm_stream

Keeping it trustworthy

A safety system you can't trust is worse than none, because it lets you stop worrying. Three small automations look after it:

- alias: "Leak: exercise the valve"
  triggers:
    - trigger: time
      at: "03:00:00"
  conditions:
    - condition: template
      value_template: "{{ now().day == 1 }}"
  actions:
    - action: valve.close_valve
      target:
        entity_id: valve.main_water
    - delay: "00:00:30"
    - action: valve.open_valve
      target:
        entity_id: valve.main_water

Ball valves that never move can seize. Once a month, at three in the morning when nobody's running a tap, the valve closes and reopens.

The other two send a normal, non-critical notification when any sensor's battery drops below 20%, or when a sensor has been unavailable for more than an hour. A sensor that's quietly dropped off the network can't report a leak.

Testing it

Twice a year, each sensor gets a damp paper towel. The valve should close, every phone should make a noise it doesn't usually make, and the message should name the right room. It's the most satisfying chore in the house.