feat: update doorbell to support multi-click

This commit is contained in:
Mario Lang 2025-08-09 15:15:40 +00:00
parent f20540792f
commit 213469defa
2 changed files with 68 additions and 48 deletions

View file

@ -4,7 +4,7 @@ time:
binary_sensor: binary_sensor:
- platform: status - platform: status
name: Online name: Status
id: ink_ha_connected id: ink_ha_connected
entity_category: diagnostic entity_category: diagnostic

View file

@ -5,10 +5,14 @@ esphome:
esp32: esp32:
board: esp32dev board: esp32dev
framework:
type: esp-idf
packages: !include common/base.yaml
# Enable Home Assistant API # Enable Home Assistant API
api: api:
web_server: logger:
ota: ota:
- platform: esphome - platform: esphome
@ -18,15 +22,35 @@ wifi:
ssid: !secret wifi_ssid ssid: !secret wifi_ssid
password: !secret wifi_password password: !secret wifi_password
sensor: event:
- platform: uptime - platform: template
name: Uptime name: Doorbell
- platform: wifi_signal id: doorbell
name: WiFi Signal device_class: doorbell
update_interval: 10s event_types:
- short
- double
- long
on_event:
then:
- if:
condition:
- switch.is_on: chime_active
then:
- switch.turn_on: relay
- light.turn_on:
id: ring
red: 0
green: 1
blue: 0.7
effect: pulse
- delay: 0.2s
- switch.turn_off: relay
- delay: 5s
- light.turn_off: ring
globals: globals:
- id: chime - id: should_ring
type: bool type: bool
restore_value: True restore_value: True
initial_value: 'true' initial_value: 'true'
@ -42,60 +66,56 @@ switch:
name: Chime Active name: Chime Active
restore_mode: RESTORE_DEFAULT_ON restore_mode: RESTORE_DEFAULT_ON
lambda: |- lambda: |-
return id(chime); return id(should_ring);
turn_on_action: turn_on_action:
- globals.set: - globals.set:
id: chime id: should_ring
value: 'true' value: 'true'
turn_off_action: turn_off_action:
- globals.set: - globals.set:
id: chime id: should_ring
value: 'false' value: 'false'
binary_sensor: binary_sensor:
- platform: gpio - platform: gpio
id: push_button id: button_doorbell
internal: True
pin: pin:
number: GPIO15 number: GPIO15
mode: mode:
input: True input: True
pulldown: True pulldown: True
filters: filters:
- delayed_on: 50ms - delayed_on: 20ms
- delayed_off: 8s - delayed_off: 20ms
on_press: on_multi_click:
# Single Short Click
- timing:
- ON for at most 750ms
- OFF for at least 300ms
then: then:
- light.turn_on: - event.trigger:
id: ring id: doorbell
red: 0 event_type: short
green: 1
blue: 0.7
effect: pulse
- button.press: chime_button
on_release:
then:
- light.turn_off:
id: ring
transition_length: 1s
- platform: status
name: Status
button: # Double Click: two quick presses
- platform: template - timing:
id: chime_button - ON for at most 750ms
name: Ring - OFF for at most 300ms
icon: mdi:bell - ON for at most 750ms
on_press: - OFF for at least 300ms
then: then:
- if: - event.trigger:
condition: id: doorbell
- switch.is_on: chime_active event_type: double
# Long Press only
- timing:
- ON for at least 750ms
then: then:
- switch.turn_on: relay - event.trigger:
- delay: 0.3s id: doorbell
- switch.turn_off: relay event_type: long
- platform: restart
name: Restart
output: output:
- platform: ledc - platform: ledc
@ -125,4 +145,4 @@ light:
transition_length: 1s transition_length: 1s
update_interval: 1s update_interval: 1s
default_transition_length: default_transition_length:
milliseconds: 200 milliseconds: 100