Hi,
I have a sonoff mini controlling a zigbee bulb. Since I don’t want to cut the main to the bulb by the relay, I was looking for alternative ways, while still having the possibility to control the main in case of wifi or ha failure.
I thought to use a momentary button instead a switch connected to the sonoff, then configure 2 different actions:
- double_click: toggle the relay
- single click: generate an event used in automations to toggle the zigbee bulb
I’m very new to ESPHome, and the only way I figured out is:
binary_sensor:
- platform: gpio
name: ${device_name}_button
pin:
number: GPIO04
inverted: true
id: button_1
on_multi_click:
- timing:
- ON for at most 1s
- OFF for at most 0.5s
- ON for at most 1s
- OFF for at least 0.2s
then:
- switch.toggle: relay_1
- timing:
- ON for at most 1s
- OFF for at least 0.5s
then:
- homeassistant.event:
event: esphome.sonoff_click
Then in Home Assistant I can create an automation triggered by esphome.sonoff_click and checking the device_id. So far so good… but I dont like it
Is there a way to create a device specific event, like a virtual sensor or switch toggled by the click and managed in HA?