Garden Irrigation: Solenoid Valves, Zones, Schedules, Rain, and Manual Override

Module 21 · Lesson 8

Garden Irrigation: Solenoid Valves, Zones, Schedules, Rain, and Manual Override

The risk level shifts starting with this lesson: a gate failure endangers people, an irrigation failure floods the lawn or dries out the flower beds. That means we can afford more automation and fewer manual confirmations, but still with hard safeguards against flooding and a pump running dry.

Budget around 85 minutes. Example entities: switch.lawn_zone_valve, switch.beds_zone_valve, binary_sensor.rain_detected, sensor.beds_soil_moisture, input_number.rain_threshold_in from Lesson 1.

A Problem from Real Life: Watering During a Downpour

A simple time-based schedule ("water every day at 6am") works right up until it starts raining overnight: a fixed schedule fires the valves in the morning anyway, onto already-soaked ground. The opposite problem: a drought in August, and the system "conserves water" according to a schedule set back in spring. The fix isn't smart weather pulled from the cloud, just simple logic: a schedule as the starting point, a rain sensor and soil moisture as a correction, manual override always available.

Solenoid Valves: Hardware and Wiring

Classic garden solenoid valves (24V AC, run through a typical irrigation controller) are simplest to integrate through a relay module with an external 24V AC power supply, something like a Shelly Plus i2/i4 for reading, or a dedicated irrigation controller with native Home Assistant integration if you'd rather skip wiring your own relays. Cheaper battery-powered Bluetooth valves (popular in the hobby-gardening segment) usually come with their own cloud integration of limited reliability: check before buying whether a local integration exists before you build your whole logic on top of them.

Never two zones at once on a weak supply line
A home's water supply line has limited flow. Turning on two valves at once drops pressure in both zones instead of doubling the effect: design your automation so valves open sequentially, one zone after another, never in parallel.

Helpers Specific to Irrigation

input_boolean:
  irrigation_enabled:
    name: "Automatic irrigation enabled"
    icon: mdi:sprinkler
    initial: true
  irrigation_manually_paused:
    name: "Irrigation manually paused"
    icon: mdi:hand-back-right
    initial: false

input_number:
  lawn_watering_minutes:
    name: "Watering time: lawn"
    min: 1
    max: 60
    step: 1
    initial: 15
    unit_of_measurement: min
  beds_watering_minutes:
    name: "Watering time: garden beds"
    min: 1
    max: 60
    step: 1
    initial: 10
    unit_of_measurement: min
  soil_moisture_threshold_pct:
    name: "Soil moisture threshold"
    min: 10
    max: 80
    step: 5
    initial: 35
    unit_of_measurement: "%"

A Sequential Script for Watering One Zone

script:
  water_zone_beds:
    alias: "Water zone: garden beds"
    icon: mdi:sprinkler-variant
    mode: single
    max_exceeded: silent
    sequence:
      - condition: state
        entity_id: input_boolean.irrigation_manually_paused
        state: "off"
      - condition: state
        entity_id: input_select.garden_mode
        state:
          - "Summer"
      - action: switch.turn_on
        target:
          entity_id: switch.beds_zone_valve
      - delay:
          minutes: "{{ states('input_number.beds_watering_minutes') | int }}"
      - action: switch.turn_off
        target:
          entity_id: switch.beds_zone_valve
      - action: logbook.log
        data:
          name: "Irrigation"
          message: "Finished watering the beds zone."

The script checks input_select.garden_mode from Lesson 1: irrigation only runs in Summer mode, not Winter, Vacation, or Service. For Vacation mode, a separate, shorter maintenance schedule is a better fit than shutting everything off entirely: more on that later in this lesson.

Automation: A Morning Schedule Adjusted for Rain and Moisture

automation:
  - alias: "Irrigation: morning schedule adjusted for conditions"
    id: irrigation_morning_schedule_adjusted
    mode: single
    triggers:
      - trigger: time
        at: "06:00:00"
    conditions:
      - condition: state
        entity_id: input_boolean.irrigation_enabled
        state: "on"
      - condition: state
        entity_id: input_boolean.irrigation_manually_paused
        state: "off"
      - condition: numeric_state
        entity_id: sensor.beds_soil_moisture
        below: input_number.soil_moisture_threshold_pct
      - condition: state
        entity_id: binary_sensor.rain_detected
        state: "off"
    actions:
      - action: script.turn_on
        target:
          entity_id: script.water_zone_lawn
      - wait_for_trigger:
          - trigger: state
            entity_id: script.water_zone_lawn
            to: "off"
        timeout: "00:30:00"
      - action: script.turn_on
        target:
          entity_id: script.water_zone_beds

The sequencing is enforced by wait_for_trigger watching for the lawn zone's script state to change to off, only then does the second zone's script run. The numeric_state condition reads the threshold straight from the helper, so moving the slider on the dashboard changes behavior instantly, with no automation edits needed.

Automation: Interrupt Watering if Rain Starts Mid-Cycle

automation:
  - alias: "Irrigation: interrupt if rain starts mid-cycle"
    id: irrigation_interrupt_rain_mid_cycle
    mode: single
    triggers:
      - trigger: state
        entity_id: binary_sensor.rain_detected
        to: "on"
    conditions:
      - condition: or
        conditions:
          - condition: state
            entity_id: switch.lawn_zone_valve
            state: "on"
          - condition: state
            entity_id: switch.beds_zone_valve
            state: "on"
    actions:
      - action: switch.turn_off
        target:
          entity_id:
            - switch.lawn_zone_valve
            - switch.beds_zone_valve
      - action: notify.mobile_app_your_phone
        data:
          title: "Irrigation interrupted"
          message: "Rain detected mid-cycle. Valves closed."

Manual Override: A "Pause for 24h" Button

script:
  irrigation_pause_24h:
    alias: "Irrigation: pause for 24 hours"
    icon: mdi:pause-circle
    mode: single
    sequence:
      - action: input_boolean.turn_on
        target:
          entity_id: input_boolean.irrigation_manually_paused
      - delay: "24:00:00"
      - action: input_boolean.turn_off
        target:
          entity_id: input_boolean.irrigation_manually_paused

Put the button that calls this script somewhere prominent on your outdoor dashboard: after mowing the lawn or applying fertilizer, you want to pause automation for a day with one tap, without digging into settings. Keep in mind: an HA restart during the 24-hour delay cuts off the delay step, so the input_boolean won't turn back off on its own until the script runs again or you flip it manually.

Solenoid Valves: Zigbee, Wi-Fi, and the Irrigation Unlimited Integration

OptionProtocolCharacteristics
SONOFF Zigbee Sprinkler / Smart Water ValveZigbee 3.0needs a Zigbee gateway (coordinator), integrates through ZHA or Zigbee2MQTT like other devices from Module 9
MOES Smart Water ValveWi-Fi or Zigbee (two versions)both versions include automatic shutoff after a set time and leak protection
Irrigation Unlimited (a HACS integration)hardware-independentlayers logic (zones, schedules, weather correction) on top of any switches or valves you already have wired up

Irrigation Unlimited is especially handy if you already have valves wired through plain relays: the integration doesn't care about the valve's brand, only the switch entity it toggles according to its own schedule and conditions, including integration with soil-moisture probes built on ESPHome.

Drip Irrigation vs. Sprinklers: Choosing by Zone

Irrigation typeBest useWater use
Drip irrigationvegetable beds, shrubs, flower borderslowest, water goes straight to the roots
Pop-up sprinklerslawns, large areashigher, some water evaporates before reaching the soil
Micro-sprinklersplanters, smaller beds, plants sensitive to direct water contactmedium

Good practice is splitting the system into zones matching different plant types, each with its own schedule: a lawn needs more frequent, shorter watering than deep-rooted shrubs, and a drip system in vegetable beds has entirely different timing needs than lawn sprinklers.

Integrating a Forecast Ahead of Time, Not Just Current Rainfall

The automation in this lesson reacts to rain that's currently falling, but a more advanced approach also factors in the forecast for the next 24 to 48 hours: if tomorrow's forecast calls for heavy rain, it makes sense to skip today's watering even if it's dry right now. A weather integration (Met.no built into Home Assistant, or OpenWeatherMap) provides a forecast entity you can use as an extra condition in the morning-schedule automation.

Water Pressure Control and Protecting a Pump from Overload

Systems fed directly from the municipal water line rarely need an extra pump, but installs drawing from a tank and pump (tying back to Lesson 9) should have a safeguard against opening too many zones at once, which would drop pressure below the minimum sprinklers need to work properly. The simple rule in the sequential script, opening zones one after another instead of all at once, already described in this lesson's main content, is exactly that safeguard.

Irrigation and Local Water Restrictions During Droughts

Some municipalities introduce seasonal restrictions on using municipal water for garden irrigation during summer months, usually with specific permitted watering hours. It's worth designing this lesson's automation schedule with those restrictions in mind from the start, drawing on stored rainwater (Lesson 9) where possible during droughts, when municipal supply is restricted, instead of relying solely on the water main.

Drip Irrigation for Pots and Balcony Planters

The irrigation system described in this lesson focuses on ground planting, but the same solenoid-valve and scheduling logic works just as well for pots and balcony planters, which usually need more frequent but shorter watering than ground beds, given the smaller volume of growing medium that dries out faster in the sun. A separate, dedicated zone for planters, with its own schedule and a substrate-moisture sensor, avoids a situation where one universal schedule either drowns the potted plants or underwaters the ground beds.

A Manual Bypass for an Electronics Failure

Every electronically controlled solenoid valve should have a physical, manual bypass (usually a knob on the valve body itself), letting you water the garden even during a complete Home Assistant or power failure. It's worth checking and testing this function right after installation, not only once you actually need it, to avoid an unpleasant surprise the first time the system fails.

How to Test This Lesson

1. Run the zone script manually and time it with a stopwatch to confirm the valve closes exactly at the set duration.

2. Simulate rain (manually toggle the binary_sensor in Developer Tools) mid-cycle and confirm the interruption.

3. Tap "Pause for 24h" and confirm the morning schedule doesn't open the valves the next day.

Common Mistakes

Two zones at once: pressure drop, weak watering in both zones simultaneously.

A rigid schedule with no rain sensor: watering straight through a downpour.

No manual override: after fertilizing, you have to dig into the automation instead of tapping one button.

Practical Task

☐ Build sequential scripts for all your irrigation zones.

☐ Add the automation that interrupts watering when rain is detected.

☐ Add a "Pause for 24h" button to the outdoor dashboard.

Key Takeaways

Water zones sequentially, never in parallel on a weak supply line.

A schedule plus a rain sensor, not a schedule alone.

Manual override always available with one tap.

What's Next

Next lesson: Rainwater and Tanks: Liquid Level, Pump, Dry-Run Protection, Overflow, and a Water Dashboard. Where to get water for irrigation, and how to protect the pump from running dry.

Finished this lesson?