Wireless Doorbell with esphome and homeassistant

A short description for turning an ancient doorbell into a smart doorbell with esphome, homeassistant and mqtt

Flashing the esp-01


The esp-01 needs to be flashed with some firmware before we can use it. To start with, we just need a version of esphome and from then on we can use Over The Air updates (OTA) for our customisation.

Using the wiring guide from Franck Nijhof and the ESP Web Tools demo flash the chip with the basic esp-web-tools-example.

Doorbell Buzzer


The main doorbell is pretty much in line with Franck’s guide although I did add some extra mqtt configuration which will be covered below.

Wireless Chime

We can’t hear the main doorbell very well from the kitchen so I wanted to create an extra wireless chime. Here is how I went about it:

Use the esphome wizard to create a project

docker run --rm -v "${PWD}":/config -it esphome/esphome wizard doorbell_chime.yaml

Initial configuration for the chime

  name: doorbellchime

  board: esp01_1m

# Enable logging

# Enable Home Assistant API
  password: ""

  password: ""

  ssid: "wifi"
  password: "wificode"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
    ssid: "wifi"
    password: "wificode"


# Enable Web server.
  port: 80

Add some extra lines so the esphome device will show up in homeassistant

# Sync time with Home Assistant.
  - platform: homeassistant
    id: homeassistant_time

# Text sensors with general information.
  # Expose ESPHome version as sensor.
  - platform: version
    name: DoorbellChime ESPHome Version
  # Expose WiFi information as sensors.
  - platform: wifi_info
      name: DoorbellChime IP
      name: DoorbellChime SSID
      name: DoorbellChime BSSID

Deploying over the air

docker run --rm -v "${PWD}":/config -it esphome/esphome run doorbell_chime.yml > log.txt

There will most likely be an error message

INFO Successfully compiled program.
INFO Resolving IP address of doorbellchime.local
ERROR Error resolving IP address of doorbellchime.local. Is it connected to WiFi?
ERROR (If this error persists, please set a static IP address: https://esphome.io/components/wifi.html#manual-ips)
ERROR Error resolving IP address: Error resolving address with mDNS: Did not respond. Maybe the device is offline., [Errno -2] Name or service not known

If using DHCP search the log for ’esp-web-tools-example’ or just ’esp’. ie

tail -n 1000 -f /var/log/syslog | grep 'esp'

Add a local DNS record to pihole for doorbellchime.local. Don’t add to /etc/hosts, for some reason it doesn’t work.

Add to homeassistant


For me, the esp device was not automatically added so I needed to add a new esphome integration with the ip address in home assistant

Now we are off and running.

Tell the wireless chime that the doorbell button has been pressed

I am sure I could have used homeassistant to trigger the wireles chime, but I wanted to experiment with the two esp devices talking to each other using mqtt. The two devices share an mqtt topic (/doorbell). When the doorbell button is pressed, the main doorbell esp publishes a message on this topic and the wireless chime uses this to trigger the bell. It works amazingly well! These are the mqtt changes to the esp config files:

Main doorbell

# Enable mqtt to send a message to our wireless receiver
+  broker: mqtt.host.name
+  port: 1883
+  topic_prefix: doorbell

# Binary sensor representing the
# Doorbell button push.
  - platform: gpio
    id: button
    name: Doorbell Button
      # Connected to GPIO on the ESP-01S.
      number: GPIO2
      mode: INPUT_PULLUP
      inverted: true
      # Small filter, to debounce the button press.
      - delayed_on: 25ms
      - delayed_off: 25ms
      # Only turn on the chime when it is active.
+        - logger.log: "Publishing on mqtt message"
+        - mqtt.publish_json:
+            topic: doorbell/chime
+            payload: |-
+              root["button"] = id(button).state;
+        - if:
              - switch.is_on: chime_active
              - switch.turn_on: relay

Wireless chime

# Enable mqtt to send a message to our wireless receiver
+  broker: mqtt.host.name
+  port: 1883
+  topic_prefix: doorbell
+  on_json_message:
+    topic: doorbell/chime
+    then:
+      - logger.log: "Ringing chime"
+      - switch.turn_on: relay
+      - delay: 3s
+      - switch.turn_off: relay

Wireless Doorbell Chime Version 0.1


Here it is, reusing an Amazon USB 5v power supply…