Hi there, I’m trying to see if I can accomplish this using only a single button. without relying on input booleans and automations within HA (in the event wifi is down, but i still have power at the ESP and want local manual control).
Essentially I have 4 relays and one button. what i want to accomplish
- if I hold the button for 5 -7 seconds, switch on relay 4 (my manual override mode indicator led)
- if i hold the button for 3-4 seconds, switch off relay 4
- only while relay 4 is switched on
– on single press, toggle relay 1
– on double press, toggle relay 2
– on triple press, toggle relay 3
Is this possible? Below is what i’ve worked up so far, but seems to want to toggle the 3 relays on the first time activating the “dev_mode”, other-wise, seems to act as intended.
hope it helps others and maybe some of you might find a better way to automate this. I’m not sure if there is a better way to handle this
binary_sensor:
- platform: template
name: "ESP Aquaponics - Program Mode Active"
id: dev_mode
lambda: |-
if (id(esp_r4).state) {
// Program Mode Active.
return true;
} else {
// Program Mode Off.
return false;
}
## button - toggle relay
- platform: gpio
name: "ESP Aquaponics Pump Button"
pin:
number: 21
mode: INPUT_PULLUP
inverted: true
filters:
- delayed_on_off: 20ms
on_multi_click:
# Dev Mode ON
- timing:
- ON for 5s to 7s
- OFF for at least 0.5s
then:
- logger.log: "Dev Mode On"
- switch.turn_on: esp_r4
- logger.log: "Relay 4 turned on"
# dev mode active
- timing:
- ON for 3s to 4s
- OFF for at least 0.5s
then:
- logger.log: "Dev Mode OFF"
- switch.turn_off: esp_r4
- logger.log: "Relay 4 turned off"
# Relay 1 Toggle
- timing:
- ON for at most 1s
- OFF for at least 0.7s
then:
- wait_until:
binary_sensor.is_on: dev_mode
- logger.log: "Single Short-Clicked"
- switch.toggle: esp_r1
# Relay 2 Toggle
- timing:
- ON for at most 1s
- OFF for at most 1s
- ON for at most 1s
- OFF for at least 0.2s
then:
- wait_until:
binary_sensor.is_on: dev_mode
- logger.log: "Double Clicked"
- switch.toggle: esp_r2
# Relay 3 Toggle
- timing:
- ON for at most 1s
- OFF for at most 1s
- ON for at most 1s
- OFF for at most 1s
- ON for at most 1s
- OFF for at least 0.2s
then:
- wait_until:
binary_sensor.is_on: dev_mode
- logger.log: "Triple Clicked"
- switch.toggle: esp_r3
switch:
## restart
- platform: restart
name: "ESP Fish Pond Restart"
- platform: gpio
name: "ESP R1 - Aquaponics Pump"
id: esp_r1
pin:
number: 17
inverted: false
- platform: gpio
name: "ESP R2 - Air Pump"
id: esp_r2
pin:
number: 16
inverted: false
- platform: gpio
name: "ESP R3 - Heater"
id: esp_r3
pin:
number: 26
inverted: false
- platform: gpio
name: "ESP R4 - Aux"
id: esp_r4
pin:
number: 25
inverted: false