Files
devices/sonoff-m5/button-c.yaml
2026-04-27 13:34:09 +02:00

61 lines
1.6 KiB
YAML

# NOTE: This file is not a stand-alone package. It is part of
# a 'root' device template and expects the substitutions that
# are hereby referenced to be defined by its parent.
binary_sensor:
# Physical Button C
- platform: gpio
name: "Button C"
id: button_c
pin:
number: ${button_c_gpio}
mode: INPUT_PULLUP
inverted: true
ignore_strapping_warning: true
filters:
- delayed_on: ${filter_delay_on}
- delayed_off: ${filter_delay_off}
on_multi_click:
# single click detection
- timing:
- ${timing_click_1}
- ${timing_click_2}
then:
- homeassistant.event:
event: esphome.on_gesture
data:
button: C
gesture: single_click
# double click detection
- timing:
- ${timing_double_click_1}
- ${timing_double_click_2}
- ${timing_double_click_3}
- ${timing_double_click_4}
then:
- homeassistant.event:
event: esphome.on_gesture
data:
button: C
gesture: double_click
# hold detection
- timing:
- ${timing_hold}
then:
- while:
condition:
binary_sensor.is_on: button_c
then:
- light.toggle: led_status
- homeassistant.event:
event: esphome.on_gesture
data:
button: C
gesture: button_hold
- delay: ${timing_hold_repeat}
- light.turn_off: led_status