Garden Irrigation

Hi There @klogg This is an cool project, thanks for sharing this with everyone. I’ve been struggling with some errors when I copied over the packages, which are as follows:

Package garden_irrigation setup failed. Component input_boolean has duplicate key 'name'
Package garden_irrigation setup failed. Component input_text has duplicate key 'name'
Package garden_irrigation setup failed. Component input_select has duplicate key 'name'
Package garden_irrigation setup failed. Component input_datetime has duplicate key 'has_date'
Package garden_irrigation setup failed. Component input_number has duplicate key 'name'
Package garden_irrigation setup failed. Component timer has duplicate key 'name'

I am running the latest version of Hassio 0.97.2. If someone is able to explain these errors, that would be amazing.

I only have one single zone for my irrigation system, so I’m assuming that I can remove the additional zones from the files and it should still be able to control single sonoff, which I have connected to a irrigation pump? I’ve also just been looking at your code and realise that you have a weather station, is that correct? So if I don’t have the weather station is it still possible to use the packages?

@mattpitts74 I suggest you go and look here My Garden Irrigation
I created a thread for my project and it has changed a bit since I posted those files.

Hey everyone,
I just stumbled across this thread because I’m planing to build an own irrigation system.
Does anyone has used the Sonoff 4CH Pro r2 for this use case? Im planing to use 3 of them cause i have hunter valves working with 24ac and a water pump which needs 220dc, don’t know if im right here, but it should be possible to use them both at the sonoff 4ch pro r2 because this one has potential free switches – anyone experience with that? or can i only use one kind of voltage/current for the sonoff 4ch pro r2?
further more i also have this rain sensor from hunter laying around and was planing to integrate that one, but in contrary to the sonoff basic i don’t know a way to connect this sensor directly to the sonoff 4ch pro - anyone done this before or do u all used a nodemcu/esp8266?

greeting to all irrigationists out there=))

Yes. This does work.

1 Like

Hi Flipso,
Yes Sonoff 4CH R2 will work for you (as iz3man stated above). I use Sonoff POW R2 for my waterpump and ESP32 for the valves.

  • What are the technical details of your hunter rain sensor?
  • Are you sure that your waterpump needs 220V DC? Could it be 220V AC?
1 Like

thanks for the fast replies first of all!!

Perhaps its really AC, messed this up a bit - but it has higher demands on Current then this little Hunter Valves und i was afraid to put high and low demanding devices on one line. the rain sensor is the Hunter Mini Click (https://www.amazon.de/Hunter-Mini-Clik-Regensensor/dp/B01BVVLTY2/ref=asc_df_B01BVVLTY2/?tag=googshopde-21&linkCode=df0&hvadid=344467603589&hvpos=1o4&hvnetw=g&hvrand=2228685127176045679&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9042006&hvtargid=pla-748418096543&psc=1&th=1&psc=1&tag=&ref=&adgrpid=77801524988&hvpone=&hvptwo=&hvadid=344467603589&hvpos=1o4&hvnetw=g&hvrand=2228685127176045679&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9042006&hvtargid=pla-748418096543) , but as stated above it only has this on/off spongmaterial in it - so im not really sure if i want to buy an extra device to connect this thing up :smiley:

Okay, the Hunter Mini Click is just a little switch. This switch gets activated (closed) by rain sooking the spongmaterial and will be de-activated (open) when it is dryed-up.
The voltage/current mentioned in the specification of this device is not of importance because you want to connect one wire to Ground (GND) and the other to a free GPIO input pin of the Sonoff device (supposing that one GPIO input port is available on the Sonoff 4CH device. (I don’t own such a devide).
You can define this sensor (input port) in ESPHome software or Tasmota software to be used by Home Assistant.

What is the maximum current of your waterpump? You must be sure the relay in the Sonoff 4CH can handle this current.
I have fried my Sonoff basic relay due to the fact that my waterpump draws 14 Amps. Sonoff basic goes up to 10 Amps. Now I have the Sonoff POW R2 with maximum capacity of 16 Amps.

1 Like

Thanks for this answer, i think the sonoff 4ch pro r2 also only goes to 10 Amp i’ll check this and probably must use a pow here too.
have done some googling and found, that such an gpio pin must also exist for the sonoff 4ch pro r2 - also if i have to buy a pow, i think there is definitively something there.

You can use a POW for the pump (16A) and the 4ch pro for the valves.

Hi @sparkydave

I tried your code to the T and whenever i set the runtime it doesn’t seem like the automation actually kick off the script to turn on the Retic Station 1 Valve. Instead of ESPHome code on NodeMCU i’m trying to get the automation to call the script script.retic_program1_run to turn on the switch that uses mqtt as referred to in some of your older posts. https://community.home-assistant.io/t/garden-irrigation/1950/167?u=irishinsanity

Have you had any issues with the automation not kicking off the scripts? I trying to figure out if i should remove the automation: !include automations.yaml from the configuration.yaml file and use all of your code as is including the automations in /config/packages/reticulation.yaml or if your automation bit of the code should be in the automations.yaml file.

I REAALY want to get this going. I’ve spent the good of 2 days trying to work this out.
Going to have another crack at this tomorrow again and can paste some of the code here.

Your will be appreciated.

Hello Philippe, I looked at the config of your github files and some configs seem to be missing. I can’t seem to find the sensor config for input_boolean.cycle2_enable, run_time, manual_run, morning and afternoon cycle status, timer.cycle1_zone_duration etc etc. Is it anyway possible we could have a chat perhaps? I tried using the config from your github page but certain information i can’t seem to find in your .yaml files.

I recently change the entire irrigation flow / automation. So if you want to to have a chat you can contact me on discord.

Hi @phdelodder , can you email me your discord details? My email address is [email protected]. Thank you very much for responding.

@klogg Your work is absolutely amazing. This helped me so much. I got everything working as explained. I was wondering. Is there by ANY chance a way you could give advice how to remove the “Daily” and “Alternate” for that for days of the week? I’ve been staring at this code for two days straight and for the love of me i can’t work out how to switch the pieces with some code from Dave. Any help will be appreciated.

  • platform: template # determine if today is selected as a watering day for program 1
    sensors:
    retic_program1_watering_day:
    value_template: >
    {% set sensor_names = [ ‘monday’, ‘tuesday’, ‘wednesday’,‘thursday’,‘friday’,‘saturday’,‘sunday’] %}
    {% set today_name = sensor_names[now().weekday()] %}
    {% set entity_id = ‘input_boolean.retic_program1_’+today_name %}
    {{ is_state(entity_id, ‘on’) }}

    retic_program2_watering_day:
      value_template:  >
        {% set sensor_names = [ 'monday', 'tuesday', 'wednesday','thursday','friday','saturday','sunday'] %}
        {% set today_name = sensor_names[now().weekday()] %}
        {% set entity_id = 'input_boolean.retic_program2_'+today_name %}
        {{ is_state(entity_id, 'on') }}
    

input_boolean:
retic_program1_monday: # watering day selections for program 1
name: Monday

retic_program1_tuesday:
name: Tuesday

retic_program1_wednesday:
name: Wednesday

retic_program1_thursday:
name: Thursday

retic_program1_friday:
name: Friday

retic_program1_saturday:
name: Saturday

retic_program1_sunday:
name: Sunday

Thanks for the compliment…

Firstly, because I had a few people interested in this I created a separate thread to split my project away from here. You might like to look there as there have been a few changes based on input and help from others.

Regarding your specific question, if I understand correctly it would not be possible as I have only allowed for two different cycles. One or both cycles will run on the days chosen which as it stands is every day or alternate days.

If you want different cycles on different days I suggest you try using the code by @sparkydave which others here seem have used to very good effect and looks pretty good to me (of course I looked at it to see if I could steal any ideas learn from it :wink: )

It works fine for me. I’m not using MQTT (as per early posts) because I’m using the ESPhome native API for HA. Using my most recent code posting above should work fine once you change any relevant entity_id’s for your own.

You can have:

automation: !include automations.yaml

as well as the package. Just make sure you are also referencing packages as per the docs.

Hi, @sparkydave thanks for providing the code to us, i would like to know if you have implemented the moisture sensor into your code. I do have a MiFlora setup already having this value to my HA setup and i suppose i should include this as a condition to your automation eg if not lower that 35% then to not run the irrigation. but also i would like to have the forecasted rain and delay the schedule, have you done any progress in that front ?

thank you

Hi John, I don’t currently use local moisture sensors for my irrigation system, only weather data. Currently my code uses a combination of actual rainfall on the current day, expected rainfall on current day and % chance of rainfall for current day to decide if watering should occur or not. I use a couple of sliders to set my cut-off limits for those parameters in the lovelace screen so I have an easy way to make changes.

latest code package:

########################################
#
#   This is a full reticulation
#   control package using ESPHOMEYAML
#   as the soleniod control via a NodeMCU
#
########################################

homeassistant:
  customize:
    switch.retic_station_1_valve:
      icon: mdi:water-pump
    switch.retic_station_2_valve:
      icon: mdi:water-pump
    input_boolean.retic_program1_enable:
      icon: mdi:traffic-light
    input_boolean.retic_program2_enable:
      icon: mdi:traffic-light



      
sensor:
  - platform: template    # determine if today is selected as a watering day for program 1
    sensors:
      retic_program1_watering_day:
        entity_id: input_boolean.retic_program1_monday, input_boolean.retic_program1_tuesday, input_boolean.retic_program1_wednesday, input_boolean.retic_program1_thursday, input_boolean.retic_program1_friday, input_boolean.retic_program1_saturday, input_boolean.retic_program1_sunday, sensor.time
        value_template:  >
          {% set sensor_names = [ 'monday', 'tuesday', 'wednesday','thursday','friday','saturday','sunday'] %}
          {% set today_name = sensor_names[now().weekday()] %}
          {% set entity_id = 'input_boolean.retic_program1_'+today_name %}
          {{ is_state(entity_id, 'on') }}

      retic_program2_watering_day:
        entity_id: input_boolean.retic_program2_monday, input_boolean.retic_program2_tuesday, input_boolean.retic_program2_wednesday, input_boolean.retic_program2_thursday, input_boolean.retic_program2_friday, input_boolean.retic_program2_saturday, input_boolean.retic_program2_sunday, sensor.time
        value_template:  >
          {% set sensor_names = [ 'monday', 'tuesday', 'wednesday','thursday','friday','saturday','sunday'] %}
          {% set today_name = sensor_names[now().weekday()] %}
          {% set entity_id = 'input_boolean.retic_program2_'+today_name %}
          {{ is_state(entity_id, 'on') }}







    
input_datetime:
  retic_program1_start_time_1:    # program start time control
    name: Program 1 Start Time 1
    has_date: false
    has_time: true

  retic_program1_start_time_2:
    name: Program 1 Start Time 2
    has_date: false
    has_time: true

  retic_program2_start_time_1:
    name: Program 2 Start Time 1
    has_date: false
    has_time: true

  retic_program2_start_time_2:
    name: Program 2 Start Time 2
    has_date: false
    has_time: true


input_number:
  retic_program1_station1_run_time:   # station run time control
    name: Station 1 Run Time
    min: 0
    max: 30
    step: 1
    icon: mdi:camera-timer

  retic_program1_station2_run_time:
    name: Station 2 Run Time
    min: 0
    max: 30
    step: 1
    icon: mdi:camera-timer

  retic_program2_station1_run_time:
    name: Station 1 Run Time
    min: 0
    max: 30
    step: 1
    icon: mdi:camera-timer

  retic_program2_station2_run_time:
    name: Station 2 Run Time
    min: 0
    max: 30
    step: 1
    icon: mdi:camera-timer  

  actual_rainfall_last_24h:
    name: 'Actual Rainfall Last 24h'  # way of keeping todays rainfall figure saved for calculations tomorrow
    min: 0
    max: 100
#    step: 0.1
    icon: mdi:cup-water
#    unit_of_measurement: mm

  allowable_rain_quantity:
    name: 'Allowed Rain (mm)'  # amount of rain we will allow to fall today and still water the garden
    min: 0
    max: 5
    step: 0.1
    icon: mdi:cup-water
#    unit_of_measurement: mm

  allowable_rain_percentage:  # percentage chance of rain today we will allow today and still water the garden
    name: 'Allowed Rain (%)'
    min: 0
    max: 100
    step: 1
    icon: mdi:water-percent
#    unit_of_measurement: %



input_boolean:
  retic_program1_monday:   # watering day selections for program 1
    name: Monday

  retic_program1_tuesday:
    name: Tuesday

  retic_program1_wednesday:
    name: Wednesday

  retic_program1_thursday:
    name: Thursday
    
  retic_program1_friday:
    name: Friday

  retic_program1_saturday:
    name: Saturday
    
  retic_program1_sunday:
    name: Sunday

  retic_program2_monday:   # watering day selections for program 2
    name: Monday

  retic_program2_tuesday:
    name: Tuesday

  retic_program2_wednesday:
    name: Wednesday

  retic_program2_thursday:
    name: Thursday
    
  retic_program2_friday:
    name: Friday

  retic_program2_saturday:
    name: Saturday
    
  retic_program2_sunday:
    name: Sunday


  retic_program1_enable:   # enable program to run
    name: Enable
  
  retic_program1_start_time1_enable:
    name: Enable
  
  retic_program1_start_time2_enable:
    name: Enable
  
  retic_program2_enable:
    name: Enable

  retic_program2_start_time1_enable:
    name: Enable
  
  retic_program2_start_time2_enable:
    name: Enable

  retic_station_1_run:
    name: Station 1 Run
  
  retic_station_2_run:
    name: Station 2 Run


  retic_rain_parameters_met:   # set to ON if rain today values are below levels set in input_numbers
    name: Rain Parameters Met
    icon: mdi:water
  retic_rain_override:         # set to ON to run retic even if rain parameters are not met
    name: Rain Override
    icon: mdi:water

group:                  # frontend interface setup
  retic_manual:
    control: hidden
    name: 'Manual Control'
    entities:
      - switch.retic_station_1_valve
      - switch.retic_station_2_valve
  
  retic_program1:
    control: hidden
    name: 'Program 1'
    entities:
      - input_boolean.retic_program1_enable
      - script.retic_program1_run
      - input_datetime.retic_program1_start_time_1
      - group.retic_program1_watering_days
      - group.retic_program1_run_times
    
  retic_program2:
    control: hidden
    name: 'Program 2'
    entities:
      - input_boolean.retic_program2_enable
      - script.retic_program2_run
      - input_datetime.retic_program2_start_time_1
      - group.retic_program2_watering_days
      - group.retic_program2_run_times

  retic_program1_watering_days:
    control: hidden
    name: 'Watering days'
    icon: mdi:calendar-multiple-check
    entities:
      - input_boolean.retic_program1_monday
      - input_boolean.retic_program1_tuesday
      - input_boolean.retic_program1_wednesday
      - input_boolean.retic_program1_thursday
      - input_boolean.retic_program1_friday
      - input_boolean.retic_program1_saturday
      - input_boolean.retic_program1_sunday

  retic_program2_watering_days:
    control: hidden
    name: 'Watering days'
    icon: mdi:calendar-multiple-check
    entities:
      - input_boolean.retic_program2_monday
      - input_boolean.retic_program2_tuesday
      - input_boolean.retic_program2_wednesday
      - input_boolean.retic_program2_thursday
      - input_boolean.retic_program2_friday
      - input_boolean.retic_program2_saturday
      - input_boolean.retic_program2_sunday

  retic_program1_run_times:
    control: hidden
    name: 'Run times'
    icon: mdi:camera-timer
    entities:
      - input_number.retic_program1_station1_run_time
      - input_number.retic_program1_station2_run_time

  retic_program2_run_times:
    control: hidden
    name: 'Run times'
    icon: mdi:camera-timer
    entities:
      - input_number.retic_program2_station1_run_time
      - input_number.retic_program2_station2_run_time


automation:
  - alias: Save last 24h rainfall figure    # save the rainfall figure to an input_number to use later
    initial_state: 'on'
    trigger:
      - platform: time
        at: "08:50:00"
    action:
      - service: input_number.set_value
        data_template:
          entity_id: input_number.actual_rainfall_last_24h
          value: "{{ states('sensor.bom_perth_rain_today') }}"


  - alias: Check rain parameters     # check that todays rain doesnt need to disable the retic from running   ### LOOK AT CHANGING THIS TO A BINARY_SENSOR TEMPLATE
    initial_state: 'on'
    trigger:
      - platform: template
        value_template: "{{ states('sensor.time') == ((states.input_datetime.retic_program1_start_time_1.attributes.timestamp - 600) | int | timestamp_custom('%H:%M', False)) }}"
      - platform: template
        value_template: "{{ states('sensor.time') == ((states.input_datetime.retic_program1_start_time_2.attributes.timestamp - 600) | int | timestamp_custom('%H:%M', False)) }}"
      - platform: template
        value_template: "{{ states('sensor.time') == ((states.input_datetime.retic_program2_start_time_1.attributes.timestamp - 600) | int | timestamp_custom('%H:%M', False)) }}"
      - platform: template
        value_template: "{{ states('sensor.time') == ((states.input_datetime.retic_program2_start_time_2.attributes.timestamp - 600) | int | timestamp_custom('%H:%M', False)) }}"
      - platform: state
        entity_id: input_number.allowable_rain_quantity
      - platform: state
        entity_id: input_number.allowable_rain_percentage
      - platform: time_pattern
        minutes: '/30'

    action:

      - service_template: >
          input_boolean.turn_{{'on' if states('sensor.bom_perth_rain_today') <= states('input_number.allowable_rain_quantity') and 
                                       states('sensor.bom_perth_forecast_chance_of_rain_0') <= states('input_number.allowable_rain_percentage')  else 'off'}}
        entity_id: input_boolean.retic_rain_parameters_met



  - alias: Reticulation Run Program 1     # start program 1 at designated time if it is enabled and today is selected as a watering day
    initial_state: 'on'
    trigger:
      - platform: template
        value_template: "{{ states('sensor.time') == (states.input_datetime.retic_program1_start_time_1.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
      - platform: template
        value_template: "{{ states('sensor.time') == (states.input_datetime.retic_program1_start_time_2.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
    condition:
      - condition: state
        entity_id: input_boolean.retic_program1_enable
        state: 'on'
      - condition: state
        entity_id: sensor.retic_program1_watering_day
        state: 'True'
      - condition: or
        conditions:
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ states('sensor.time') == (states.input_datetime.retic_program1_start_time_1.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
              - condition: state
                entity_id: input_boolean.retic_program1_start_time1_enable
                state: 'on'
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ states('sensor.time') == (states.input_datetime.retic_program1_start_time_2.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
              - condition: state
                entity_id: input_boolean.retic_program1_start_time2_enable
                state: 'on'
      - condition: or
        conditions:
          - condition: state
            entity_id: input_boolean.retic_rain_parameters_met
            state: 'on'
          - condition: state
            entity_id: input_boolean.retic_rain_override
            state: 'on'
    action:
      - service: script.turn_on
        entity_id: script.retic_program1_run

  - alias: Reticulation Run Program 2     # start program 2 at designated time if it is enabled and today is selected as a watering day
    initial_state: 'on'
    trigger:
      - platform: template
        value_template: "{{ states('sensor.time') == (states.input_datetime.retic_program2_start_time_1.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
      - platform: template
        value_template: "{{ states('sensor.time') == (states.input_datetime.retic_program2_start_time_2.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
    condition:
      - condition: state
        entity_id: input_boolean.retic_program2_enable
        state: 'on'
      - condition: state
        entity_id: sensor.retic_program2_watering_day
        state: 'True'
      - condition: or
        conditions:
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ states('sensor.time') == (states.input_datetime.retic_program2_start_time_1.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
              - condition: state
                entity_id: input_boolean.retic_program2_start_time1_enable
                state: 'on'
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ states('sensor.time') == (states.input_datetime.retic_program2_start_time_2.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
              - condition: state
                entity_id: input_boolean.retic_program2_start_time2_enable
                state: 'on'
      - condition: or
        conditions:
          - condition: state
            entity_id: input_boolean.retic_rain_parameters_met
            state: 'on'
          - condition: state
            entity_id: input_boolean.retic_rain_override
            state: 'on'




    action:
      - service: script.turn_on
        entity_id: script.retic_program2_run

  - alias: Reticulation Station 1 Run
    initial_state: 'on'
    trigger:
      platform: state
      entity_id: input_boolean.retic_station_1_run
    action:
      - service_template: >
          {% if is_state('input_boolean.retic_station_1_run', 'on') %}
            script.retic_station_1_run
          {% else %}
            script.retic_station_1_stop
          {% endif %}
      
  - alias: Reticulation Station 2 Run
    initial_state: 'on'
    trigger:
      platform: state
      entity_id: input_boolean.retic_station_2_run
    action:
      - service_template: >
          {% if is_state('input_boolean.retic_station_2_run', 'on') %}
            script.retic_station_2_run
          {% else %}
            script.retic_station_2_stop
          {% endif %}

  - alias: Reticulation Controller Offline Alert
    initial_state: 'on'
    trigger:
      platform: state
      entity_id: binary_sensor.retic_controller_status
      to: 'off'
      for:
        minutes: 5
    action:
      - service: notify.pushbullet
        data:
          message: 'Retic Controller Offline!'


script:
  retic_program1_run:             #run retic program 1 through each station for selected time
    alias: Program 1 Run
    sequence:
      - service: switch.turn_on
        data:
          entity_id: switch.retic_station_1_valve
      - delay: "00:00:01"
      - service: switch.turn_on
        data:
          entity_id: switch.retic_bore_control
      - delay: "00:{{ states('input_number.retic_program1_station1_run_time')|int }}:00"
      - service: switch.turn_off
        data:
          entity_id: switch.retic_station_1_valve
      - service: switch.turn_on
        data:
          entity_id: switch.retic_station_2_valve
      - delay: "00:{{ states('input_number.retic_program1_station2_run_time')|int }}:00"
      - service: switch.turn_off
        data:
          entity_id: switch.retic_bore_control
      - delay: "00:00:01"
      - service: switch.turn_off
        data:
          entity_id: switch.retic_station_2_valve
      
  retic_program2_run:             #run retic program 2 through each station for selected time
    alias: Program 2 Run
    sequence:
      - service: switch.turn_on
        data:
          entity_id: switch.retic_station_1_valve
      - delay: "00:00:01"
      - service: switch.turn_on
        data:
          entity_id: switch.retic_bore_control
      - delay: "00:{{ states('input_number.retic_program2_station1_run_time')|int }}:00"
      - service: switch.turn_off
        data:
          entity_id: switch.retic_station_1_valve
      - service: switch.turn_on
        data:
          entity_id: switch.retic_station_2_valve
      - delay: "00:{{ states('input_number.retic_program2_station2_run_time')|int }}:00"
      - service: switch.turn_off
        data:
          entity_id: switch.retic_bore_control
      - delay: "00:00:01"
      - service: switch.turn_off
        data:
          entity_id: switch.retic_station_2_valve

  retic_station_1_run:
    alias: Station 1 Run
    sequence:
      - service: switch.turn_on
        data:
          entity_id: switch.retic_station_1_valve
      - delay: "00:00:01"
      - condition: state
        entity_id: switch.retic_station_1_valve
        state: 'on'
      - service: switch.turn_on
        data:
          entity_id: switch.retic_bore_control
  
  retic_station_1_stop:
    alias: Station 1 Stop
    sequence:
      - service: switch.turn_off
        data:
          entity_id: switch.retic_bore_control
      - delay: "00:00:01"
      - condition: state
        entity_id: switch.retic_bore_control
        state: 'off'
      - service: switch.turn_off
        data:
          entity_id: switch.retic_station_1_valve

  retic_station_2_run:
    alias: Station 2 Run
    sequence:
      - service: switch.turn_on
        data:
          entity_id: switch.retic_station_2_valve
      - delay: "00:00:01"
      - condition: state
        entity_id: switch.retic_station_2_valve
        state: 'on'
      - service: switch.turn_on
        data:
          entity_id: switch.retic_bore_control
  
  retic_station_2_stop:
    alias: Station 2 Stop
    sequence:
      - service: switch.turn_off
        data:
          entity_id: switch.retic_bore_control
      - delay: "00:00:01"
      - condition: state
        entity_id: switch.retic_bore_control
        state: 'off'
      - service: switch.turn_off
        data:
          entity_id: switch.retic_station_2_valve

thank you for uploading your updated code, i have already changed the old one and incorporated my MiFlora moisture sensors , and i have everything setup , for me the actual rainfall input (actual_rainfall_last_24h) won’t be used since i check the moisture before running the automation . thank you for all your help and ideas.

Hi @sparkydave, thanks for sharing your code. I have about 11 watering zones in total for font and back yards, and so I expanded your code for the extra zones which wasn’t hard. For one of the watering programs however, I have a bunch of zones which don’t get used. Because of the structure of the code, these unused zones get pulsed for one second each as the script iterates through each zone until it gets to a zone which is used for x number of minutes. Maybe it’s not a big deal and just a ‘nice to have’, but feels less than ideal to have unused zones pulsed on for that second, especially when there’s quite a few (at least it sounds quite odd when you’re outside). I’ve been trying to add a condition where unused zones get skipped altogether but haven’t managed to get that working. I guess maybe if I removed the 1 second delay between zones it might go away. Any suggestions?