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