Martin's corner on the web

Garden irrigation with Home Assistant, Sonoff Zigbee valves and soil moisture sensors

I have been using Sonoff Zigbee valves on the garden taps since last summer, they replaced the mechanical Gardena timers. With the Gardena timers I had to walk from tap to tap and wind each one, in daylight when watering makes the least sense, and when we were away or I could not be bothered nothing got watered at all. I should have done the switch years earlier.

The water first goes through a Sonoff SWV master valve with a built-in flow meter (I added it after a pipe fitting downstream let go a few times), then the Gardena booster pump that starts by itself when the pressure drops, and then six more SWV valves, one per zone:

  • metal shack
  • BBQ zone
  • tool shack
  • south side
  • front yard
  • near the sunroom

For the soil I use two Third Reality soil probes, one in the backyard and one in the sunroom bamboo pots. Back in 2012 I built my own soil moisture sensors. These ones are capacitive, run on a single AA and show up in Zigbee2MQTT, so I just bought two.

The automation runs every night at 03:00 and skips the run if any of these fails:

  • outside temperature above 10 °C
  • humidity below 85 %
  • less than 2.5 mm of rain in the next 12 hours of the Pirate Weather forecast
  • backyard probe below 25 % moisture

The probe reading only counts if it is less than an hour old. This month the master valve got the same rule. Its batteries were at 0 % for over a week and I did not notice, the valve dropped off Zigbee2MQTT, and the run on 8 September was skipped because the gate wanted to see the valve open. Now only a master that is confirmed closed stops a run. Last summer I also had the AI Tasks in HA look at the lawn cameras before a run, to skip it if something was left on the grass, and it caught a beanbag once.

Backyard camera frame with a beanbag left on the lawn, the object the AI check flagged before an irrigation run
The frame that stopped a run: a beanbag on the lawn, spotted by the camera check.
Diagram of the garden irrigation: supply line, Sonoff SWV master valve with flow meter, Gardena booster pump, six zone valves, two soil probes, the 03:00 gate conditions, leak watch, and the separate sunroom bamboo circuit with a Gardena AquaBloom powered through an IKEA TRETAKT plug
Water path and the 03:00 gate. The bamboo circuit on the right has its own reservoir and pump.

When everything passes, the six zones run one at a time, the pump can hold pressure for one zone only. Each zone gets 22 minutes plus a per-zone offset, so a typical night is about three hours and 1 200–1 260 liters. The valve runs the timer itself, so a Home Assistant reboot mid-cycle does not leave a zone open, the script is in a gist.

If there is flow through the master while all six zone valves are closed for 40 minutes, I get a push notification with a Close master valve button. I made it notify-only on purpose, the garden hose trips it too. The storm script I wrote last month kills a running cycle when a hail cell is inbound, and does not resume it, a lost cycle is harmless.

Home Assistant irrigation dashboard: seven zone cards with soil percentages, global run time slider, master valve and pump cards, daily schedule, rain and soil gating sliders, and a flow-per-zone chart
The dashboard view. Tap a zone to run or stop it, hold to enable or disable it, double-tap for its time offset.

The bamboo pots in the sunroom are on a separate circuit. A Gardena AquaBloom waters them from two 10.5 L buckets. Its solar charging was not reliable, so the three AA cells are now a 4.5 V USB battery eliminator on an IKEA TRETAKT plug. The AquaBloom dial stays on its 30-minute program, it pumps from the moment it gets power and HA decides when and for how long (28 minutes, unless the sunroom probe reads above 45 %).

The lawn never looked this good on the mechanical timers, a year in I am quite happy with the result.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.