zuidwijk / esphome-doorbell

ESPHome based DoorBell
58 stars 17 forks source link

Switch doesn't debounce #12

Closed x-real-ip closed 6 months ago

x-real-ip commented 6 months ago

Hello, the switch did not debounce. When I press the doorbell button (switch), it keeps ringing until I manually turn off the switch in home assistant. Anyone any idea what could be the cause? I have the smart-doorbell hardware v3

config:

---
substitutions:
  device_name: smart-doorbell
  device_comment: "Zuidwijk smart-doorbell"

esphome:
  name: ${device_name}
  project:
    name: zuidwijk.smart-doorbell
    version: "1.0"

esp32:
  board: esp32dev
  framework:
    type: arduino

<<: !include { file: common/api.yaml, vars: { reboot_timeout: "15min" } }

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  domain: !secret wifi_domain
  ap:
    ssid: ${device_name}_ap
    password: !secret wifi_password

captive_portal:

logger:

ota:
  password: !secret ota_password

web_server:
  port: 80

time:
  - platform: homeassistant
    id: homeassistant_time

sensor:
  - platform: uptime
    name: ${device_name}_uptime
  - platform: wifi_signal
    name: ${device_name}_wifi_signal
    update_interval: 20s
    filters:
      - sliding_window_moving_average:
          window_size: 3
          send_every: 3
          send_first_at: 3

text_sensor:
  - platform: wifi_info
    ip_address:
      name: ${device_name}_wifi_ip
    ssid:
      name: ${device_name}_wifi_ssid
    bssid:
      name: ${device_name}_wifi_bssid
  - platform: version
    name: ${device_name}_version

improv_serial:

esp32_improv:
  authorizer: none

dashboard_import:
  package_import_url: github://zuidwijk/esphome-doorbell/smart-doorbell.yaml@main
  import_full_config: true

globals:
  - id: chime
    type: bool
    restore_value: true
    initial_value: "true"

switch:
  - platform: restart
    name: ${device_name}_restart
  - platform: gpio
    pin:
      number: GPIO5
      inverted: false
    name: "${device_name}_relay"
    id: relay
    internal: false
    icon: mdi:alarm-bell
  - platform: template
    name: ${device_name}_chime_active
    id: chime_active
    restore_mode: disabled
    turn_on_action:
      - globals.set:
          id: chime
          value: "true"
    turn_off_action:
      - globals.set:
          id: chime
          value: "false"
    lambda: |-
      return id(chime);

binary_sensor:
  - platform: status
    name: ${device_name}_status
  - platform: gpio
    name: ${device_name}_button
    pin:
      number: GPIO4
      mode: INPUT_PULLUP
      inverted: true
    filters:
      - delayed_on: 25ms
      - delayed_off: 25ms
    on_press:
      then:
        if:
          condition:
            - switch.is_on: chime_active
          then:
            - switch.turn_on: relay
    on_release:
      - switch.turn_off: relay
x-real-ip commented 6 months ago

Already figured it out I had to set inverted to false for GPIO4

binary_sensor:
  - platform: gpio
    name: ${device_name}_button
    pin:
      number: GPIO4
      mode: INPUT_PULLUP
      inverted: false