Help With Slider for Irrigation

automation:

- alias: Sprinker Time Zone 01
  trigger:
    platform: state
    entity_id: switch.01_pro_switch_1
    to: 'on'
  action:
    service: homeassistant.turn_on
    entity_id: script.timed_sprinkler_01
      
- alias: Sprinker Time Zone 02
  trigger:
    platform: state
    entity_id: switch.01_pro_switch_2
    to: 'on'
  action:
    service: homeassistant.turn_on
    entity_id: script.timed_sprinkler_02
      
- alias: Sprinker Time Zone 03
  trigger:
    platform: state
    entity_id: switch.01_pro_switch_3
    to: 'on'
  action:
    service: homeassistant.turn_on
    entity_id: script.timed_sprinkler_03


 script:
    timed_sprinkler_01:
    alias: "Set Sprinkler Timer Zone 01"
    sequence:
      # Cancel ev. old timers
      - service: script.turn_off
        data:
           entity_id: script.timer_off
      # Set new timer
      - service: script.turn_on
        data:
          entity_id: script.timer_off
    timer_off_01:
    alias: "Turn Off Sprinkler Zone 01"
    sequence:
      - delay: '00:00:{{ states.input_slider.slider1.state | int }}'
      - service: homeassistant.turn_off
        entity_id: switch.01_pro_switch_1
    
timed_sprinkler_02:
alias: "Set Sprinkler Timer Zone 02"
sequence:
  # Cancel ev. old timers
  - service: script.turn_off
    data:
       entity_id: script.timer_off
  # Set new timer
  - service: script.turn_on
    data:
      entity_id: script.timer_off
timer_off_02:
alias: "Turn Off Sprinkler Zone 02"
sequence:
  - delay: '00:00:{{ states.input_slider.slider2.state | int }}'
  - service: homeassistant.turn_off
    entity_id: switch.01_pro_switch_2
    
timed_sprinkler_03:
alias: "Set Sprinkler Timer Zone 03"
sequence:
  # Cancel ev. old timers
  - service: script.turn_off
    data:
       entity_id: script.timer_off
  # Set new timer
  - service: script.turn_on
    data:
      entity_id: script.timer_off
timer_off_03:
alias: "Turn Off Sprinkler Zone 03"
sequence:
  - delay: '00:00:{{ states.input_slider.slider3.state | int }}'
  - service: homeassistant.turn_off
    entity_id: switch.01_pro_switch_3


   input_number:
      slider1:
        name: Sprinkler Time Zone 01
        initial: 10
        min: 1
        max: 30
        step: 1
    

  slider2:
    name: Sprinkler Time Zone 02
    initial: 10
    min: 1
    max: 30
    step: 1
    

  slider3:
    name: Sprinkler Time Zone 03
    initial: 10
    min: 1
    max: 30
    step: 1

This is what I have along with the switch, I was wondering why I can’t seem to get any of this to work. I think I copied this from an old thread possibly. If I hit the slider it doesn’t turn the switch on. Execute the Timer nothing. Is there somehting Im not linking properly?

Oh and I used the </> and the formating is off, but all is indented corrrectly. I just can’t seem to get the few first ones right. Haha sorry

The delay portion looks off. I pulled the following from the script docs. The first example seems to be the simplest.

# Waits however many seconds input_number.second_delay is set to
- delay:
    # Supports milliseconds, seconds, minutes, hours, days
    seconds: "{{ states('input_number.second_delay') }}"
# Waits however many minutes input_number.minute_delay is set to
# Valid formats include HH:MM and HH:MM:SS
- delay: "{{ states('input_number.minute_delay') | multiply(60) | timestamp_custom('%H:%M:%S',False) }}"

I think the delay looks ok, but your only running for 30 seconds max?

You are firing off a script named “script.timer_off”, but this doesnt exist? There is timer_off_01…03…

Rather then using scripts with big delays in them, have you thought about using proper timers instead?

Where would I find proper timer examples?

Start/restart timer for some reason:

lights_night_sensor_on:
  sequence:
    - service: timer.cancel
      entity_id: timer.night_light_timer
    - service: timer.start
      entity_id: timer.night_light_timer
      data:
        duration: '00:02:00'
    - condition: state
      entity_id: group.all_wemo_lights
      state: 'off'
    - service: script.lights_on

Do something when timer completes:

- id: lights_night_sensor_off
  alias: 'Lights - Night Light, No motion off'
  trigger:
    - platform: event
      event_type: timer.finished
      event_data: 
        entity_id: timer.night_light_timer
  action:
    - service: script.lights_off

If you use trigger.entity_id you could actually have one automation to turn on all solenoids rather than one automation for each on, and then another for off. E.g. 2 automations for the control, than than 2y (8)

e.g.

- alias: Sprinker Time Zone 1_4
  trigger:
    - platform: state
      entity_id: switch.01_pro_switch_1
      to: 'on'
    - platform: state
      entity_id: switch.01_pro_switch_2
      to: 'on'
    - platform: state
      entity_id: switch.01_pro_switch_3
      to: 'on'
    - platform: state
      entity_id: switch.01_pro_switch_4
      to: 'on'
  action:
    {%- if (trigger.entity_id == "switch.01_pro_switch_1") %}
          service: homeassistant.turn_on
          entity_id: script.timed_sprinkler_01
    {%- elif (trigger.entity_id == "switch.01_pro_switch_2") %}
          service: homeassistant.turn_on
          entity_id: script.timed_sprinkler_02
    {%- elif (trigger.entity_id == "switch.01_pro_switch_3") %}
          service: homeassistant.turn_on
          entity_id: script.timed_sprinkler_03
    {%- elif (trigger.entity_id == "switch.01_pro_switch_4") %}
          service: homeassistant.turn_on
          entity_id: script.timed_sprinkler_04
    {%- else %}
          service: homeassistant.turn_on
          entity_id: script.do_nothing
    {%- endif %}

Rinse and repeat for the to ‘off’ automation.

I don’t believe you can use this anymore it should be states.input_number.slider3.state

I appreciate your help on this.

I have changed to something simpler following the automation in the wiki.

So everything displays correctly in the frontend, but when the timer finishes it doesn’t turn the switch off… Is there something I’m not putting into the automation?

  zone01_01:
    name: Time Left
    duration: '00:01:00'
    
  zone02_01:
    name: Time Left
    duration: '00:01:00'
    
  zone03_01:
    name:  Time Left
    duration: '00:01:00'
    

  zone01_05:
    name: Time Left
    duration: '00:05:00'
    
  zone02_05:
    name: Time Left
    duration: '00:05:00'
    
  zone03_05:
    name:  Time Left
    duration: '00:05:00'
    

  zone01_10:
    name: Time Left
    duration: '00:10:00'
    
  zone02_10:
    name: Time Left
    duration: '00:10:00'
    
  zone03_10:
    name:  Time Left
    duration: '00:10:00'





####################################################
#                                                  #
#                 Irrigation                       #
#                                                  #
####################################################

################  1 Minute #########################


- alias: Timer 1 Minute Zone 01
  # Timer is started when the switch pumprun is set to on. 
  trigger: 
    platform: state
    entity_id: switch.01_pro_switch_1
    to: 'on'
  action:
    service: timer.start
    entity_id: timer.zone01_01
    
- alias: Timer 1 Minute Zone 02
  # Timer is started when the switch pumprun is set to on. 
  trigger: 
    platform: state
    entity_id: switch.01_pro_switch_2
    to: 'on'
  action:
    service: timer.start
    entity_id: timer.zone02_01
    
- alias: Timer 1 Minute Zone 03
  # Timer is started when the switch pumprun is set to on. 
  trigger: 
    platform: state
    entity_id: switch.01_pro_switch_3
    to: 'on'
  action:
    service: timer.start
    entity_id: timer.zone03_01

################  5 Minutes #########################


- alias: Timer 5 Minutes Zone 01
  # Timer is started when the switch pumprun is set to on. 
  trigger: 
    platform: state
    entity_id: switch.01_pro_switch_1
    to: 'on'
  action:
    service: timer.start
    entity_id: timer.zone01_05
    
- alias: Timer 5 Minutes Zone 02
  # Timer is started when the switch pumprun is set to on. 
  trigger: 
    platform: state
    entity_id: switch.01_pro_switch_2
    to: 'on'
  action:
    service: timer.start
    entity_id: timer.zone02_05
    
- alias: Timer 5 Minutes Zone 03
  # Timer is started when the switch pumprun is set to on. 
  trigger: 
    platform: state
    entity_id: switch.01_pro_switch_3
    to: 'on'
  action:
    service: timer.start
    entity_id: timer.zone03_05

################  10 Minutes ########################
    
- alias: Timer 10 Minutes Zone 01
  # Timer is started when the switch pumprun is set to on. 
  trigger: 
    platform: state
    entity_id: switch.01_pro_switch_1
    to: 'on'
  action:
    service: timer.start
    entity_id: timer.zone01_10  
    
- alias: Timer 10 Minutes Zone 02
  # Timer is started when the switch pumprun is set to on. 
  trigger: 
    platform: state
    entity_id: switch.01_pro_switch_2
    to: 'on'
  action:
    service: timer.start
    entity_id: timer.zone02_10 
    
- alias: Timer 10 Minutes Zone 03
  # Timer is started when the switch pumprun is set to on. 
  trigger: 
    platform: state
    entity_id: switch.01_pro_switch_3
    to: 'on'
  action:
    service: timer.start
    entity_id: timer.zone03_10

I tried this, but it didn’t work and I obviously don’t understand what I’m doing. LOL

timer_zone01_01_min:
  alias: Timer Off 1 Minute Zone 01
  sequence:
    - service: timer.finished
      data: 
        entity_id: timer.zone01_01
    - service: switch.turn_off  
      data:
        entity_id: switch.01_pro_switch_1

timer_zone02_01_min:    
  alias: Timer Off 1 Minute Zone 02
  sequence:
    - service: timer.finished
      data: 
        entity_id: timer.zone02_01
    - service: switch.turn_off  
      data:
        entity_id: switch.01_pro_switch_2

timer_zone03_01_min:    
  alias: Timer Off 1 Minute Zone 03
  sequence:
    - service: timer.finished
      data: 
        entity_id: timer.zone03_01
    - service: switch.turn_off  
      data:
        entity_id: switch.01_pro_switch_3 
    
################  5 Minutes  #########################

timer_zone01_05_min:
  alias: Timer Off 5 Minutes Zone 01
  sequence:
    - service: timer.finished
      data: 
        entity_id: timer.zone01_05
    - service: switch.turn_off  
      data:
        entity_id: switch.01_pro_switch_1

timer_zone02_05_min:    
  alias: Timer Off 5 Minutes Zone 02
  sequence:
    - service: timer.finished
      data: 
        entity_id: timer.zone02_05
    - service: switch.turn_off  
      data:
        entity_id: switch.01_pro_switch_2

timer_zone03_05_min:    
  alias: Timer Off 5 Minutes Zone 03
  sequence:
    - service: timer.finished
      data: 
        entity_id: timer.zone03_05
    - service: switch.turn_off  
      data:
        entity_id: switch.01_pro_switch_3  

################  10 Minutes  ########################

timer_zone01_10_min:
  alias: Timer Off 10 Minutes Zone 01
  sequence:
    - service: timer.finished
      data: 
        entity_id: timer.zone01_10
    - service: switch.turn_off  
      data:
        entity_id: switch.01_pro_switch_1

timer_zone02_10_min:    
  alias: Timer Off 10 Minutes Zone 02
  sequence:
    - service: timer.finished
      data: 
        entity_id: timer.zone02_10
    - service: switch.turn_off  
      data:
        entity_id: switch.01_pro_switch_2

timer_zone03_10_min:    
  alias: Timer Off 10 Minutes Zone 03
  sequence:
    - service: timer.finished
      data: 
        entity_id: timer.zone03_10
    - service: switch.turn_off  
      data:
        entity_id: switch.01_pro_switch_3

Give this a shot. This is an automation not a script. Don’t worry about knowing what to do. You have to learn somehow. :wink:

- alias: 'Timer Off 10 Minutes Zone 01 Automation'
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.zone01_10
  action:
    service: switch.turn_off
    entity_id: switch.01_pro_switch_1

walrus_parka!!!

You are a gentlemen sir. That worked perfectly. Haha. I’m starting to understand more and more. This helped a ton. Thank you, thank you.

Chris

Sorry to ask one more favor, but I have tasmota scheduling my on off just in case I loose conectivity to HA.

So this is simply if I want to test them or have them go on for a few if it’s going to be hot and such.

The problem with this setup is if I don’t forget to turn off the button that activates the correct timer it stays on and HA takes over Tasmota on the scheduled timed events.

Is there a way for after the automation button I select (Say the 1 min) turns off at the time of the finished state of the timer. I tried this, but it made an error in my config file. I rebooted and the same happened.

This was a seperate set of automation rules. I tried adding another service to the OFF automation, but it gave an error as well.

Thanks for your reply’s.

################  1 Minute #########################


- alias: 'Timer Button Off 01 Minute Zone 01 Automation'
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.zone01_01
  action:
    service: automation.turn_off
    entity_id: automation.timer_1_minute_zone_01
    
- alias: 'Timer Button Off 01 Minute Zone 02 Automation'
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.zone02_01
  action:
    service: automation.turn_off
    entity id: automation.timer_1_minute_zone_02
    
- alias: 'Timer Button Off 01 Minute Zone 03 Automation'
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.zone03_01
  action:
    service: automation.turn_off
    entity_id: automation.timer_1_minute_zone_03

################  5 Minutes #########################


- alias: 'Timer Button Off 5 Minutes Zone 01 Automation'
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.zone01_05
  action:
    service: automation.turn_off
    entity_id: automation.timer_5_minutes_zone_01
    
- alias: 'Timer Button Off 5 Minutes Zone 02 Automation'
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.zone02_05
  action:
    service: automation.turn_off
    entity_id: automation.timer_5_minutes_zone_02
    
- alias: 'Timer Button Off 5 Minutes Zone 03 Automation'
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.zone03_05
  action:
    service: automation.turn_off
    entity_id: automation.timer_5_minutes_zone_03     

################  10 Minutes ########################
    
- alias: 'Timer Button Off 10 Minutes Zone 01 Automation'
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.zone01_10
  action:
    service: automation.turn_off
    entity_id: automation.timer_10_minutes_zone_01
    
- alias: 'Timer Button Off 10 Minutes Zone 02 Automation'
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.zone02_10
  action:
    service: automation.turn_off
    entity_id: automation.timer_10_minutes_zone_02
    
- alias: 'Timer Button Off 10 Minutes Zone 03 Automation'
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.zone03_10
  action:
    service: automation.turn_off
    entity_id: automation.timer_10_minutes_zone_03

Nevermind got It!!

Just needed to read. Apparently it’s the indentation. Learning more daily. Thanks

- alias: 'Timer Off 01 Minute Zone 01 Automation'
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.zone01_01
  action:
    -  service: switch.turn_off
       entity_id: switch.01_pro_switch_1
    -  service: automation.turn_off
       entity_id: automation.timer_1_minute_zone_01