esphome/doorbell.yaml
2025-08-16 13:36:45 +00:00

152 lines
2.9 KiB
YAML

esphome:
name: doorbell
friendly_name: Doorbell
name_add_mac_suffix: True
esp32:
board: esp32dev
framework:
type: esp-idf
packages: !include common/base.yaml
# Enable Home Assistant API
api:
logger:
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
event:
- platform: template
name: Doorbell
id: doorbell
device_class: doorbell
event_types:
- short
- double
- long
on_event:
then:
- if:
condition:
- switch.is_on: chime_active
then:
- switch.turn_on: relay
- delay: 0.2s
- switch.turn_off: relay
globals:
- id: should_ring
type: bool
restore_value: True
initial_value: 'true'
switch:
- platform: gpio
name: Relay
id: relay
internal: True
pin: GPIO12
- platform: template
id: chime_active
name: Chime Active
restore_mode: RESTORE_DEFAULT_ON
lambda: |-
return id(should_ring);
turn_on_action:
- globals.set:
id: should_ring
value: 'true'
turn_off_action:
- globals.set:
id: should_ring
value: 'false'
binary_sensor:
- platform: gpio
id: button_doorbell
internal: True
pin:
number: GPIO15
mode:
input: True
pulldown: True
filters:
- delayed_on: 20ms
- delayed_off: 20ms
on_press:
then:
- light.turn_on:
id: ring
red: 0
green: 1
blue: 0.7
effect: pulse
on_release:
then:
- delay: 5s
- light.turn_off: ring
on_multi_click:
# Single Short Click
- timing:
- ON for at most 750ms
- OFF for at least 300ms
then:
- event.trigger:
id: doorbell
event_type: short
# Double Click: two quick presses
- timing:
- ON for at most 750ms
- OFF for at most 300ms
- ON for at most 750ms
- OFF for at least 300ms
then:
- event.trigger:
id: doorbell
event_type: double
# Long Press only
- timing:
- ON for at least 750ms
then:
- event.trigger:
id: doorbell
event_type: long
output:
- platform: ledc
pin: GPIO2
id: led_red
- platform: ledc
pin: GPIO4
id: led_green
- platform: ledc
pin: GPIO16
id: led_blue
light:
- platform: rgb
name: Ring
id: ring
blue: led_blue
green: led_green
red: led_red
effects:
- pulse:
transition_length: 500ms
update_interval: 500ms
min_brightness: 30%
max_brightness: 100%
- random:
transition_length: 1s
update_interval: 1s
default_transition_length:
milliseconds: 100