View on GitHub

Smart Irrigation

A Home Assistant integration to optimize irrigation

Full controller

Main page: Usage
Previous: Off-the-shelf controllers
Next: Coming from Irrigation Unlimited

By default Smart Irrigation decides how long each zone waters and leaves the running of the valves to you: an automation, a controller, Irrigation Unlimited. The full controller is an option for those who would rather have it do both. It runs the whole watering itself: when, in what order, with which pump, for how long, and what to do when you want it to stop.

It is off by default, and turning it on changes nothing until you add to it. Nothing on this page appears in the panel until it is on.

The Watering tab: the main program, its schedules and the order of its zones

Turning it on

On the General page, in the card with direct valve control: Full controller: Smart Irrigation runs all my watering.

Switching it on:

Switching it off brings back the previous behaviour: direct valve control returns to what it was before you switched the full controller on (off if it was off), unless you set it yourself in the same change. Your programs and supplies stay stored for the day you switch it on again. If you switched the full controller on with an older version, nothing was remembered, and direct valve control stays on.

One thing is different from the moment it is on: a valve found open at startup that no run of ours owns is closed. After a crash or a restart, a valve left open by a run nobody resumes would water until someone noticed. A reading that says nothing (unavailable, unknown) is never taken for an open valve. That startup alignment also closes a zone's extra valves, and it looks at the supplies: a pump or main valve that is on while nothing holds it is switched off, and one whose state cannot be read yet is looked at again 30 and 120 seconds later, since its entity often comes up after Home Assistant has started.

Pumps and main valves (supplies)

A supply is one or several entities, a pump or a main valve in front of the zone valves, that run while a zone they feed is being watered. Add them in the card Pumps and main valves, then pick one in each zone's settings.

Each supply has two delays, in seconds, and both are signed, from -3600 to +3600:

Positive Negative
Delay before The supply comes on that long before the zone valve opens. The valve opens first, and the supply comes on that long after.
Delay after The supply stays on that long after the zone valve closes. The supply goes off that long before the valve closes, so a pump never pushes against a closed valve.

Power cut before starting (kick_seconds, 0 to 60, 0 by default): for a pump whose pressure controller only starts again after its power has been cut, the supply is switched off that many seconds and then on, each time it is switched on. A supply already on for another zone is not cut again.

A supply is on while anything holds it, and goes off when the last hold is given back, after its delay. It is never switched off on a guess of when the cycle will end. Two zones in a row share one run of the pump, and with a delay after the pump stays on between them.

A supply that will not come on keeps the zone shut. Each switch call is tried twice, 3 seconds apart, and the entity must then read a state within 5 seconds. If the supply still has not come on, the zone's valve is not opened (no pump, no water), the run of that zone ends with a smart_irrigation_zone_problem of reason supply_did_not_turn_on, and smart_irrigation_supply_problem is fired too. A supply that will not go off never blocks anything: the off is tried again after 15, 45 and 120 seconds, smart_irrigation_supply_problem (reason supply_did_not_turn_off) is fired for the first failure (the retries are silent), and a supply still on after that stays recorded as on, so the next run or the next startup puts it off. The payload of supply_problem is supply_id, supply, entity_id and reason (supply_did_not_turn_on or supply_did_not_turn_off).

A zone can also have other valves that open and close with its own (a zone whose water comes through two valves), and light and cover entities are accepted as valves.

Programs

A program is an ordered list of steps. A step is one zone, or several zones watered at the same time. By default a step takes the duration Smart Irrigation calculated for each zone, which is what sets this apart from a timer.

For each step:

For the program:

How the duration of a step is worked out, in this order: the step's percentage (percent steps), then the percentage of an adjust_program adjustment in force, then the step's time added or removed plus the seconds of that adjustment, then the minimum, then the maximum (so when the minimum is larger than the maximum, the maximum wins). Nothing under zero is watered. These bounds apply to the total water of the step, before it is split across the rounds; the lead time comes on top of each pass.

One program, or one cycle of the main program, runs at a time. A different program asked for while one runs waits its turn, and a manual run asked for during a program is added behind it. A program that is already running or waiting is not queued a second time: run_program on it is ignored (with a line in the log), and so is a schedule that comes due meanwhile. The plan is worked out when the turn comes, from the zones as they are then: a zone watered meanwhile is not watered again.

Schedules

A program has any number of schedules, each a moment and the days it applies to.

Good to know: the weather holds work on the zones' calculated durations, which all programs share. On a day a weather-aware start has held a zone back, a program that ignores the weather but waters that zone for its calculated duration finds nothing to water. For a zone that must be watered whatever the weather says, give its step a fixed duration.

A schedule that comes due while its program is already running or waiting starts nothing and counts no watering day; the days between irrigations are only reset for the zones that really start. A program deleted, disabled or suspended while it runs stops before its next step. Deleting a program or a schedule also clears what was remembered of its last run, so a new schedule never inherits it.

An occurrence counts as fired as soon as it comes due, whatever happens next: a schedule that is suspended, whose program is already running, or that the weather holds back is not tried again for that occurrence. A scheduled run that is waiting for its turn when Home Assistant restarts is not kept (only a queued manual run is, see below): it is lost until the schedule's next occurrence.

The Smart Irrigation schedules are armed when a setting changes, after a calculation and at a new day, like the start trigger.

The length a "must be done" schedule works back from is the one the Planning card and the program sensors show, with the adjust_program adjustment in force included. Setting or clearing an adjustment arms the schedules again at once, so the start moves with it.

Schedules of the main program

By default the main program is started by your start trigger. It can have schedules of its own instead, as an option: add one on the Programs page, with the same moments, days, weather choices and fallback time as above.

Driving the watering

The buttons of the Programs card, and these services:

Service What it does
smart_irrigation.run_program Runs a program now, or when it is its turn. Optional seconds (1 to 86400) is a total for the whole program, shared between its steps in proportion to their planned durations (the main program takes none: asking for it is refused with an error); left out, the planned durations. A program that is already running or waiting, disabled or suspended is not run, with a line in the log; the main program joins the queue of the cycles instead. Optional mode: queue (default) takes the turn behind what is running, replace first stops what runs and waits, cleanly (valves closed, delivered water credited), then runs the program.
smart_irrigation.water_zone Waters a zone for a number of seconds of water, or for its calculated duration. With mode: queue (default) it takes its turn like everything else; with mode: replace it first stops what is running and waiting. With several zones, only the first replaces, the others follow it. A zone you suspended is watered anyway: asking for it by hand overrides the suspension.
smart_irrigation.stop_program Stops one program: if it runs, its open zones close the normal way and are credited for what they delivered, and no further step starts; if it waits for its turn, it is taken out of the queue. An unknown id does nothing. The main program is stopped with stop_watering.
smart_irrigation.set_program_enabled, set_step_enabled, set_schedule_enabled Switch a program, one of its steps (step_id) or one of its schedules (schedule_id) on or off (enabled), as the panel does: the schedules are armed again and the panel refreshes. With the full controller off nothing changes; an unknown program, step or schedule id is refused with an error.
smart_irrigation.pause_watering Closes the open valves and holds everything, the zones waiting included. The clock stops: what was delivered is credited and, after the resume, the part of the pass still owed is watered. A pause that is not lifted ends by itself after an hour (or the minutes given).
smart_irrigation.resume_watering Goes on from where the pause stopped.
smart_irrigation.next_step Ends the zones of the step a program is on, and lets it go on. With overlapping steps, it ends every step that is open. It only acts on programs with steps, not on the cycle of the main program, although the card shows the button on a running main row.
smart_irrigation.stop_watering Stops now: every valve is closed, each zone is credited for the water it delivered, programs and waiting zones end. With zones chosen, only those, and the programs under way or waiting do not water those zones in their later steps either. Without zones it also ends a pause.
smart_irrigation.suspend Keeps a zone or a program from watering for some hours or until a date. Zero hours lifts it. Hours are limited to 8760, a date that cannot be read is refused (it never lifts a suspension), and an unknown program id is ignored.
smart_irrigation.adjust_program Makes a program water longer or shorter for a while (Irrigation Unlimited's adjust_time): a percent (0 to 1000) of every step's water, and/or seconds added to it, for hours (1 to 8760) or until reset. It replaces the previous adjustment instead of adding to it, applies to the runs that start after it is set (not to the one under way), survives a restart, and reset: true clears it. Refused when the full controller is off, for an unknown program id, and for the main program (it has no steps to adjust). The program's sensor shows it in the adjustment attribute.
smart_irrigation.use_measured_throughput Takes the flow a zone's meter measured as its throughput. The measurement is advice and is never applied on its own.

Seeing what is going on

The Planning page: what the programs will water over the next three days

When Home Assistant restarts

A program run and a cycle that is under way are recorded as they go. After a restart the run that was open is finished from its own record first, then the steps still to do follow, one at a time. A run more than six hours old is not resumed: it belongs to another day. With overlapping steps, the record is that of the later step: the earlier one that was still open is finished from its own record, and the later one restarts with the zones it had not started. What is not resumed: the remaining passes of the zone that was open (only the pass in progress is).

A pause survives a restart while its end is still ahead: the watering is held again until then (or until you resume), and the valves that were open are not reopened by the pause itself; the program goes on from the resume as it does after any pause. A valve run interrupted by the restart is held the same way: nothing is opened (the pump included) while the pause lasts, and the rest of its pass is watered after the resume, with the water delivered before the restart credited once. A manual run you stopped while it waited is also removed from the stored queue at once, and queued runs wait for every run resumed after the restart (a valve run or a cycle, not only a program) before they start. The water a pause owes is kept too: when a pause closes the valves of a step, what each zone still owes (and the passes after it) is recorded, so a reload (an options save) or a restart during the pause does not lose it. After it, and once the pause is over, those zones water what they owed first (credited once, the part delivered before the pause having been credited already), then the program goes on with the next steps. A pause that ended while Home Assistant was down is not held again, and the owed water is watered at once; owed water more than 30 hours old is dropped. Manual runs waiting for their turn (a run_program asked for during another program) are kept too: after a restart they are put back in line, behind a program that is being resumed, unless they are more than six hours old or their program is gone, disabled or suspended.

A valve that is slow to say it is open, a battery valve on Zigbee for instance, is given 30 seconds instead of 8 and is asked to open again at 10 and 20 seconds. Only one that stays closed after that is a failure, reported as valve_did_not_open. A zone can set its own wait and number of resends, for a cloud valve that confirms slowly or should not be asked twice: see the confirmation per zone.

A Sonoff SWV on ZHA is opened with one command, ZHA's on with timed off, which opens the valve and bounds it at the same time: the time is the pass length plus a 30-second margin, so the valve closes itself even if Home Assistant dies right after opening. Smart Irrigation still closes it at the normal time, and a repeated open (above) sends the same command. This happens only when the zone's safety off mode is auto (the default), the zone has no MQTT topic and the valve is a known SWV; in zha or off mode the normal open is used. The command is tried once, for 6 seconds. If it fails, a warning is logged once for the zone and the valve is opened the normal way. It works with direct valve control alone, the full controller is not needed. See closed-loop control for the details and the other valves.

Limitations

What it is not

It is not a pressure controller, a master-valve scheduler for a whole farm, or a replacement for a controller that already does its job. If a Rain Bird, Hydrawise, Rachio, OpenSprinkler or B-hyve runs your valves, its blueprint is the right way and the full controller has nothing to add to it.

Next: Coming from Irrigation Unlimited