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
- Five Zigbee moisture sensors: under the kitchen sink, under the bathroom vanity, behind the washer, beside the water heater and next to the basement floor drain. They're cheap, run for a year or more on a coin cell, and are small enough to sit flat on the floor.
- A motorised valve actuator clamped onto the existing quarter-turn ball valve on the main supply. No plumbing changes needed. In Home Assistant it appears as a
valveentity,valve.main_water.
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
- Closing the valve comes first. The notification can take a moment; the valve shouldn't wait for it.
- The trigger lists each sensor rather than the group, so
trigger.to_state.namesays which sensor is wet. - The extra
datamakes it a critical alert. Thepushblock is for iPhones and breaks through Do Not Disturb.ttl,priorityandchanneldo the same on Android. Each platform ignores the other's keys. - Nothing reopens the valve automatically. Turning the water back on is a decision for a person standing next to a dry floor.
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.