Smart Irrigation with respect to rainfall of last 24h

My smart irrigation approach is now working.
Devices:

  • MQTT Weatherstation
  • MQTT Waterpump
  • MQTT Flowrate Sensor

I use the Sparkfun Weatherkit as weatherstation and measure the rainfall over 24h.
At 22:00 hrs I start my irrigation automation. It checks how much rain has fallen and calculates the difference between a set value and the rainfall of the last 24h. I convert it to a duration. The coefficient for this conversion is determined by averaging the flow rate of the waterpump over a single irrigation cycle.
I then store this duration and scripts use this input_number as input for a delay statement. Thus, each sprinkler is active for a specific fraction of the residual cycle duration.

Automations:

- alias: Count_Rain_Ticks    
  id: irrigation1
  trigger:
  - platform: mqtt
    topic: garden/weatherstation/rain
  action:
  - service: counter.increment
    entity_id: counter.rain_tick_cnt
  - delay:
      seconds: 1
  - service: input_number.set_value
    target: 
      entity_id: input_number.current_rainfall
    data:
      value: 
        "{{ states('counter.rain_tick_cnt') | float * 0.2794 | float }}"
      

- alias: Reset_Rain_Counter
  id: irrigation2
  trigger:
  - platform: state
    entity_id: counter.executed_irrigation
    to: '2'
  action:
  - service: counter.reset
    entity_id: counter.rain_tick_cnt
  - service: counter.reset
    entity_id: counter.executed_irrigation
  - service: input_number.set_value
    target: 
      entity_id: input_number.current_rainfall
    data:
      value: 0.0
    
  
- alias: Bewässerung Hinten
  id: irrigation3
  trigger:
  - platform: time
    at: '22:00:00'
  condition:
    condition: and
    conditions:
    - condition: time
      weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
    - condition: numeric_state
      entity_id: input_number.current_rainfall
      below: 1.0
  action:
  - service: input_number.set_value
    target: 
      entity_id: input_number.total_irrigation_duration_back
    data:
      value: >
        {% set total_rainfall = states('input_number.current_rainfall') | float %}
        {% set total_irrigation_volume = ( 1.0 - total_rainfall ) | float * 237.0 %}
        {% set irrigation_cycle_time = total_irrigation_volume | float / 0.1562 %}
        {% if total_irrigation_volume > 50.0 %}
          {{ irrigation_cycle_time }}
        {% else %}
          0.0
        {% endif %}
  - delay: 
      seconds: 1
  - service: script.irrigation_back

Script (reduced):


irrigation_back:
  alias: "Hinten Bewässerung"
  sequence:
      # Pump on
    - service: switch.turn_on
      entity_id: switch.waterpump_garden_back
      # Sprinkler 1 on
    - service: switch.turn_on
      entity_id: switch.waterhub_back_valve_3
    - delay:
        seconds: "{{ states('input_number.total_irrigation_duration_back') | float * 0.0625  }}"
    - service: switch.turn_off
      entity_id: switch.waterhub_back_valve_3
      # Sprinkler 2 on
    - service: switch.turn_on
      entity_id: switch.waterhub_back_valve_4
    - delay:
        seconds: "{{ states('input_number.total_irrigation_duration_back') | float * 0.0625  }}"
    - service: switch.turn_off
      entity_id: switch.waterhub_back_valve_4
      # Pump off
    - service: switch.turn_off
      entity_id: switch.waterpump_garden_back
    - service: counter.increment
      entity_id: counter.executed_irrigation

It is still not complete. I want to take the season and temperature for the number of irrigation cycles into account.

If some is interested in more details, I am happy to share.

Best
Ck

Well, now I feel stupid. I usually access the forum on my Android. I have never seen this post Smart Irrigation - save water by precisely watering your lawn/garden until now on my laptop. Well I guess my post can be closed then :sweat_smile:

Hey, your solution is way simpler so very valuable for those that don’t want to deal with the details about evaporation… :joy:

Another solution that may be of interest to you. It also has an example of how to integrate HAsmartirrigation.