I have an ESP32 connected to a relay and a momentary button. I want to use the button to turn off the relay locally as well as send a message (somehow) to HAss to turn on/off all lights.
Tap> toggle local relay(light); double tap>all lights on; hold for 2s> all lights off.
BUT—The light.toggle function is not working correctly. It turns off the light, and then IMMEDIATELY turns it back on. I tried to code a toggle from scratch using an if>then>else function, but it still did the same thing. Please Help!
binary_sensor:
platform: gpio
pin:
number: 12
mode: INPUT_PULLUP
name: "BedButton"
filters:
- invert:
- delayed_on: 50ms
- delayed_off: 50ms
# - delayed_on_off: 1000ms
on_multi_click:
- timing:
- ON for at most 1s
- OFF for at most 0.3s
- ON for at most 1s
- OFF for at least 0.2s
then:
- light.turn_on: BedLamp1
- switch.template.publish:
id: allLights
state: ON
- logger.log: "Double-Clicked"
- timing:
- ON for at most .5s
- OFF for at least 0.1s
then:
light.toggle: BedLamp1
# if:
# condition:
# light.is_on: BedLamp1
# then:
# - light.turn_off: BedLamp1
# - logger.log: "Single-Clicked Off"
# else:
# - light.turn_on: BedLamp1
# - logger.log: "Single-Clicked On"
- timing:
- ON for at least 2s
then:
- light.turn_on:
id: ButtonLight
brightness: 15%
- switch.template.publish:
id: allLights
state: OFF
- logger.log: "Hold-Click"