diff --git a/common/base.yaml b/common/base.yaml index 0d34f51..c36b20d 100644 --- a/common/base.yaml +++ b/common/base.yaml @@ -4,7 +4,7 @@ time: binary_sensor: - platform: status - name: Online + name: Status id: ink_ha_connected entity_category: diagnostic diff --git a/doorbell.yaml b/doorbell.yaml index d238bfa..f948884 100644 --- a/doorbell.yaml +++ b/doorbell.yaml @@ -5,10 +5,14 @@ esphome: esp32: board: esp32dev + framework: + type: esp-idf + +packages: !include common/base.yaml # Enable Home Assistant API api: -web_server: +logger: ota: - platform: esphome @@ -18,15 +22,35 @@ wifi: ssid: !secret wifi_ssid password: !secret wifi_password -sensor: - - platform: uptime - name: Uptime - - platform: wifi_signal - name: WiFi Signal - update_interval: 10s +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 + - 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: - - id: chime + - id: should_ring type: bool restore_value: True initial_value: 'true' @@ -42,60 +66,56 @@ switch: name: Chime Active restore_mode: RESTORE_DEFAULT_ON lambda: |- - return id(chime); + return id(should_ring); turn_on_action: - globals.set: - id: chime + id: should_ring value: 'true' turn_off_action: - globals.set: - id: chime + id: should_ring value: 'false' binary_sensor: - platform: gpio - id: push_button + id: button_doorbell + internal: True pin: number: GPIO15 mode: input: True pulldown: True filters: - - delayed_on: 50ms - - delayed_off: 8s - on_press: - then: - - light.turn_on: - id: ring - red: 0 - 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 + - delayed_on: 20ms + - delayed_off: 20ms + 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 -button: - - platform: template - id: chime_button - name: Ring - icon: mdi:bell - on_press: - then: - - if: - condition: - - switch.is_on: chime_active - then: - - switch.turn_on: relay - - delay: 0.3s - - switch.turn_off: relay - - platform: restart - name: Restart + # 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 @@ -125,4 +145,4 @@ light: transition_length: 1s update_interval: 1s default_transition_length: - milliseconds: 200 + milliseconds: 100