Talking Door Bell
I use a USB radio dongle with rtl_433 to log data from several devices, like rainfall, temperatures etc. I recently bought a wireless doorbell and rtl_433 will receive the bell push data too. It came with a receiver that uses up another mains socket but I had a better idea.
My logging setup runs on Raspbery Pi. The incoming data are logged to a file on a RAM disk which is process every five minutes and then zeroed. Obviously having a doorbell notification five minutes ater it's pressed is of little use but, linux has userspace file monitoring applications and one fo these can be used to monitor the temporary file for changes then parse the tail for matching data. On a match, using grep, a sound file is played through my always-on speakers.
Install inotify-tools using apt if you're using Raspian and adapt the script below to your needs.
#!/bin/bash
# Unload and reload modules to force re-init of SDR
modprobe -r dvb_usb_rtl28xxu
modprobe dvb_usb_rtl28xxu
#Now start the process with output to a file
/usr/local/bin/rtl_433 -C si -F json:/home/username/logger/ramdisk/rtl_433.json &
# Set up an inotifyevent on the file to ring a bell if the correct code is received/
# The
inotifywait -q -m -e modify /home/username/logger/ramdisk/rtl_433.json |
while read events; do
#echo $events
line=$(tail -1 /home/username/logger/ramdisk/rtl_433.json | grep 11122) # Doorbell code is 11122
if [ -n "$line" ]
then
logger "Doorbell"
# Get the current volume
vol=$(awk -F"[][]" '/dB/ { print $2 }' <(amixer sget -M PCM) | sed 's/\%//')
# Set the volume
amixer sset -M PCM 50%
# Play the messages.
mpg123 /home/username/logger/door.mp3
# Restore the volume
amixer sset -M PCM $vol%
sleep 1
fi
done
This script is called from a systemd file and runs on startup.
Last changed: 25. January, 2022 at 10:19
Back to Overview