I have built a custom component that builds on the work of others (specifically @hhaim) to precisely control my lawn/garden irrigation. It is available through HACS (Smart Irrigation) and here: https://github.com/jeroenterheerdt/HAsmartirrigation.
There is a lot to this, but the gist of it is: the component calculates evapotranspiration (evaporation) of moisture and compares it with any rain- and snowfall. Then, if the moisture evaporated is higher than the precipitation (rain+snow) the component calculates the number of seconds the irrigation needs to run to bring the balance back to zero (no moisture lost). If the net value is lower (more moisture added through precipitation than has evaporated) irrigation is not required and the net value is carried over to the next day (to account for the situation of heavy rain followed by hot, dry days - you donāt need to water right away then).
Note that the component does not control your irrigation. The reason for this is I wanted to keep maximum flexibility in hardware choice and integration with other solutions. The component does all the calculations, but the user is expected to build the automation using the adjusted run time the component provides. Also, after any irrigation is done the automation is expected to notify the component irrigation was completed so the net value can be reset to 0.
Here is a sample automation:
- alias: Smart Irrigation
description: 'Start Smart Irrigation at 06:00 and run it only if the adjusted_run_time is >0 and run it for precisely that many seconds'
trigger:
- at: 06:00
platform: time
condition:
- above: '0'
condition: numeric_state
entity_id: sensor.smart_irrigation_daily_adjusted_run_time
action:
- data: {}
entity_id: switch.irrigation_tap1
service: switch.turn_on
- delay:
seconds: '{{states("sensor.smart_irrigation_daily_adjusted_run_time")}}'
- data: {}
entity_id: switch.irrigation_tap1
service: switch.turn_off
- data: {}
service: smart_irrigation.reset_bucket
As you can see this is fairly straightforward. More details, including formulas and links to scientific papers are on the GitHub: https://github.com/jeroenterheerdt/HAsmartirrigation.