Objective
Let Home Assistant (HA) automatically adjusts the watering duration based on actual weather conditions.
The controller reduces the amount of watering when the weather cools down/rains, and adds time when it heats up.
The scheduling days and when to start irrigation is constant and set by the user.
My dashboard - two taps
How it works
Query actual weather conditions each hour from OpenWeatherMap and estimate/calculate the following:
- Evapotranspiration: evaporation (ETo) is how much water is lost from your soil due to either evaporation directly into the air or transpiration through the plants and into the air,
- Rain: How much water is added to the soil
ETo will increase the taps queue and rain will reduce it.
The idea was taken from a leaky bucket (networking policers)
Each tap will maintain a virtual queue and irrigation time will be calculated in such a way to zero the queue (ev
reduces the level, rain/irrigation fills it).
How to estimate evaporation (ETo)
I’ve tested a few methods and found that the best and most accurate one is based on Penman–Monteith_equation
More details are in this book
Luckily, there is a python library from Mark Richards pyETo that could calculate it and estimate what needed based on weather actual conditions.
The value of ETo by FAO-56 Penman-Monteith is a value between 1.0 (cold) to 12.0 (very hot).
To be more accurate I’ve calculated this number each hour and added it so it now it is between (~100- cold) to 300-400(hot) in ev units.
Estimating Rain
OpenWeatherMap based on your accurate location could provide this information. In some cases (if you are located close to a weather station) it is surprisingly accurate. Again, this is not a forecast it is actual rain in mm. The code accumulates the total mm and covert it to ev units using a simple factor. I’m using a factor of 100. Let’s take an example:
Total rain a day: 5 mm
Day Ev : 5x 100 (ev/mm) = 500 ev
which is 5 days of cold weather ETo without irrigation.
Irrigation duration
Irrigation duration is based on the queue level at the time of irrigation time.
Irrigation time = (-queue level) * max_tap_time (min)
After Irrigation the queue is zeroed
WBI works the same as your old system, it just reduces the time when it fits (e.g. rain, cold days etc)
Example:
.With wbi
[options=“header”,cols=“1,1,1,1,1,6”]
|=======================================
| Day | old value |evaporation (-) | rain Ev (+) | new value | desc
|0 | 0 | -200 | +500 | +300| rain of ~5mm total
|1 | +300| -200| 0 | +100|no rain , no irrigation
|2 | +100|-200| 0 | -100 | can irrigate
|3 | -100|-200| 0 | -300 | can irrigate
|4* | -300|-100| 0 | 0 | can irrigate – scheduled calculate the time
|=======================================
.Without wbi
[options=“header”,cols=“1,1,1,1,1,6”]
|=======================================
| Day | old value |evaporation (-) | rain Ev (+) | new value | desc
|0 | 0 | -300 | 0 | -300| rain of ~5mm total
|1 | -300| -300| 0 | -600|no rain , no irrigation
|2 | -600|-300| 0 | -900 | can irrigate
|3 | -900|-300| 0 | -1200 | can irrigate
|4* | -1200|-300| 0 | 0 | can irrigate – scheduled calculate the time
|=======================================
This is how it looks in grafana
Back to Reality - Home Assistant
Ingredients for 4 taps
- HA
- Appdaemon
- Hardware: Sonoff 4 ch pro to switch on/off the taps
- Sonoff firmware: Tasmota
Sonoff 4 ch
- Install latest Tasmota firmware
- Sprinkler Valve could be any s 48VAC or DC Sprinkler
- Connect valve power throw the Sonoff relay
Tasmota configuration
This is an example for 2 taps.
The rules make sure that the taps won’t stay opened in case of a network problem.
You should tune the time for your usec-case.
.Tasmota configuration (once)
Rule1 on Power1#state==1 do RuleTimer1 1800 endon on Rules#Timer=1 do power1 off endon on Power1#state==0 do RuleTimer1 off endon
Rule2 on Power2#state==1 do RuleTimer2 2700 endon on Rules#Timer=2 do power2 off endon on Power2#state==0 do RuleTimer2 off endon
Rule1 on
Rule2 on
poweronstate 0
TelePeriod 60
SetOption36 20
Install HA custom component
Copy this project <config directory>/custom_components/
folder to your <config directory>
directory
make sure you are in sync with the the right version of hass (see above)
after you copy the data you should reboot/restart HA
Enable wbi component
Add this to your configuration file
wb_irrigation:
api_key: !secret openweathermap_key
rain_factor: 90
max_ev: 3000
min_ev: -1500.0
name: "wb_irrigation"
debug: false
longitude: !secret accurate_longitude
latitude: !secret accurate_latitude
elevation: !secret accurate_elevation
taps:
- name: p1
- name: p2
look into this example full example with 2 taps
- A free token from openweathermap. Add your taps in this example there are two taps
- p1 and p2 is the names of the taps.
Appdaemon script
The app is responsible to to turn on the taps in specific schedule. +
The total time is calculated from the weather component (wb_irrigation see below). +
In case the tap state is changed to ON (manually) the time is taken from the input and weather queue is not updated.+
It is possible to estimate how much littler is consumed by each tap using the global water input sensor (if exists)
See here for switch and sensor definition for this app to work
This is an example for 2 taps
.Irrigation configuration
# irrigation app
wb_irrigation:
module: heat_app
class: CWBIrrigation
m_temp_celsius: 31 #fill from here https://www.holiday-weather.com/ average *day* temperatures in celsius hottest month
m_temp_hours: 13 # average day hours hottest month
enabled: input_boolean.wbi_enabled #disable irrigation
water_sensor: sensor.water_total_external_norm # read total water # optional to read water global sensor
notify: [tap_open]
taps:
- name: p1
days: [2,5] # 1-7 1 for sunday, .. 7 for saturday
stime: "05:45:00" # time to start irrigating
m_week_duration_min: input_number.wbi_week_p1_duration
switch: switch.wbi_p1
manual_duration: input_number.wbi_p1_duration
queue_sensor: sensor.wb_irrigation_p1
water_sensor: variable.wbi_water_p1
time_sensor: variable.wbi_last_duration_p1
- name: p2
days: [1,3,5]
stime: "05:00:00"
m_week_duration_min: input_number.wbi_week_p2_duration
switch: switch.wbi_p2
manual_duration: input_number.wbi_p2_duration
queue_sensor: sensor.wb_irrigation_p2
water_sensor: variable.wbi_water_p2
time_sensor: variable.wbi_last_duration_p2
more could be found here:wiki
Any questions/issues/suggestions could be submitted to github