Michael Zazon

Home automation · Build log

Leak to closed valve in 68 ms

My leak and smoke sensors sat dark for a week with zero alerting, so I built the safety automations from scratch and the first live water test closed the main in 68 ms.

Why haven’t I gotten any notifications from Home Assistant, you might ask? Well, I assumed they were broken, but they weren’t.. it’s just that I had zero automations, so the notify service was never being called.

This question came to me just as HA’s telemetry started hitting my new metrics DB (VictoriaMetrics as the first metrics database on my home server), and the first thing I noticed was that both of my Phyn leak pucks and First Alert smoke/CO detectors had been unavailable for about a week.. and nobody had been alerted to that fact.

Safety sensors dark at first, then zero unavailable by August 8

I already had the shutoff hardware in place (an EcoNet Z-Wave motor on a Bulldog ball valve on the main, on the network but not being used for anything), so the first automation I built closes that. When the leak sensor gets wet, HA closes the main first, then pages me, allowing the notification steps to fail without preventing the shutoff. Water never gets automatically restored.. restoring it is a human decision. Now the house can protect itself even if my phone is in another room.

Two design choices made this durable. First, I put all leak sensors in a group helper and triggered the automation from the group, not the device class. The Phyn sensors report device class “problem”, not “moisture”, so a moisture trigger would match nothing and protect nothing. When I later added two Zooz sensors (under the kitchen sink and in the laundry closet) to the group, I didn’t have to edit the automation.

Tip · Not all leak sensors report as moisture

A trigger on “any moisture sensor” only covers sensors that actually report as moisture. Grouping the sensors you care about means coverage is a list you can read, not a guess.

Second, the valve semantics were inverted. The Z-Wave switch showed off while water was flowing.. off meant open and on meant closed. That’s a vendor decision, not a Z-Wave convention. I wrapped the raw switch in a Change device type of a switch helper with invert on to get a true valve entity where close means close. The helper docs pointed me to that native option instead of a template valve. Downstream automations don’t know or care that the semantics are inverted.

Note · Check which way off goes

The Z-Wave switch showed off when water was flowing: off meant open, on meant closed. Change the device type of a switch helper with invert to get a valve entity where close means close.

Leak sensors in one group close the valve before phones get paged Leak sensors One leak group Shut-off automation Wrapper flips on/off Z-Wave valve on main after close Then page phones

From the beginning, I set up a standing rule to send water and leak alerts directly to my phone as iOS critical alerts, plus a Pushover message. I tested the valve by pressing its button once, and it closed while both alerts made it through. But then I asked about the night: would I sleep through it? Would it get re-pinged? I bumped both water alerts to Pushover’s emergency priority, which repeats every minute for up to an hour until acknowledged.

Warning · One press only on the valve button

On the EcoNet motor, three quick presses start Z-Wave inclusion or exclusion, and holding the button for 10 seconds factory resets it. A test only needs one isolated press.

Smoke and CO got the same upgrade, and moving them exposed a silent failure in my safety alerts. I moved the detectors from SmartThings to Z-Wave, and the obvious thing was to add the new entities to the existing smoke alert. That looked right, but it paged nobody because the Z-Wave detectors report “on”, never “detected”. So the alert got a second trigger for that state. The offline watchdog missed them, too: the pattern matched no smoke entities. Now one Life Safety label covers all safety sensors and the valve, and a native HA automation pages me if any labeled entity goes dark. I discovered that Siri could shut off the house water (“turn on the water valve” drove a raw inverted switch). The valve is permanently removed from HomeKit and renamed in a room-and-function style. (Naming things in Home Assistant)

The first live water test was real proof. The probe got wet at 19:09:23.685 and the automation started 1 millisecond later. The valve reported closed at 19:09:23.753.. 68 milliseconds after the probe got wet, and before any notification was sent. When the sensor dried, I reopened the valve from HA and nothing closed it again.

The test exposed two gaps: a second phone in the house had never been on any life-safety page since I had the automations, and every leak was triggering two emergency sirens instead of one. Both were fixed that same evening. Now, if HA closes the valve, I get a single quiet receipt, but if the valve closes on its own, both phones get an emergency alert.

Any new leak sensor is covered as soon as it joins the group, and the close-first pattern carries over to CO. Next up are the places without sensors. The bathrooms need leak sensors, the sump pit needs a Z-Wave sensor (the Eve sensor there doesn’t have Matter firmware), and CO is next on the build list: A CO alarm that turns on every light and talks on all 8 Sonos.