Pause/Resume Sprinkler controler

I would like to use a switch to pause and resume the sprinklers where they left off.

on_...:
  then:
    - sprinkler.pause: sprinkler_ctrlr
on_...:
  then:
    - sprinkler.resume: sprinkler_ctrlr

this is the code from esphome docs but i don’t understand where to put the code or how to trigger it via a switch in HA

my yaml for the controller is below

esphome:
  name: sprinkler-controller
  friendly_name: Sprinkler Controller



esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "3JV5RJdjqbide6/lwXIXXLfSAYQECJItsIvT7F0ifLI="

ota:
  - platform: esphome
    password: "bee3c396ab8dfe0f40a58dd90e5bc645"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Sprinkler-Controller"
    password: "p0JEw6Z6qLjh"

captive_portal:

web_server:
  port: 80

bluetooth_proxy:
  active: true

time:
  - platform: homeassistant
    id: homeassistant_time

binary_sensor:
  - platform: status
    name: "Status"

  - platform: gpio
    name: "Boot Button"
    pin:
      number: 0
      ignore_strapping_warning: true
      mode:
        input: true
      inverted: true
    disabled_by_default: true
    on_press:
      then:
        - button.press: restart_button
sprinkler:
  - id: lawn_sprinkler_ctrlr
    main_switch: "Lawn Sprinklers"
    auto_advance_switch: "Lawn Sprinklers Auto Advance"
    reverse_switch: "Lawn Sprinklers Reverse"
    multiplier_number: "Lawn Sprinkler Multiplier"
    repeat_number: "Lawn Sprinkler Repeat"
    valve_overlap: 5s
    valves:
      - valve_switch: "Zone 1"
        enable_switch: "Enable Zone 1"
        run_duration_number: "Zone 1"
        valve_switch_id: zone1
      - valve_switch: "Zone 2"
        enable_switch: "Enable Zone 2"
        run_duration_number: "Zone 2"
        valve_switch_id: zone2
      - valve_switch: "Zone 3"
        enable_switch: "Enable Zone 3"
        run_duration_number: "Zone 3 Run Duration"
        valve_switch_id: zone3

switch:
  - platform: gpio
    pin: GPIO1
    id: zone1
  - platform: gpio
    pin: GPIO2
    id: zone2
  - platform: gpio
    pin: GPIO41
    id: zone3
  - platform: gpio
    pin: GPIO42
    id: zone4
  - platform: gpio
    pin:
      number: GPIO45
      ignore_strapping_warning: true
    id: zone5
  - platform: gpio
    pin:
      number: GPIO46
      ignore_strapping_warning: true
    id: zone6

uart:
  tx_pin: GPIO17
  rx_pin: GPIO18
  baud_rate: 9600
  id: modbus_uart

# buzzer
output:
  - platform: ledc
    pin: GPIO21
    id: buzzer

rtttl:
  output: buzzer
  id: rtttl_buzzer
  gain: 30%

light:
  - platform: esp32_rmt_led_strip
    chipset: ws2812
    pin: GPIO38
    num_leds: 1
    rgb_order: RGB
    name: "RGB LED"
    id: rgb_led

button:
  - platform: restart
    name: "Restart"
    id: restart_button
    entity_category: config

  - platform: factory_reset
    name: "Factory Reset"
    id: reset
    entity_category: config

  - platform: safe_mode
    name: "Safe Mode"
    internal: false
    entity_category: config

Try this:

switch:
  - platform: template
    name: "Pause Switch"

    turn_on_action:
      - sprinkler.pause: sprinkler_ctrlr
    turn_off_action:
      - sprinkler.resume: sprinkler_ctrlr
1 Like

does this go in the esphome yaml or in HA automation yaml?

Esphome yaml

The way the documentation is meant to be used, it isn’t obvious to most people and not intuitive IMO.

See how the example you copied/pasted starts with

on_...

The “…” will depend on what type of entry you choose and for example if you want your Pause/Resume to be a Button then you go look at the Button Documentation to see what the “…” type it uses.
[Esphome Button ](Button Component - ESPHome - Smart Home Made Simple Button Component - ESPHome - Smart Home Made Simple)

So, Button uses

on_press:

For its automation so, thats what you need to use.

If for example you want to trigger Pause/Resume from a Switch then you go look at the Switch documentation and see what Switch requires for its automations. Switch can use…

on_turn_on:

on_turn_off:

So thats what you for that “on_…” you were asking
[Switch](Switch Component - ESPHome - Smart Home Made Simple Switch Component - ESPHome - Smart Home Made Simple)

Ill give you 1 more example here. Say you wanted to the Pause/Resume to be triggered based on some sensor state, like a rain sensor perhaps. You want to use use the Pause Action based on if its raining so, you go look at the Sensor documentation and check to see what it uses for it’s

on_...

[Sensor](Sensor Component - ESPHome - Smart Home Made Simple Sensor Component - ESPHome - Smart Home Made Simple)

According to the documentation it uses

on_value:

on_value_range:

on_raw_value:

So, now you know what options you have to choose from to complete that “on_…” example and the answer is, “it just depends on what you wind up using”

You wouldn’t likely use a Sensor for that type of example either sorry. You would use a

binary_sensor:

[Binary sensor](Binary Sensor Component - ESPHome - Smart Home Made Simple Binary Sensor Component - ESPHome - Smart Home Made Simple)

And it uses,

on_press:

on_state:

on_click:

And etc. So, if you needes to use binary_sensor then those are the configuration options for binary_sensor automations.

Does that make sense or help a little bit?

The idea is a zigbee button that pauses it so someone can take a shower or get out the front door, and have it resume 15 to 30 mins later. The schedule around here changes so much, I tired of dodging sprinklers to get to garage to shut it off.

The most logical thing to do would be to just push the start time back even earlier in the AM. Water the zones in the front of the house first thing so that there is a low likelihood of them ever bwing on during the morning rush to exit the house…

So did you get the template switch working?

no the switch shows up in the control panel, but about 2 seconds after its switched on is turn off automatically and shut the whole system do

  name: sprinkler-controller
  friendly_name: Sprinkler Controller

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "3JV5RJdjqbide6/lwXIXXLfSAYQECJItsIvT7F0ifLI="

ota:
  - platform: esphome
    password: "bee3c396ab8dfe0f40a58dd90e5bc645"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Sprinkler-Controller"
    password: "p0JEw6Z6qLjh"

captive_portal:

web_server:
  port: 80

bluetooth_proxy:
  active: true

time:
  - platform: homeassistant
    id: homeassistant_time

binary_sensor:
  - platform: status
    name: "Status"

  - platform: gpio
    name: "Boot Button"
    pin:
      number: 0
      ignore_strapping_warning: true
      mode:
        input: true
      inverted: true
    disabled_by_default: true
    on_press:
      then:
        - button.press: restart_button
sprinkler:
  - id: lawn_sprinkler_ctrlr
    main_switch: "Lawn Sprinklers"
    auto_advance_switch: "Lawn Sprinklers Auto Advance"
    reverse_switch: "Lawn Sprinklers Reverse"
    multiplier_number: "Lawn Sprinkler Multiplier"
    repeat_number: "Lawn Sprinkler Repeat"
    valves:
      - valve_switch: "Zone 1"
        enable_switch: "Enable Zone 1"
        run_duration_number: "Zone 1"
        valve_switch_id: zone1
      - valve_switch: "Zone 2"
        enable_switch: "Enable Zone 2"
        run_duration_number: "Zone 2"
        valve_switch_id: zone2
      - valve_switch: "Zone 3"
        enable_switch: "Enable Zone 3"
        run_duration_number: "Zone 3 Run Duration"
        valve_switch_id: zone3
      - valve_switch: "Zone 4"
        enable_switch: "Enable Zone 4"
        run_duration_number: "Zone 4 Run Duration"
        valve_switch_id: zone4
      - valve_switch: "Zone 5"
        enable_switch: "Enable Zone 5"
        run_duration_number: "Zone 5 Run Duration"
        valve_switch_id: zone5  
      
      

switch:
  - platform: gpio
    pin: GPIO1
    id: zone1
  - platform: gpio
    pin: GPIO2
    id: zone2
  - platform: gpio
    pin: GPIO41
    id: zone3
  - platform: gpio
    pin: GPIO42
    id: zone4
  - platform: gpio
    pin:
      number: GPIO45
      ignore_strapping_warning: true
    id: zone5
  - platform: gpio
    pin:
      number: GPIO46
      ignore_strapping_warning: true
    id: zone6
uart:
  tx_pin: GPIO17
  rx_pin: GPIO18
  baud_rate: 9600
  id: modbus_uart

# buzzer
output:
  - platform: ledc
    pin: GPIO21
    id: buzzer

rtttl:
  output: buzzer
  id: rtttl_buzzer
  gain: 30%

light:
  - platform: esp32_rmt_led_strip
    chipset: ws2812
    pin: GPIO38
    num_leds: 1
    rgb_order: RGB
    name: "RGB LED"
    id: rgb_led

button:
  - platform: restart
    name: "Restart"
    id: restart_button
    entity_category: config

Ideas???
thoughts

Dan

what is that **?

i tried to highlight it opps

Not clear to me what’s going on there…
Try how it behaves adding optimistic: true to that template switch

  - platform: template
    optimistic: true

I set it up as 2 button one pause one resume and it works fine, not sure why it didn’t like the on off switch

  - platform: restart
    name: "Restart"
    id: restart_button
    entity_category: config
  - platform: template
    name: "Sprinkler Pause"
    id: sprinkler_pause
    on_press:
     then:
      - sprinkler.pause: lawn_sprinkler_ctrlr
  - platform: template
    name: "Sprinkler Resume"
    id: sprinkler_resume
    on_press:
      then:
        - sprinkler.resume_or_start_full_cycle: lawn_sprinkler_ctrlr 

its working

Dan