We have a pretty standard doorbell with a wireless chime, but living in a three floor house means the chime cannot be heard in all rooms. These doorbells usually run on 433MHz, which means we can use some cheap hardware to intercept the signals.

In this project I have used a Raspberry Pi with a NESDR Mini 2 USB RTL-SDR to capture the wireless signal from the doorbell and activate a sensor in Home Assistant. Home Assistant then sends a notification to my mobile and plays a doorbell sound through my Google Assistants.

Pi Setup

First we will setup the Pi. I won’t go through the full setup, as there are many guides out there, but here is a very quick overview of the setup:

Example of signals received, showing the SDR is working.

Capture the signal

To capture the signal we will use the pulse analyser mode to capture the signal, this will analyse the signal from the doorbell and give us the details needed.

Run: sudo rtl_433 -A and then activate the doorbell.

In my case, the output was as follows:

Full output of doorbell signal

The important line is:

Flex decoder specification

Save this line for later.

Setting up Home Assistant & MQTT

It might be possible to do this by plugging the SDR into the device running Home Assistant, to simplify this step but I am running Home Assistant as a virtual machine running under Hyper-V which does not have USB pass-through.

I’m not going to go through the full steps for setting up Home Assistant, as they are documented very well elsewhere.

Once you have the basics setup, you’ll need to install the Mosquitto broker add-on through the supervisor menu, this allows home assistant to listen to MQTT messages on the network. You’ll then need to add the MQTT integration. If you are using the built in mosquitto broker, then the configuration of this is very simple. Finally you’ll need to create an account for MQTT logins. This doesn’t need to be an administrator, just a standard user.

Putting it all together

I have configured a system service on my Pi so rtl_433 starts on boot, and restarts on failure. The service calls a single line script which is as follows:

rtl_433 -R 0 -X ‘n=doorbell,m=OOK_PWM,s=352,l=692,r=5296,g=696,t=136,y=0’ -F “mqtt://<Home Assistant IP>:1883,user=<username>,pass=<password>”

Breaking this down:

When running the command, you should see that it successfully makes an MQTT connection:

MQTT connection established

Once this is running, head back to Home Assistant, to into the MQTT integration and click “configure”. This will allow you to run an MQTT listener.

Initially start listening to all messages using the wildcard character #

MQTT listener running

This will output all messages which should initially just be the connection details from the Pi into Home Assistant. Pressing the doorbell will generate additional traffic, including message codes. These message codes are unique and what we will monitor for in Home Assistant.

We need to create a binary sensor in configuration.yaml:

binary_sensor:
## Doorbell
    - platform: mqtt
      state_topic: "rtl_433/raspberrypi/devices/doorbell/codes/#"
      payload_on: "{13}98e8"
      off_delay: 5
      name: Doorbell

The bit which will need changing is the “payload on” code – this should be taken from the listener above.

Once the file has been updated, save and restart Home Assistant. This will create a binary sensor which changes to “on” for 5 seconds when the doorbell is pressed.

The next step is to use the sensor to generate alerts. I have setup two forms of alerts:

  1. An alert on my Android phone (through the Home Assistant app)
  2. Google homes playing a doorbell sound.

My automation looks like the following:

alias: Doorbell
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.doorbell
    to: 'on'
condition: []
action:
  - service: media_player.volume_set
    target:
      device_id:
        - Google Home 1
        - Google Home 2
    data:
      volume_level: 0.75
  - service: media_player.play_media
    data:
      media_content_type: audio/mp3
      media_content_id: 'URL of MP3'
    target:
      entity_id:
        - media_player.kitchen_speaker
        - media_player.office_speaker
  - service: notify.mobile_app_phone_name
    data:
      data:
        tag: doorbell
        ttl: 0
        priority: high
      message: Doorbell
  - wait_template: ''
    timeout: '00:00:10'
    continue_on_timeout: true
  - service: media_player.volume_set
    data:
      volume_level: 0.25
    target:
      device_id:
        - Google Home 1
        - Google Home 2
mode: single

Breaking this down, the trigger is the state of the sensor changing from ‘off’ to ‘on’

The actions in order are:

  1. Set the volume on my google home speakers to 75%
  2. Play the MP3 stored at the URL provided
  3. Pop up an android notification
  4. Wait 10 seconds
  5. Set google home speakers volume to 25%

Further Work / Improvements

There are a few areas where I think this setup could be improved:

  1. rtl_433 is resource intensive on my Raspberry Pi, I have done some basic reading that there may be a better way to compile it in a more optimised way
  2. The Google Home notification stops any music currently playing, and doesn’t restart it. I would prefer to play the notification and then resume whatever was playing in the background, at the previous volume.

Thanks for reading, I hope this has been useful! If you have any comments, suggestions for improvements to this setup please leave a comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *