
Doorbell
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...
- Cheap RF doorbells seem to have pretty limited range, with the chime only working a short distance inside the house
- You need to be in range of the chime to be able to hear and respond to it
- There is no way to keep a record of when the doorbell is pressed
Interaction flow
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
from Xiaomi
Doorbell 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.
This article is part of the Home automation set.
Feedback? Questions? Email me

All articles
About Sinclair Studios