I've been working from home a lot more recently, so I've been opting to get packages delivered straight to my home instead of the office. Since I need to sign for some packages myself, I need a reliable way to hear when someone is at the door. Now they can press a button outside, which triggers a notification and plays a doorbell chime inside the house.

The obvious fix for this is to buy a simple RF doorbell and install it, however...

In addition, the built-in chimes are bland. My first Nokia phone had better single-channel MIDI tunes.

Interaction flow

A diagram showing how messages from a Mijia button are are delivered to Home Assistant and then through to Pushbullet and a connected speaker.
A Zigbee button communicates to Zigbee2mqtt and Home Assistant to send a notification and trigger an audio alert.

The interaction flow above is similar to how the Mailbox sensor and Bedside lamp button operate, but this time the Raspberry Pi is connected directly to an external speaker

Devices

Doorbell cap

The mounted doorbell with a 'ringing bell' icon cap

It needs to be clear that the button is actually a doorbell, so I decorated it with a 3D printed cap with a 'ringing bell' silhouette from the Material Design Icons set. This is just hot-glued to the button face, making the entire cap pressable.

Playing audio

Home Assistant offers a few integrations for playing audio. I tried the Music Player Daemon and VLC integrations, but settled on the low-fi Shell Command with aplay due to its speed and minimalism. The only problem with using aplay is that it only accepts unencoded waveform audio. An easy workaround is to transcode audio files manually before using them: ffmpeg -i input.mp3 output.wav.

In this example, I'm using sound_file as a parameter to make the play_sound command reusable. My Raspberry Pi has a USB audio card connected, but for the speaker I want to use the onboard audio card (which is aliased as 'sysdefault').

$ cat ${HOME_ASSISTANT}/configuration.yaml
    
...
shell_command:
  play_sound: 'aplay -D sysdefault {{ sound_file }}'
...

Here, I'm using a new script to handle the "doorbell pressed" notification actions, to keep them decoupled from the automation trigger.

$ cat /home/homeassistant/.homeassistant/scripts.yaml
    
...
notify_doorbell_pressed:
  alias: Notify doorbell pressed
  sequence:
  - service: shell_command.play_sound
    data:
      sound_file: /home/pi/puzzle-solved.wav
  - service: notify.notify_pushbullet
    data:
      message: Doorbell was pressed
...

Finally, the automation simply waits for a single click trigger, which fires off the notify_doorbell_pressed script above.

$ cat /home/homeassistant/.homeassistant/automations.yaml
    
...
- id: doorbell_pressed
  alias: Doorbell pressed
  trigger:
  - entity_id: sensor.0x00158d0002c41211_click
    platform: state
    to: single
  action:
  - service: script.notify_doorbell_pressed
...

Wrap-up

This serves as a sensible first cut of a doorbell. Next, I'm keen to include some behaviours from other smart doorbell solutions, such as an intercom.

If you have any feedback or questions related to this article, please reply to my post on Twitter.

This article is part of the Home automation set.