Making my doorbell smart

For a while I was playing with the idea to be able to mute the doorbell, and receive a notification on my phone when somebody is at the door. I have this old fashioned doorbell that’s ringing very loud:

Old school doorbell

So I ordered some extra Wemos D1 mini ESP’s and a relay shield and started coding. Since I’ve discovered ESPHome, I intended to use this as number 1 choice before coding manually 🙂

Wemos D1 mini, headers and a relay shield

For the test setup I used a breadboard to figure out which pins to use and how the code response to it.

Test setup: a wire for input and a led for the output

I’m using esphome for communication between the doorbell and homeassistant. In my design I wanted the doorbell to be able to work without interaction with homeassistant. Therefore I used the homeassistant sensor to be able to mute the doorbell. As long as this boolean is not true, the doorbell will ring. So no message to homeassistant and a message back to the doorbell, no extra delay 😉

  name: deurbel
  platform: ESP8266
  board: d1_mini

  ssid: "<SSID>"
  password: "<PASSWORD>"

# Enable logging

# Enable Home Assistant API


  - platform: gpio
    name: "Deurbel Relay"
    id: relay
    internal: true
    icon: mdi:alarm-bell
      number: D1
      inverted: false
  - platform: gpio
    pin: D2
    name: "Deurbel"
    #device_class: window
#      - delayed_on: 50ms   # THIS DOES THE DEBOUNCE
      - delayed_off: 5000ms # THIS PREVENTS FROM MULTIPLE RANGS
        - if:
              binary_sensor.is_off: mute # IF MUTE DONT RING
              - switch.turn_on: relay
              - delay: 250ms
              - switch.turn_off: relay
  - platform: homeassistant
    name: "Input Boolean From Home Assistant"
    entity_id: input_boolean.mute_doorbell
    id: mute
  - platform: status
    name: "Status deurbel"

It works! Next step: assembling the Wemos and the Relay shield. The relay on the shield is connected to the D1, so that remains the same in my code. For the trigger I used the 3.3v on the D2. D2 is shorted to the ground via a resistor, and is high when pressed on the doorbell. This resister is needed to make sure that the input is only high when doorbell is pressed and is low on release.