How to Build Smart Garden Irrigation with Home Assistant and a Rain Sensor

A smart garden irrigation system built on Home Assistant combines a Wi-Fi-enabled sprinkler controller (commercial or DIY), a rain sensor (physical or API-based), and automations that cancel or adjust watering schedules based on recent rainfall, soil moisture, and the weekly forecast. With the WiseWater integration and Home Assistant 2025.12’s native irrigation scheduling dashboard, this setup is now a genuinely practical alternative to expensive standalone smart irrigation systems that depend on cloud services. Here is how to build one from scratch.
Why DIY Smart Irrigation Beats the Commercial Options
Commercial smart sprinkler controllers like Rachio , Orbit B-hyve , and RainBird Wi-Fi run anywhere from $100 to $200. Their “smart” features - weather-based skip logic, seasonal adjustment, soil type awareness - all require a cloud connection and often a paid subscription. If the vendor shuts down their servers (remember Wink ?), those smart features revert to dumb timer-only irrigation. You are left with an overpriced relay board.
The Home Assistant approach solves this problem entirely. A Sonoff 4CH Pro R3 ($25) or a custom ESP32 with an 8-relay board ($18) paired with a rain sensor ($12 for a tipping-bucket, or free via OpenWeatherMap API) creates a system with zero recurring fees and zero cloud dependency. Everything runs locally on your network.
Home Assistant’s weather integrations are more accurate than what most commercial controllers use internally. You can query OpenWeatherMap , Open-Meteo , or the National Weather Service API for hyper-local precipitation forecasts. Combining predicted rainfall with actual basin accumulation data eliminates over-watering far more effectively than a simple moisture sensor threshold. Commercial controllers typically use a single weather source and a basic algorithm. With Home Assistant, you stack multiple data sources and write the decision logic yourself.
The 2026 hardware situation has improved things further. Matter 1.4 added irrigation device types (controller, valve) to the specification. Home Assistant 2025.12 includes native Matter 1.4 irrigation cluster support, so devices like the Eve Aqua Water Controller Gen 2 and Aqara Cube T1 Pro integrate without any add-ons or custom firmware. If you want something between full DIY and cloud-dependent commercial, Matter devices now occupy that middle ground.
On the performance side, an ESP32-based controller running ESPHome responds in under 100 milliseconds to automation commands. Compare that with a cloud round-trip of 1-3 seconds for commercial controllers that relay commands through a vendor server. When your automation decides to shut off a zone because rain just started, you want that response to be immediate.
This guide covers a 4-8 zone residential garden system. Larger agricultural irrigation scales to the same architecture but needs industrial-grade solenoid valves (24VAC rather than 12VDC) and more robust relay boards.
Hardware Options: Commercial vs. DIY Controllers
The hardware choice depends on your comfort level with electronics and your existing garden infrastructure. Here is the full spectrum from drop-in replacement to fully custom builds.
Commercial Controllers with Home Assistant Integration
| Controller | Zones | Price | HA Integration | Local Control |
|---|---|---|---|---|
| Orbit B-hyve XD | 8 | $89 | bhyve HACS integration | MQTT supported |
| Rachio 3 | 8 | $229 | Official integration | Local polling + webhooks |
| Sonoff 4CH Pro R3 | 4 | $25 | Tasmota or eWeLink | Full local via Tasmota |
The Orbit B-hyve XD is the best value option. At $89 for 8 zones, it works with existing 24VAC solenoid valves already in your garden, and the bhyve HACS integration provides local MQTT control. If you just want to add rain-skip logic to an existing sprinkler system, this is the fastest path.

The Rachio 3 at $229 is the premium choice. It has the most reliable Home Assistant integration (official, with local polling and webhook pushes), the best build quality among consumer irrigation controllers, and the most complete local API. The price is steep, but if you want something that just works out of the box with HA, this is it.

The Sonoff 4CH Pro R3 at $25 is the budget-conscious option. Flash it with Tasmota firmware (possible over the air) to get full local control. The four relay channels handle four individual irrigation zones. The dry relay contacts work with standard 24VAC solenoid valves. For a small garden with four or fewer zones, this is hard to beat on price.
DIY ESP32 Controller
For maximum flexibility and the lowest cost, build your own controller with an ESP32 development board and an 8-relay module. Total hardware cost is roughly $18. Flash the ESP32 with ESPHome to get a fully local-control irrigation controller that integrates natively with Home Assistant.
The parts list for a complete DIY 8-zone controller:
- ESP32 DevKit V1 board - $6
- 8-channel relay module (5V, optocoupler isolated) - $8
- 24VAC power supply (if using standard sprinkler solenoids) - $12
- Project enclosure (weatherproof, IP65 rated) - $10
- Wiring, connectors, fuses - $5
You can add peripherals to the same board: an SSD1306 OLED display for status visibility, a DS18B20 soil temperature sensor, and multiple capacitive soil moisture sensors.
Rain and Soil Sensors
For rain detection, you have three tiers of complexity. At the top end, hardware tipping-bucket sensors like the Davis Leaf & Soil Station ($45) provide actual rainfall accumulation data in millimeters. These are the most accurate option and work independently of any internet connection.
A step down, simple resistive rain sensors ($8, wired to an ESP32 GPIO) provide binary “it is raining right now” detection. Cheap and functional, but no accumulation data.
If you want to skip hardware entirely, the Open-Meteo integration provides free, no-API-key precipitation data with 1-hour resolution. No sensor needed at all, but you are trusting a forecast rather than measuring actual rainfall at your location.
For soil moisture, capacitive sensors (SEN0193, about $4 each) avoid the corrosion problems that plague resistive sensors and work well in garden beds. You can connect up to 8 per ESP32 using the ADC pins. Use averaged readings over a 30-minute window to filter out noise from soil movement and watering artifacts.
ESPHome Configuration for a DIY 8-Zone Controller
If you go the DIY route, ESPHome turns an ESP32 microcontroller into a fully Home Assistant-integrated irrigation controller. Here is the complete configuration structure.
The ESPHome config uses three component types: switch components control relay outputs (one per zone), sensor components read ADC values for soil moisture, and binary_sensor reads the rain sensor GPIO. All state publishes to Home Assistant natively via the ESPHome API - no MQTT broker required.
Here is a minimal configuration for Zone 1 with a rain sensor:
esphome:
name: garden-irrigation
platform: ESP32
board: esp32dev
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
encryption:
key: !secret api_key
ota:
platform: esphome
web_server:
port: 80
switch:
- platform: gpio
name: "Zone 1 Front Lawn"
pin: GPIO32
id: zone_1
icon: "mdi:sprinkler"
restore_mode: ALWAYS_OFF
- platform: gpio
name: "Zone 2 Back Garden"
pin: GPIO33
id: zone_2
icon: "mdi:sprinkler"
restore_mode: ALWAYS_OFF
- platform: gpio
name: "Zone 3 Side Beds"
pin: GPIO25
id: zone_3
icon: "mdi:sprinkler"
restore_mode: ALWAYS_OFF
- platform: gpio
name: "Zone 4 Vegetable Patch"
pin: GPIO26
id: zone_4
icon: "mdi:sprinkler"
restore_mode: ALWAYS_OFF
binary_sensor:
- platform: gpio
name: "Rain Detected"
pin:
number: GPIO27
mode: INPUT_PULLUP
filters:
- delayed_on: 50ms
device_class: moisture
sensor:
- platform: adc
pin: GPIO34
name: "Zone 1 Soil Moisture"
update_interval: 60s
unit_of_measurement: "%"
filters:
- calibrate_linear:
- 3.2 -> 0.0
- 1.4 -> 100.0
- sliding_window_moving_average:
window_size: 10
send_every: 5A few important configuration details worth calling out.
Interlock groups prevent multiple zones from running simultaneously. This matters if your water pressure cannot support two zones at once. Add an interlock key to the switch group listing all zone switch IDs.
Soil moisture calibration requires two reference points: read the raw ADC value in dry air (typically around 3.2V / 3200 raw) and in saturated water (typically around 1.4V / 1400 raw). The calibrate_linear filter converts these to a 0-100% scale. The sliding window average smooths out short-term fluctuations.
The OTA and web server sections are included so you can push firmware updates wirelessly and access a diagnostic web page at the device’s IP address. This avoids the need to physically connect to the ESP32 after initial installation.
Home Assistant Automations for Smart Watering
The actual intelligence in this system lives in Home Assistant automations. Two patterns matter most: weather-based cancellation and soil-moisture-responsive scheduling.
Weather-Based Cancellation
This automation runs every morning before the scheduled watering time and cancels irrigation if rain is expected or already falling:
automation:
- alias: "Irrigation Weather Skip"
trigger:
- platform: time
at: "06:00:00"
condition:
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.openmeteo_precipitation_next_12h
above: 5
- condition: state
entity_id: binary_sensor.rain_detected
state: "on"
action:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.irrigation_rain_delay
- service: notify.mobile_app
data:
message: >
Irrigation skipped -
{{ states('sensor.openmeteo_precipitation_next_12h') }}mm
rain expected in the next 12 hours.The input_boolean.irrigation_rain_delay helper acts as a flag that other automations check before turning on any zone. Set it to auto-clear after 24 hours with a second automation, so irrigation resumes the following day if conditions improve.
Soil Moisture Responsive Watering
This automation checks each zone’s soil moisture and only waters zones that actually need it, with duration calculated from the moisture deficit:
automation:
- alias: "Irrigation Soil Responsive"
trigger:
- platform: time
at: "06:30:00"
condition:
- condition: state
entity_id: input_boolean.irrigation_rain_delay
state: "off"
action:
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.zone_1_soil_moisture
below: 40
sequence:
- service: switch.turn_on
target:
entity_id: switch.zone_1_front_lawn
- delay:
minutes: >
{{ ((40 - states('sensor.zone_1_soil_moisture') | float)
* 0.5) | int }}
- service: switch.turn_off
target:
entity_id: switch.zone_1_front_lawnThe watering duration template calculates minutes based on how far below the 40% threshold the soil currently sits. A zone at 20% moisture gets 10 minutes of watering. A zone at 35% gets only 2-3 minutes. This proportional approach prevents both under-watering and the waste of running every zone for a fixed duration regardless of actual need.
ET-Based Scheduling
For the most sophisticated approach, calculate daily evapotranspiration (ET) using the Open-Meteo sensor’s temperature, humidity, wind speed, and solar radiation data. Compare ET to precipitation to determine the net water deficit, then adjust zone run times proportionally. This is the exact algorithm that commercial smart controllers charge a subscription for - except you own the logic and can tune it to your specific garden.
Multi-Zone Sequential Runs
Wrap the zone-by-zone logic in a Home Assistant script rather than an automation. Scripts are reusable - you can call the same irrigation script from the morning automation, a dashboard button, and a voice assistant command. Use delay actions between zones to run them sequentially without overlap, which keeps water pressure consistent.
Water Usage Tracking
For actual consumption measurement, add a pulse counter sensor to your water meter. A reed switch on the meter’s low-flow indicator connects to an ESP32 GPIO and counts pulses. Each pulse represents a known volume of water. Track sensor.garden_water_litres_today and feed it to the Home Assistant Energy Dashboard for seasonal water usage logging. This gives you hard data on whether your smart irrigation is actually saving water compared to a dumb timer.
Building the Irrigation Dashboard
A well-designed dashboard turns the irrigation system from a set of switches into a garden management interface you actually want to use.
Zone Control Cards
Use a grid card layout with Mushroom
template cards for each zone. Each card shows the zone’s active/inactive state, last run time, current soil moisture percentage, and a manual run button. Color the card green when the zone is active and grey when inactive. The large touch targets on Mushroom cards work well when you are standing in the garden with your phone trying to manually trigger a zone.
Home Assistant 2025.12 Irrigation Scheduler
The native scheduler added in Home Assistant 2025.12 provides a dedicated irrigation view in the Energy Dashboard sidebar. You configure zone run times, days of the week, and weather skip conditions directly in the UI without writing YAML. It works with both native Matter 1.4 devices and manually configured switch entities. The irrigation_unlimited HACS integration provides additional scheduling flexibility if the native scheduler does not cover your use case.
Weather and History Widgets
Add a weather-forecast card showing the 5-day precipitation forecast alongside the irrigation schedule. This lets you manually adjust the schedule before the automated morning run if you disagree with the automation’s decision.
For water history, use a statistics-graph card showing daily and weekly water usage from the pulse counter sensor. Overlay precipitation bars from the weather integration to create a visual that immediately communicates the relationship between rainfall and irrigation activity. The pattern you want to see: when the rain bars go up, the irrigation bars go down.
Zone Map
For gardens with defined bed layouts, the picture-elements card accepts a garden diagram (SVG or photo) as the background. Place zone label overlays that change color based on zone active state. This is purely cosmetic, but it makes the dashboard significantly more intuitive for household members who are not interested in learning entity IDs and YAML syntax.
Practical Tips and Gotchas
A few things that are easy to overlook during setup.
Each solenoid valve draws about 0.3A at 24VAC during inrush, so fuse your relay board. Put a 1A fuse on each zone’s relay output. A stuck relay without a fuse can overheat a solenoid coil and start a fire in your valve box.
On the enclosure side, an IP65-rated project box is the minimum. Mount it under an eave or in a shed if possible. ESP32 boards and relay modules are not designed for outdoor humidity, even inside an enclosure. Throw a small packet of silica gel desiccant inside the box while you are at it.
The restore_mode: ALWAYS_OFF setting in ESPHome is worth double-checking. It ensures that if the ESP32 loses power and reboots, all zones start in the off state. Without this, a zone could restart in its last-known state and flood your garden overnight.
Try to set up the full automation chain during winter when accidentally over-watering or under-watering does not matter. By the time spring arrives, you will have confidence that the weather skip logic and soil moisture thresholds are tuned correctly for your specific garden.
Water pressure is the other thing people underestimate. If your home’s water pressure cannot support two zones running simultaneously, the interlock group in ESPHome is not optional - it is a requirement. Running two zones on insufficient pressure results in both zones getting inadequate coverage, which is worse than running them sequentially.
The total cost for a complete 8-zone DIY smart irrigation system with soil moisture sensing and rain detection is roughly $60-80 in hardware, plus whatever Home Assistant instance you already have running. Compare that with $229 for a Rachio 3 plus a cloud subscription for weather intelligence features. The DIY system is cheaper, more capable, and entirely under your control.