Advice for ESP Sprinkler

Hi, I need some advice.
I’m building an ESP sprinkler with:
• 1 water pump
• 6 valves
• 1 tank level sensor

I’m using the “sprinkler” component of ESPhome.

For me it would be very important that for each sprinkler, I could choose, in addition to the duration, the interval of days. This is because I water some plants every 3 days, others every 2 days and others daily.
Each plant has different needs (I use it to water potted plants).

Example sprinkler options (valves):

SPRINKLER_1
Enable: true
Duration: 60s (from 60 to 600)
Day interval: 1 (1 to 7)

SPRINKLER_2
Enable: true
Duration: 200s (from 60 to 600)
Day interval: 3 (1 to 7)

SPRINKLER_3
Enable: true
Duration: 150s (60 to 600)
Day interval: 5 (1 to 7)

IRRIGATION AUTOMATION:

For automation, I would like to have this control of the water level in the tank, especially the notification in case of problem (notification on companion app)

TANK LEVEL CHECK

  • if sensor_tank_level: false > run automation
  • if sensor_tank_level: true > do not run automation > notify companion app

Would anyone be kind enough to help me?
Thank you

This is my code:


sprinkler:
  - id: controller_micro_irrigazione
    main_switch: "Irrigatori"
    auto_advance_switch: "Irrigatori Auto Advance"
    reverse_switch: "Irrigatori Reverse"
    valve_open_delay: 0s
    valves:
      - valve_switch: "Irrigatore 1"
        enable_switch: "Enable Irrigatore 1"
        pump_switch_id: irrigation_pump
        run_duration: 1s
        valve_switch_id: irrigation_channel1
        
      - valve_switch: "Irrigatore 2"
        enable_switch: "Enable Irrigatore 2"
        pump_switch_id: irrigation_pump
        run_duration: 1s
        valve_switch_id: irrigation_channel2
        
      - valve_switch: "Irrigatore 3"
        enable_switch: "Enable Irrigatore 3"
        pump_switch_id: irrigation_pump
        run_duration: 1s
        valve_switch_id: irrigation_channel3
        
      - valve_switch: "Irrigatore 4"
        enable_switch: "Enable Irrigatore 4"
        pump_switch_id: irrigation_pump
        run_duration: 1s
        valve_switch_id: irrigation_channel4
        
      - valve_switch: "Irrigatore 5"
        enable_switch: "Enable Irrigatore 5"
        pump_switch_id: irrigation_pump
        run_duration: 1s
        valve_switch_id: irrigation_channel5
        
      - valve_switch: "Irrigatore 6"
        enable_switch: "Enable Irrigatore 6"
        pump_switch_id: irrigation_pump
        run_duration: 1s
        valve_switch_id: irrigation_channel6


binary_sensor:
  - platform: template
    name: Livello Serbatoio Acqua
    id: adc_to_digital

##LEVEL SENSOR
sensor:
  - platform: adc
    internal: false
    pin: A0
    id: adc_to_digital_value
    update_interval: 120s
    on_value:
      then:
        - if:
            condition:
              - binary_sensor.is_on: adc_to_digital
            then:
              - if:
                  condition:
                    - lambda: "return x<0.3;"
                  then:
                    - binary_sensor.template.publish:
                        id: adc_to_digital
                        state: false
            else:
              - if:
                  condition:
                    - lambda: "return x>0.6;"
                  then:
                    - binary_sensor.template.publish:
                        id: adc_to_digital
                        state: true
                        
switch:       
  - platform: gpio
    name: "Pompa Acqua"
    icon: mdi:water-pump
    id: irrigation_pump
    pin: GPIO5
    inverted: false
    restore_mode: ALWAYS_OFF

  - platform: gpio
    name: "Valvola 1"
    icon: mdi:pipe-valve
    id: irrigation_channel1
    pin: GPIO16
    inverted: false
    restore_mode: ALWAYS_OFF

  - platform: gpio
    name: "Valvola 2"
    icon: mdi:pipe-valve
    id: irrigation_channel2
    pin: GPIO14
    inverted: false
    restore_mode: ALWAYS_OFF

  - platform: gpio
    name: "Valvola 3"
    icon: mdi:pipe-valve
    id: irrigation_channel3
    pin: GPIO12
    inverted: false
    restore_mode: ALWAYS_OFF

  - platform: gpio
    name: "Valvola 4"
    icon: mdi:pipe-valve
    id: irrigation_channel4
    pin: GPIO13
    inverted: false
    restore_mode: ALWAYS_OFF

  - platform: gpio
    name: "Valvola 5"
    icon: mdi:pipe-valve
    id: irrigation_channel5
    pin: GPIO15
    inverted: false
    restore_mode: ALWAYS_OFF

  - platform: gpio
    name: "Valvola 6"
    icon: mdi:pipe-valve
    id: irrigation_channel6
    pin: GPIO0
    inverted: false
    restore_mode: ALWAYS_OFF
    
number:
  - platform: template
    id: irrigatore_1_timer
    name: "Irrigatore 1 Timer"
    icon: mdi:timer-outline
    min_value: 5
    max_value: 120
    step: 1
    mode: box
    unit_of_measurement: s
    lambda: "return id(controller_micro_irrigazione).valve_run_duration(0);"
    set_action:
      - sprinkler.set_valve_run_duration:
          id: controller_micro_irrigazione
          valve_number: 0
          run_duration: !lambda 'return x;'   

  - platform: template
    id: irrigatore_2_timer
    name: "Irrigatore 2 Timer"
    icon: mdi:timer-outline
    min_value: 5
    max_value: 120
    step: 1
    mode: box
    unit_of_measurement: s
    lambda: "return id(controller_micro_irrigazione).valve_run_duration(1);"
    set_action:
      - sprinkler.set_valve_run_duration:
          id: controller_micro_irrigazione
          valve_number: 1
          run_duration: !lambda 'return x;'   

  - platform: template
    id: irrigatore_3_timer
    name: "Irrigatore 3 Timer"
    icon: mdi:timer-outline
    min_value: 5
    max_value: 120
    step: 1
    mode: box
    unit_of_measurement: s
    lambda: "return id(controller_micro_irrigazione).valve_run_duration(2);"
    set_action:
      - sprinkler.set_valve_run_duration:
          id: controller_micro_irrigazione
          valve_number: 2
          run_duration: !lambda 'return x;'   

  - platform: template
    id: irrigatore_4_timer
    name: "Irrigatore 4 Timer"
    icon: mdi:timer-outline
    min_value: 5
    max_value: 120
    step: 1
    mode: box
    unit_of_measurement: s
    lambda: "return id(controller_micro_irrigazione).valve_run_duration(3);"
    set_action:
      - sprinkler.set_valve_run_duration:
          id: controller_micro_irrigazione
          valve_number: 3
          run_duration: !lambda 'return x;'   

  - platform: template
    id: irrigatore_5_timer
    name: "Irrigatore 5 Timer"
    icon: mdi:timer-outline
    min_value: 5
    max_value: 120
    step: 1
    mode: box
    unit_of_measurement: s
    lambda: "return id(controller_micro_irrigazione).valve_run_duration(4);"
    set_action:
      - sprinkler.set_valve_run_duration:
          id: controller_micro_irrigazione
          valve_number: 4
          run_duration: !lambda 'return x;'   

  - platform: template
    id: irrigatore_6_timer
    name: "Irrigatore 6 Timer"
    icon: mdi:timer-outline
    min_value: 5
    max_value: 120
    step: 1
    mode: box
    unit_of_measurement: s
    lambda: "return id(controller_micro_irrigazione).valve_run_duration(5);"
    set_action:
      - sprinkler.set_valve_run_duration:
          id: controller_micro_irrigazione
          valve_number: 5
          run_duration: !lambda 'return x;'   

Can anyone really help me?

I did not know there was a sprinkler component. Mine is handled with a combination of automations, Node Red and helper entities. Quite a mess. I may replace all of this with the sprinkler component.

In my case we are restricted to even/odd days depending on the house number. In my automation that starts the sequence, I test for even/odd days:

alias: Sprinkler Start
description: Start the sprinklers at 'irrigation_zone1_start_time'
trigger:
  - platform: time
    at: input_datetime.irrigation_zone1_start_time
condition:
  - condition: template
    value_template: "{{ now().day % 2 ==0 }}"
action:
  - service: script.sprinklers
    data: {}
mode: single

I don’t know how precise you need the every third day to be, but for example value_template: "{{ now().day % 3 ==0 }}" would be true for every day divisible by 3. However, when a month is 31 (or 28) days, it will be four days until the 3rd.

This is a very in depth component that requires a working knowledge of lambdas to achieve what you ask for automation wise. It’s not really something that someone can easily setup for you. At first you may want to consider leveraging some of HA’s helpers to get it working.

You’ll need to setup the controller actions to control the valves timing.

`Sprinkler Controller — ESPHome

As for the schedule you can use HA’s schedule component.