Alert This post is over a year old, some of this information may be out of date.

Ringing the doorbell on your Sonos speakers

Ringing your doorbell on your Sonos speakers

Ding dong!!! Earlier this week, I changed my old doorbell to the Eufy video doorbell. When it arrived and wanted to install it, I found out that my current wiring with the intercom system was not supported. Luckily the doorbell has a battery, so instead of running on power coming from the old wires, it will run on the battery for six months.

Info: I also use the security cameras (first version). They stated that the battery lasts for one year, and the current cameras are still running on their first charge for more than a year.

Back to the doorbell, as I could not use my existing wiring, that also meant that I could not use my indoor chimes. Of course, this doorbell comes with a chime/home base station and notifications.

The chime/doorbell issue

As I am living in a house, the chime does not reach very far.

Like the Ring and Nest doorbell, Eufy also supports Alexa. With Alexa enabled, you can announce on your Echo devices when somebody rings the doorbell.

For other Alexa enabled devices, Amazon suggests creating routines as I have a couple of Sonos speakers in the house (which are all Alexa enabled). I found out that Sonos has not yet implemented support for routines.

There goes my solution to playing a doorbell sound on my speakers. When I searched on the internet for the options, the only thing I could find was either use IFTTT or a custom Alexa Skill.

IFTTT has a Sonos connector in beta, but the problem is that it does only one action. Like starting to play, pause, … For a doorbell, this would work. When somebody rings, play the doorbell sound.

Sonos connector for IFTTT
Sonos connector for IFTTT

The play stream action can be used for it and worked on the first try. BUT, the problem is that it kept playing the doorbell sound on all speakers. So quickly turned this off again.

I also thought about the custom Alexa skill, but that would involve a lot more work.

The DIY approach

The do-it-yourself approach is always better, as whit this approach, you can create how you want it.

I went for the following solutions:

  • Create an API running on my Raspberry PI, which allows me to play the doorbell sound on my speakers.
  • Use ngrok to make the API available to create a tunnel to the API endpoint.
  • Use Alexa in combination with IFTTT to call the API endpoint.

This solution took me one hour to create. Like I mentioned before, DIY means that you can make it the way you want it to work. In my case, when somebody rings my doorbell, the API will check if I am in a meeting. When that is the case, my office speakers will not play the doorbell sound (I still get the notification on my phone, so that is enough).

Playing doorbell sound on all speakers
Playing doorbell sound on all speakers

The code

You can check out the project here: https://github.com/estruyf/sonos-doorbell-api. I removed the logic to check if I am in a meeting, as that does a call to my Busy Light Raspberry Pi.

Installation and configuration

To get started, you first have to clone the repository to your device. I am running this on one of my Raspberry Pi’s. You can find more information to start up the API in the GitHub repository.

Info: An excellent way to keep the API running is to use PM2. This tool makes sure your API keeps running.

When the API is running, you will only be able to call it from within your local network. In some cases, this might be enough. The only option was to trigger it from Alexa, which meant that I had to make it publicly available.

An excellent tool for this is ngrok. This tool allows you to create a tunnel for the website/API from the localhost you want to expose.

I made use of the following ngrok service approach so that it always starts-up automatically when my Raspberry Pi reboots: https://github.com/vincenthsu/systemd-ngrok.

My ngrok.yml file for the service looks like this:

1
2
3
4
5
6
7
8
authtoken: <ngrok-auth-token>
tunnels:
  sonos-http:
    proto: http
    addr: 5050
    bind_tls: true
    region: eu
    auth: "<username>:<password>"

Once the service is running, it will create a forwarding URL like https://<id>.ngrok.io.

Important: If you use the free plan, this endpoint will always change. When you sign up, you can quickly check the latest tunnel endpoint on the ngrok dashboard.

Setting things up on IFTTT

Once the API and ngrok are up and running, it is time for the configuration on IFTTT.

IFTTT applet for ringing the doorbell
IFTTT applet for ringing the doorbell

Start by creating a new applet. For the this option, pick Alexa. To make it work with an Alexa routine, take the Say a specific phrase trigger and specify a phrase like: “ring my doorbell ding ding ding”.

Alexa doorbell phrase
Alexa doorbell phrase

For the that option, pick the webhook action. This action allows you to create a web request.

Web request to your Sonos doorbell API
Web request to your Sonos doorbell API

Important: As I configured basic authentication for ngrok. I need to specify the username and password in the API call.

Finish the applet
Finish the applet

When you created the applet, it is time to configure your Alexa routine.

Create an Alexa routine for your doorbell

On the Alexa app, go to routines and create a new one. Choose on when this routine has to start up. For me, this is when my doorbell gets pressed.

The action which I want the routine to perform is to start the IFTTT applet.

When you linked Alexa with IFTTT, you should see the phrase you inserted when configuring your IFTTT applet.

Alexa doorbell routine
Alexa doorbell routine

Save this routine, and that is it. Go and press your doorbell.

Ding dong

Comments

Back to top