What do you need before you start?
- A leak sensor: a Zigbee, Z-Wave, Thread or Wi-Fi water sensor that Home Assistant can see. Our best smart water leak sensors roundup covers what to buy. Whatever the brand, it should appear as a binary sensor with the moisture device class.
- The Companion app: it provides the
notify.mobile_app_<your_phone>action used throughout. If it is not set up yet, follow the mobile app guide. - Your entity IDs: find them under Settings → Devices & services → Entities. The examples use
binary_sensor.kitchen_leakandbinary_sensor.utility_leak; swap in your own. - Optional: a motorised shut-off valve that Home Assistant exposes as a valve or switch entity, covered in Step 5.
Where should you put leak sensors?
Put them where water collects first, not where you would notice it first. The usual culprits are the floor beside a washing machine or dishwasher, under the kitchen sink, behind the toilet, beside the boiler or hot water cylinder, and in a utility room or loft near a header tank. Place the sensor flat on the floor with its probes touching the surface, at the lowest point, because water runs downhill and a sensor on a shelf will only trigger once the leak is serious.
Wired probe cables are worth considering for tight spots such as under a sink, because the cable lets the radio body sit somewhere with a better signal. If you are also protecting a washing machine, our washing machine finished notification guide uses a different signal (power draw) and pairs well with a floor sensor.
Step 1: Check what your sensor reports
Open Developer tools → States, search for your sensor and look at its state. According to the Home Assistant binary sensor documentation, the moisture device class reports on when moisture is detected (shown as Wet) and off when none is (shown as Dry).
Now test it for real: touch the probes with a damp paper towel or dip them in a saucer of water and watch the state flip to on, then dry them and confirm it returns to off. Doing this before you write any automation tells you how quickly the sensor reports and whether your radio coverage is adequate at that spot. Note the sensor's friendly name too, because the notification will use it to say which room is flooding.
Step 2: Create a basic leak alert
Go to Settings → Automations & scenes → Create automation, switch to YAML from the three-dot menu and paste this. A leak is not something to debounce for minutes, so there is no for delay on the trigger.
alias: Water leak alert
mode: parallel
triggers:
- trigger: state
entity_id:
- binary_sensor.kitchen_leak
- binary_sensor.utility_leak
to: "on"
actions:
- action: notify.mobile_app_your_phone
data:
title: "Water leak detected"
message: "{{ trigger.to_state.name }} is reporting water."
data:
tag: water-leak
One automation covers every sensor in the list, and trigger.to_state.name tells you which one fired. The parallel mode lets a second sensor trigger its own run while the first is still going, which matters once you add the repeat loop in Step 4. The automations guide explains modes in more detail.
Step 3: Make the notification loud
A normal notification can sit silently on a locked, muted phone. The Companion app documentation describes how to override that. On iOS, a critical notification appears at the top of the lock screen and plays a sound even when Do Not Disturb is on or the phone is muted. On Android, setting ttl: 0 and priority: high makes the notification show immediately and ring, and adding channel: alarm_stream plays it through the alarm volume, which sounds even in vibrate or silent mode.
Replace the notify action in Step 2 with the block for your phone. For an iPhone:
- action: notify.mobile_app_your_iphone
data:
title: "Water leak detected"
message: "{{ trigger.to_state.name }} is reporting water."
data:
tag: water-leak
push:
sound:
name: default
critical: 1
volume: 1.0
For an Android phone:
- action: notify.mobile_app_your_android
data:
title: "Water leak detected"
message: "{{ trigger.to_state.name }} is reporting water."
data:
tag: water-leak
ttl: 0
priority: high
channel: alarm_stream
If your household has both kinds of phone, use one action per device rather than trying to merge the blocks. On iOS you may be asked to allow critical alerts in the app's notification settings the first time, so run a test now rather than discovering that at 3am. Use this level of noise only for leaks and similar emergencies; if everything is critical, people start ignoring it.
Step 4: Repeat the alert until the floor is dry
One alert is easy to miss or swipe away. A repeat loop with a while condition keeps nagging until the sensor reads off again, which happens when the probes dry out or you mop up. Wrap the notify action like this, using the entity that fired the trigger:
actions:
- repeat:
while:
- condition: template
value_template: "{{ is_state(trigger.entity_id, 'on') }}"
- condition: template
value_template: "{{ repeat.index <= 10 }}"
sequence:
- action: notify.mobile_app_your_iphone
data:
title: "Water leak still detected"
message: "{{ trigger.to_state.name }} is still wet."
data:
tag: water-leak
push:
sound:
name: default
critical: 1
- delay: "00:02:00"
The cap of ten repeats stops an endless loop if a sensor sticks on, so you get roughly twenty minutes of reminders. Reusing the same tag means each new message replaces the previous one on your phone instead of stacking. Because the loop checks trigger.entity_id, it works for whichever sensor fired, and parallel mode lets two leaks run side by side.
Step 5: Alert everyone and, optionally, close the water
A leak while you are at work is a problem for whoever is home. Create a notify group under Settings → Devices & services → Helpers (the Group helper's Notify group option) containing each person's mobile app, then use the group's action name in place of notify.mobile_app_your_iphone. Adding a second action that announces the room on a smart speaker is useful for anyone without the app.
If you have a motorised shut-off valve, the same automation can close it. Home Assistant provides a valve.close_valve action for entities in the valve domain; older integrations may expose the valve as a switch, in which case use switch.turn_off or switch.turn_on according to how it behaves. Put it as the first action so the water stops before the notifications go out:
- action: valve.close_valve
target:
entity_id: valve.main_water
Think carefully before automating this. A valve that closes on a false alarm will cut off water to the whole house, and a valve left closed for months can seize. Our smart water shut-off valve guide covers hardware options and installation considerations, and a plumber should fit anything on the mains supply. A closed valve also does not replace your manual stop tap, so know where that is.
Step 6: Get warned when a sensor stops responding
A leak sensor that has quietly died protects nothing. Battery sensors sit unattended for years in damp, cold places, which are the worst conditions for batteries and radio links. Add a second automation that fires if any sensor has been unavailable for a few hours:
alias: Leak sensor offline
triggers:
- trigger: state
entity_id:
- binary_sensor.kitchen_leak
- binary_sensor.utility_leak
to: "unavailable"
for: "06:00:00"
actions:
- action: notify.mobile_app_your_phone
data:
title: "Leak sensor offline"
message: "{{ trigger.to_state.name }} has been unavailable for 6 hours."
The state trigger's for option means the sensor must stay in that state for the whole period. The Home Assistant documentation notes that the timer resets if Home Assistant restarts or automations reload, so a restart can delay this warning by up to the full period. Pair it with the low battery alerts guide so a flat battery is flagged before the sensor goes offline altogether.
Step 7: Test the whole chain
Do not trust it until you have watched it fire. Touch a damp paper towel to each sensor in turn and check four things: the notification arrives, it sounds with the phone muted, it repeats, and it stops after you dry the probes. If you added a valve, test that with the water supply isolated or with the valve safe to operate, and confirm the valve reopens when you want it to, because the automation above only closes it.
Each automation's Traces tab shows exactly which trigger fired and where a run stopped, which is the fastest way to debug silence. Repeat the test every few months; put a reminder in your calendar, because a stuck sensor or a changed notify service name is the sort of thing you only find out about during a real leak.
Why did my leak alert not fire? Common problems and fixes
The usual cause is that the sensor never reached Home Assistant in the first place, so check the sensor's state in Developer tools → States before blaming the automation.
The state never changes to on: the probes may not be touching the water, or a wired probe is unplugged. Some sensors need a conductive film of water across both contacts, so a single drip may not register. Test with a saucer of water.
The sensor shows unavailable: check the battery first, then the radio link. A metal cabinet under a sink can weaken a Zigbee signal; move the sensor body outside the cabinet and run a probe cable in.
The notification arrives silently: you are using the plain action rather than the critical or alarm-stream version, or iOS critical alerts are not allowed in the Companion app's notification settings.
No notification arrives: run the notify action on its own from Developer tools → Actions. If it fails, the notify.mobile_app_ name is wrong. The notifications guide covers the basics.
It fires when nothing is wet: condensation or a cold pipe can trigger some sensors. Move the sensor off the pipe and onto the floor.
What should you do when the leak alarm goes off?
Turn the water off at the stop tap first, then find the source. WaterSafe says the internal stop tap is usually under the kitchen sink, with other common places including a downstairs bathroom or toilet, a garage or utility room, a cellar or under the stairs. Turning it clockwise closes it, anticlockwise reopens it, and it should be operated slowly without forcing, because over-tightening can damage it. WaterSafe also advises checking it works regularly, so you are not trying it for the first time in an emergency.
Thames Water adds that you should always have a working inside stop valve and use it as your main way to turn the water on and off, with the outside valve kept for emergencies on the supply pipe. If the leak is near electrics, switch those off at the consumer unit only if it is safe to reach, and call an approved plumber. A leak alert gets you there in minutes instead of hours; it does not fix the pipe.
Once this is working, the same pattern protects other risks: see the frost alert for frozen pipes for the cold-weather version of the same problem.







