Leak-triggered main shutoff with a 4 litre flow threshold
Six leak pucks plus a whole-house flow meter close the main valve when any puck gets wet, or when flow exceeds 4 L/min for 12 minutes with no fixture in use. Measured shutoff time from water contact to closed valve: 9 seconds.
# HearthNodes recipe 21 - leak shutoff
alias: "Water - leak or runaway flow closes the main"
id: hn_water_leak_main_shutoff
description: "Any puck wet, or 4 L/min idle flow for 12 minutes, closes the main"
mode: single
max_exceeded: silent
trigger:
- platform: state
entity_id:
- binary_sensor.leak_puck_1
- binary_sensor.leak_puck_2
- binary_sensor.leak_puck_3
- binary_sensor.leak_puck_4
- binary_sensor.leak_puck_5
- binary_sensor.leak_puck_6
to: "on"
id: puck_wet
- platform: numeric_state
entity_id: sensor.house_water_flow_lpm
above: 4
for: "00:12:00"
id: runaway_flow
variables:
fixtures_that_may_run:
- binary_sensor.bath_tap_active
- binary_sensor.shower_active
- binary_sensor.garden_tap_active
- binary_sensor.irrigation_running
- binary_sensor.washing_machine_active
- binary_sensor.dishwasher_active
valve: valve.water_main
condition:
- condition: state
entity_id: "{{ valve }}"
state: "open"
- condition: template
value_template: >-
{{ is_state('person.primary','home') or is_state('person.partner','home')
or is_state('input_boolean.away_flow_guard','on') }}
- condition: template
value_template: >-
{{ trigger.id == 'puck_wet'
or (trigger.id == 'runaway_flow'
and fixtures_that_may_run | select('is_state','on') | list | count == 0) }}
action:
- service: valve.close_valve
target:
entity_id: "{{ valve }}"
- wait_template: "{{ is_state_attr(valve, 'current_position', 0) }}"
timeout: "00:00:10"
continue_on_timeout: true
- service: siren.turn_on
target:
entity_id: siren.indoor
data:
tone: water
duration_s: 90
- service: notify.all_devices
data:
title: "Water shut off"
message: >-
{{ trigger.id }} on {{ trigger.entity_id }}.
Flow {{ states('sensor.house_water_flow_lpm') }} L/min.
Valve {{ states(valve) }}. Reset by hand at the valve.
- service: input_boolean.turn_on
target:
entity_id: input_boolean.water_lockout
# Puck buzzers are local hardware and still sound with the hub down. Valve fails
# to confirm closed in 10 s -> two retries, then a notification with instructions
# for the manual bypass. Monthly exercise cycle closes and reopens the ball valve
# at 04:00 on the first of the month so scale cannot seize it.
Trigger · state
binary_sensor.leak_puck_[1..6]
Any leak puck reports moisture, or the whole-house flow meter exceeds 4 L/min while every fixture is idle.
Step-by-step
- valve.water_mainClose the ball valve motor and verify the position feedback; on this hardware a full close takes 7 seconds from open.
close · confirm position within 10 s - siren.indoorSound an audible alarm; a silent shutoff leaves a plumber searching for why the taps do not work.
on · pattern 'water' · 90 s - notify.all_devicesNotify every adult in the household with the specific puck, the flow reading and the valve state, so nobody reopens the valve without knowing why it closed.
send · which puck · flow rate · valve state - input_boolean.water_lockoutLatch a lockout that must be cleared by hand on the valve itself, so the system cannot re-open onto a burst pipe automatically.
on · requires manual reset
Put pucks where water actually pools
Under the dishwasher, in the cabinet below the sink, beside the washing machine, next to the water heater, under the fridge's ice maker line, and in the bathroom's lowest corner. Pucks on open floor are wasted; water runs along the cabinet base and pools at the back corner, not where you can see it.
Tune the flow threshold against your real baseline
Watch the flow meter for a week and note the highest reading when nothing is running — typically 0.1–0.3 L/min for a leaking toilet flapper. Set the threshold at least ten times that, so a slow toilet leak does not shut the house off every night, and keep the dwell at 12 minutes.
Make the shutoff loud and the reset manual
A silent valve closing at 03:00 means the morning starts with a plumber guessing. Sound the siren, notify everyone, and require a physical reset at the valve. The whole point is to stop water, and a quick manual re-open defeats it.
Hardware
| Model | Protocol | Link | Role in this chain |
|---|---|---|---|
| Z-Wave motorised ball valve (1") | zwave |
wired | Mains-powered actuator with position feedback; a spring-return valve without feedback would leave you guessing whether it actually closed. |
| Whole-house ultrasonic flow meter | zwave |
wired | Non-invasive clamp-on sensor; gives litres per minute at 0.1 L resolution, which is what the 4 L/min threshold needs. |
| Zigbee leak pucks with a local buzzer | zigbee |
wireless | Battery-powered pucks under each wet appliance; the local buzzer matters because it works even if the hub is down. |
When it fails
If the valve does not confirm closed within 10 s, the automation retries twice and then notifies with instruction to close the manual bypass. If the hub is down, each puck's own buzzer still sounds. The flow-based trigger is disabled while the away guard is off, because a 12-minute garden tap can legitimately exceed 4 L/min.