- This program turns your Raspberry Pi into a doorbell. It can replace a traditional hardware doorbell, and it integrates with openHAB and has a number of customization features.
-
Integration with openHAB via its simple HTTP API. Know if your doorbell's been rung and take actions accordingly.
-
Silent mode. It's beneficial for babies or people who act like babies all day when the doorbell interrupts their sleep.
-
Selectable indoor/outdoor sound location (based on stereo channel). Even if it's silent inside, you can make it play outside so that someone doesn't think your doorbell's broken and resort to knocking.
-
Configurable sound. You can go with a traditional sound or pick novelty sounds for holidays, specific guests, UPS delivery, etc.
-
Button timings match a real mechanical doorbell. The software reacts in real time, but there's a (configurable) delay that precedes the playback of the lower-pitch bell.
-
On-the-fly re-load of configuration changes. This makes the configurable sound feature more powerful.
-
Raspberry Pi. (Rev B tested, but any revision should work.)
-
A momentary switch.
-
A resistor. (The resistance depends on how you wire up your switch.)
-
A free GPIO pin.
-
Two WAV files.
-
At least 7% available CPU on your Pi.
-
Basic Linux skills (file copying and editing).
-
Wire up a pushbutton on a GPIO pin of your choosing.
-
There are many different ways to do this. _See online HOWTOs for doing this properly.
-
The code does not enable built-in pulldown or pullup resistors, so you will need to provide your own resistor._
-
-
Copy the project files and folders to a directory of your choosing on your Raspberry Pi.
-
Edit
doorbell_config.ini
.-
Set
input_pin
to the 1-indexed board-centric pin number that you used above, as shown here. -
If your button takes your input pin LOW when pressed, set
reverse_logic
toTrue
. Otherwise, set it toFalse
. -
Set the paths of the WAV files you want to use (or leave them alone to use the default included sounds).
-
ding_soundfile
will be played on button press. -
dong_soundfile
will be played on button release.
-
-
Set
noise_location
to reflect where you want your doorbell sounds to play.
-
-
In the directory where you copied the project files and directories, run this command:
sudo python ./doorbell.py
-
Press and release the button as you would a normal doorbell.
For openHAB Integration
- In openHAB, add a "virtual" doorbell in your
.items
file for the doorbell, like so:
Switch Button_Front_Doorbell "Doorbell" (Outdoor)
- Set up any rules you'd like to run when it's pressed and released. Example
.rules
entry:
rule "Virtual Front Doorbell"
when
Item Button_Front_Doorbell received command
then
if(receivedCommand==ON) {
logInfo("Virtual Front Doorbell", "DING...")
} else if(receivedCommand==OFF) {
logInfo("Virtual Front Doorbell", "...DONG")
}
end
- In
doorbell_config.ini
, editopenhab_base_URL
to point to the URL for your openHAB instance, and edititem_name
to match your virtual doorbell. For example:
openhab_base_URL:http://openhab.igo:8080/CMD/
item_name:Button_FF_Doorbell
For Home Assistant Integration
- In Home Assistant, add a "virtual" doorbell in
configuration.yaml
as aninput_boolean
, like so:
input_boolean:
doorbell:
name: doorbell state
initial: off
- Set up an automation you'd like to fire when it's pressed and released. Example automation:
- alias: notify of doorbell ring
trigger:
platform: state
entity_id: binary_sensor.doorbell
from: 'off'
to: 'on'
action:
service: notify.medium_priority
data:
title: ''
message: 'DOORBELL'
- In
doorbell_config.ini
, editha_base_URL
to point to the URL for your Home Assistant instance, and editentity_id
to match your virtual doorbell. For example:
ha_base_URL:http://hass.igo:8123/api/states/
entity_id:binary_sensor.doorbell
- See the comments in
doorbell_config.ini
to learn about the other ways you can configure your doorbell.
- As above, but create or find two bell tones in WAV format. The 'DING' tone should be 3 half-tones in pitch higher than the 'DONG' tone.
- As above, using any two WAV files you like.
-
DING: "somebody's" DONG: "at the door"
- A larger value for
dong_delay
indoorbell_config.ini
is likely necessary, to avoid "at the door" stepping over "somebody's."
- A larger value for
-
DING: (a dog barking) DONG: (another dog barking)
-
DING: (spooky Halloween ambient sounds) DONG: (random spooky Halloween accent sound)
- For the accent sound, write a script that periodically edits
doorbell_config.ini
to pointdong_soundfile
at a different WAV file.
- For the accent sound, write a script that periodically edits
- Alter
doorbell_config.ini
to point to different sounds when different external conditions occur, such as calendar events (keywords, holidays, etc.), times of day.
-
DING: "Happy" DONG: "Easter"
- Use a calendar to pick different WAV files and
dong_delay
values fordoorbell_config.ini
.
- Use a calendar to pick different WAV files and
-
DING: "Hi, [friend's name]." DONG: "I'll be right there."
- Use openCV to do face or license plate recognition, then change
ding_soundfile
indoorbell_config.ini
appropriately. Change it all back when done.
- Use openCV to do face or license plate recognition, then change
-
DING: "Hi. We're asleep right now, so please leave a message after the beep. BEEP" DONG: (silence)
- Boodler is a Python soundscape generator. You could either generate "canned" instances of dynamically-generated soundscapes and switch between them using methods outlined above, or you could extend the software architecture to invoke Boodler instead of playing WAV files.
- I'm happy to field any questions in the comments on my corresponding blog post.