Cheap DIY water shut off valve

I’ve put together a cheap HA-integrated water shut off valve with leak detection.

It uses a motorized ball valve, a modified Sonoff basic and in my case, Xiaomi Aquara water leak sensors but of course other ones should work.

Video demonstration:

Write up with links and configuration sample: GitHub - reefab/homeassistant-water-valve: DIY Automatic water shut off valve using Home Assistant

I did not install it on my water supply yet, I’m waiting on a water meter replacement and this valve will be installed right at the output of the meter.


Hey @reefab thanks for sharing this.

I followed your guide and I think I have done the wiring right but I do not manage to have the valve closed when sonoff is turned on. Would you mind taking a look at my wiring and let me know?

Also does it mean that when you turn sonoff ON the valve closes and when you turn it OFF the valve opens?

Most of these valves are closed (off) Open (On) I’m looking to use one of these too for my solar heater on my pool.

I used these, because you only need a pulse to open and a pulse to close. Didn’t want the valve to be locked open or closed on power failure:

Well, the wiring to the valve might be ok but the relay is not connected to the sonoff, I presume you wired those contacts after taking the photo?

And yes, I wired it so that the valve closes when the sonoff is on and opens when the sonoff is off.

I am not sure which relays you are referring to. Can you draw it on the picture?

By the way, I recently got it installed in situ. It works great and I’ll shoot a new video shortly. The reaction time is pretty good.

Here you go: the pins of the relay coil needs to be connected the original pins on the sonoff. Either use wires or bend the pin 90 degrees.

Nope I haven’t done that and I was pretty certain that was what I was missing but from the photos that you have published, I was not seeing those connected. Will try that tomorrow and let you know. Thanks a lot!

@reefab works like a charm now that I wired the relays. Thanks a lot again for sharing this!

I now it’s an old conversation but i’m working on a little project with an electric valve as well and I’m wondering if you can use a smart plug and just put it on or off in HA. So wire the cables to a plug and put it in the smart plug to control it!

It would be one way only with those kind of valve.

So if you have a manually resettable valve you could plug it into a smart plug and have it close when activated but you’ll need to manually open it up afterwards.

Wouldn’t that be desirable anyway ? False alarm or not, you’d have to manually check for leaks once it triggered. If there’s a leak, that’s not going to fix itself, so an automatically or remotely resettable valve wouldn’t be too useful / safe.

But isn’t the valve closed when there is no power?
At least that’s what I thought. So if you cut off the power it closes.

It’s for watering my yard. So there is a hose attached

Ah got it, so it’s not an emergency cutoff valve. Yeah, then automatic open / close would probably be desirable :grinning:

Should’ve said that. Sorry.

So this is going to work? Hopefully…

I think this valve doesn’t work the way you think it is. Then again, the description on that page is extremely unprecise. I found that thing here of what seems to be the same valve, at least it shows the top of the valve with some technical info. Apparently what I could gather from that page, this is a bistable 2 way valve. That means if you apply power to one of the two control wires (the third is neutral), the valve opens and (hopefully) stops when it’s fully open. To close it, you have to apply power to the other control wire. By itself, that is a good principle. But you need to control it differently.

That said, and let me make this absolutely 100% clear here: DO NOT USE THIS VALVE. This is absolute zero-quality China crap and it uses 230V on your main water supply. It is not grounded and uses the earth wire as a control wire. Not only is this 100% against all sane electrical codes anywhere in the world (probably China included), it’s also extremely dangerous. If there’s a fault somewhere in that non-grounded thing, it could put live 230V onto your water supply.

If you want to use these cheap things on your main water supply (I wouldn’t, they’re probably more a risk than a mitigation of a leak), then make sure they’re at least low voltage.

You make an absolute valid point. The wires seems to me it’s grounded but I’m not sure. I think I’m going to skip this one. 14€ seems to good to be true for a thing like this.

The valve in your comment looks almost identical.

Thank you for warning me.

Do you have any other ideas on how I can automate my irrigation system? That’s not overly priced?

Oh, it is. It was just because they had an image from the top where you can see the schematics. The one you linked to had not. But they’re very much the same the crap :slight_smile:

Your idea is good. I would just use a different valve. If you absolutely have to run it on 230V, then get a good one from a reputable brand with all needed certifications. If you want to use something cheap from Ali, then take a low voltage one (12/24V). If that one breaks, the worst you get is a new pool in your backyard. If the 230V one breaks, worst case is someone dies from touching the water supply.

1 Like