Ready reckoner calculation for a variable irrigation duration

Howdo.

I have a very simple single zone irrigation system, driven by an ESPHome triggered solenoid. The main hose snakes to each pot at the front of my house, and feeds a drip valve that drops about 4L/hr.

The ESPHome takes a variable duration that opens the solenoid for 0 to 200 minutes, which I’ve modelled as a slider in lovelace. I’ve tended to look at the openweathermap forecast temperature and rainfall each morning, and set the slider manually before kicking off the watering cycle. I’ve been tweaking an automation to see if I can get it to be largely standalone, in terms of approximating the values I’d choose (generally, zero to about 120 mins).

Thought I’d share where I’ve got to, as the below seems pretty good at delivering what I’d want for the bulk of temperatures and weathers we get in the UK. I didn’t want to get into complex evapotranspiration calculations that would only ever introduce a false level of precision. Might be useful to a few of you.

My Automation

alias: 08:00 - Calc Irrigation Duration and Start Watering
trigger:
  - at: '08:00:00' #8am means I'll spot if the hose splits!
    platform: time
condition: # don't bother if its 5 degrees or less outside 
  - condition: numeric_state
    entity_id: sensor.openweathermap_forecast_temperature_low
    above: '5.0'
action: # ok, we won't freeze, let's water
  - service: input_number.set_value
    data_template:
      entity_id: input_number.irrigation_duration
      value: |-
        {{ [ 0, 
           [((80 - (80 *
             ((states('sensor.openweathermap_forecast_precipitation')|float / 3.3))))
             * 
             (states('sensor.openweathermap_forecast_temperature')|float / 18 )
            )|int,
            120] | min] | max 
        }}
  - service: script.call_variable_squirt #my ESPHome will water for 'irrigation_duration' in mins.
mode: single

The main techniques here are:

  1. bracing everything with a min of 0 and a max of 120 mins.
  2. setting a baseline watering time of 80 mins, then using the forecast_precipitation to proportionally reduce this according to the amount of rainfall we are expected to get that day. (no rain means 80 mins, 3.3mm or above means no irrigation, 1.6mm of rain means 41 mins of irriguation).
  3. modelling this around an expected temperature of 18 degrees C, and using variation from that to increase or reduce the watering time (at 28C, no rain becomes 124 mins, 3.3mm is still zero, 1.6 is 64 mins).

Varying it for your purposes:

  • If you want it to top out at a higher value, replace the 120 with the figure you prefer.
  • If the numbers are always too low/high for you, replace both 80s with a greater/lesser number.
  • If you base your watering upon a higher/lower ambient temperature, replace the 18 with a greater/lesser number.

Testing

You can paste the data_template value into the developer tools → template section of home assistant to see what figures you’ll get back, or can replicate the formula in Excel or equivalent to get a table of values.

Here’s mine:

Forecast Precipitation (mm) Baseline Duration (18°C) Duration at 28°C
0.0 80.0 124.4
0.1 77.6 120.7
0.2 75.2 116.9
0.3 72.7 113.1
0.4 70.3 109.4
0.5 67.9 105.6
0.6 65.5 101.8
0.7 63.0 98.0
0.8 60.6 94.3
0.9 58.2 90.5
1.0 55.8 86.7
1.1 53.3 83.0
1.2 50.9 79.2
1.3 48.5 75.4
1.4 46.1 71.6
1.5 43.6 67.9
1.6 41.2 64.1
1.7 38.8 60.3
1.8 36.4 56.6
1.9 33.9 52.8
2.0 31.5 49.0
2.1 29.1 45.3
2.2 26.7 41.5
2.3 24.2 37.7
2.4 21.8 33.9
2.5 19.4 30.2
2.6 17.0 26.4
2.7 14.5 22.6
2.8 12.1 18.9
2.9 9.7 15.1
3.0 7.3 11.3
3.1 4.8 7.5
3.2 2.4 3.8
3.3 0.0 0.0
3.4 0.0 0.0
3.5 0.0 0.0
3.6 0.0 0.0
3.7 0.0 0.0

Thought I’d share, as its been quite a labour of trial and error to get me close, and it might save someone else a chunk of work :laughing:

3 Likes