Playing UniFi G4 Doorbell Chime through Sonos with Home Assistant
In February 2020 I made a big upgrade to the network at my house. While there isn't a lot of high bandwidth usage happening here I have been working from home since 2014 and due to the pandemic my wife had also been working from home. WiFi coverage had always been spotty and unreliable. We also had a few Ring products throughout the house including their Video Doorbell Pro and chime. Once I made the decision to upgrade I went all in on Ubiquiti's UniFi line of products for both networking and video security replacing all the networking and Ring devices in the house.
After a few days of running new ethernet drops, installing equipment, and getting things configured I was left with a setup I was happy with but there was one issue. Since we didn't have a traditional wired doorbell chime, we had no way of being alerted of someone pressing the button on the G4 doorbell other than receiving a notification on our phones. Ideally, like a traditional doorbell, we'd hear some audible notification in the house.
I set out to find a solution to this. I thought through and tried a few options but it turned out I didn't need to try or purchase anything else as I already had what I needed to accomplish what I was looking for.
This was always going to be my backup solution but I really didn't want to do it as it would require me to buy and wire in a traditional doorbell transformer and chime. With the current state of IoT devices and services I knew there had to be another way so I was reluctant to settle on this option for as long as it could.
While searching for wireless solutions I came across some people using these two products from Honeywell.
To get this working you have to wire your doorbell's power wires into the Doorbell Adapter then wirelessly link the adapter to the chime speaker. The installation and setup were pretty straight forward and you're able to upload any mp3 you want to the speaker via USB. However, for whatever reason, I found this setup to be very unreliable. Some of the issues I encountered over the couple weeks of using this setup ranged from:
- No sound being played when the doorbell button is pressed
- A very long delay between the doorbell button being pressed and the sound being played
- The sound being played on repeat at random times during the day (and middle of the night) without the doorbell button being pressed
After a couple instances of having to get out of bed in the middle of the night to pull the batteries from the speaker I decided to return both products and go back to the drawing board.
At some point between returning the Honeywell devices and continuing my search on Google for another solution I was fiddling around in Home Assistant and had a realization that I may be able to pull this off with my current setup. After some more searching and tinkering I was able to get the UniFi doorbell chime to play through one of my Sonos speakers when the doorbell button was pressed. The following steps are specific to the UniFi Protect G4 Doorbell and a Sonos speaker but this theoretically could work with any doorbell/button and speaker that is connected to Home Assistant.
You can use any mp3 file you want. In my case, I wanted to use the chime that plays on the G4 doorbell when the button is pressed. Unfortunately Ubiquiti doesn't make these files publicly available. However they do allow you to upload your own chimes to the doorbell (community.ui.com + reddit.com/r/Ubiquiti). While I was poking around on the device I found all the default sound files, downloaded them to my computer, then uploaded them to a public repo on GitHub which you can find here.
Again, I chose to use the native chime from the doorbell to play in the house.
Follow the directions for each of the Sonos and UniFi Protect integrations to get them configured in Home Assistant. I didn't run into any issues with either of these and I've been quite satisfied with their reliability.
There's a couple ways to do this. The easiest way is to install the official File Editor add-on. Other options include SFTP and
Install File Editor by following these instructions.
Once installed, click the "File Editor" link in the left hand navigation.
- Scroll down and select the
wwwdirectory and then click the up arrow icon to bring up the "Upload File" modal.
From there find the file on your computer to upload and upload it.
Get the local URL for the file by concatenating the URL for your Home Assistant instance,
local/, and the filename of the file you uploaded.
In my case the URL parts look like this:
You can test that it works by loading it up into your browser.
The following instructions are for creating a new automation in the visual editor. If you want to create the automation in code I've included automation in YAML format below.
In Home Assistant create a new Automation by logging in to your instance and clicking "Configuration" then "Automations". Once on the Automations page, click the "Add Automation" button in the bottom left then select "Start with an empty automation".
I named my automation
Play chime on Sonos when doorbell is pressed.
You'll need a single "Trigger" which is activated when the doorbell button is pressed. The values I've used are below. Simply, we're triggering the automation when the state of the doorbell is set to "on".
UPDATE: Thanks to Reddit users u/Eriner_ and u/pie_faced_avitar for both suggesting to use the
sonos.restore services to pause and resume whatever may be playing when the doorbell chime is played.
Create a snapshot of what is currently playing on all Sonos speakers.
Set the volume of the speaker that is going to play the doorbell chime.
Select the speaker from the
Play the doorbell chime on one or many Sonos speakers.
Select the same entity as above.
This is the URL we established by uploading the audio file in step 3.
Wait 4 seconds (the length of the audio file) for the doorbell chime to play.
|hh mm ss ms|
Restore all Sonos speakers back to what they were doing before chime was played.
As mentioned above here is the automation in YAML format.
alias: Play chime on Sonos when doorbell is presseddescription: ''trigger:- platform: stateentity_id: binary_sensor.doorbell_front_doorto: 'on'condition: action:- service: sonos.snapshotdata:entity_id: all- service: media_player.volume_settarget:entity_id:- media_player.living_roomdata:volume_level: 0.65- service: media_player.play_mediatarget:entity_id:- media_player.living_roomdata:media_content_type: musicmedia_content_id: http://192.168.20.121:8123/local/sounds_sounds_ring_button_Chime.mp3- delay:hours: 0minutes: 0seconds: 4milliseconds: 0- service: sonos.restoredata:entity_id: allmode: single
Save your automation then go test it out! Here's a quick video my wife and I recorded to showcase how responsive the automation is. There is a less than a second delay between the doorbell being pressed and the audio playing on the Sonos speaker in my house.
Overall I'm super happy with how this turned out as I didn't have to add anything new to my current setup and it leaves me with some flexibility for the future. If you have any questions feel free to shoot me an email at johnzanussi [at] gmail.com.
Found the above useful? Have a question? Thought of something I didn't?
Consider buying me a coffee, leaving a comment below, or sending an email at firstname.lastname@example.org.