[UniFi Protect] Protect Unleashed Episode II | Unifi Doorbell to Sonos Text to Speech announcement

Have you ever wonder why your Unifi Protect product does not have Alexa, Homekit or Google Assistant support? May be you wish UniFi Protect device can do something else. You may be in luck with Home Automation platform, like Home Assistant. In this part II of the protect unleashed series, I will be sharing how I got my Unifi Doorbell ring trigger Sonos speaker text to speech announcement using Home Assistant.

History:
– 4/20/2021: Added comment about google_translate_say.

Prerequisite

What do you need?

  • UniFi Doorbell
  • Sonos Speakers
  • Home Assistant Hub with
    • UniFi Protect Integration
    • Sonos Integration

In this article, you will learn:

Add Sonos Integration to Home Assistant

On Home Assistant > Configuration > Integrations > SONOS > Configure

Sonos addition was the simplest integration installation. I just hit Configure button and it detected 3 Sonos speakers in my home. One of which is setup as 5.1 system so it did not separate surround speakers or bass but rather showed up as a single speaker entity. For my future organization, I just changed area where each speakers are located, which you can do afterwards. I just then hit submit and all speakers were ready to go.

Creating Unifi Doorbell Ring to Sonos TTS Automation

Now, you are ready to make UniFi Protect genius.

Configuration > Automations > Add new Automation

Here you put a name of Automation. A little trick here is to use Emoji at the beginning as suggested by a reddit user. This will help when you start creating many automations since currently there is no official organization system for automations right now.

Trigger section is where you define what triggers/starts this automation. In this particular case, you want to trigger based on Unifi Doorbell push.

Trigger Type: Device
Device: Select [Doorbell Name] In above example, Unifi Doorbell is the name of the doorbell.
Trigger: [Doorbell Name] became occupied
*You might be looking for Doorbell is pushed, but there is no such entry. “became occupied” is indeed what triggers when Unifi Doorbell is pushed.
Duration: 00:00:00

I have not set any condition here, but you may want to prevent doorbell ring announcement after certain time. If so, this is where you put that.

Action specifies what to do when this automation executes. In this case, play a Text to Speech (TTS) on Sonos speaker(s).

This can be done by setting Action type to Call Service then choose a service either tts.cloud_say or tts.google_translate_say.

tts cloud_say is for Nabu Casa subscribed users so you will not see the option if you are not logged into the Nabu Casa. In which case, you can use google_translate_say. Cloud say provides more natural sound. Below is the setup using google_translate version of TTS, basically it is identical except for the service.

So in the end you will have one action entry per speaker as following.

Action type: Call  service
Service: tts cloud_say or google_translate_say*
Entity: [Choose one of Sonos Speaker]
Message: Type in text of what you want the speaker to say e.g. Someone is at the door.
Cache: Check

Turn on Cache

Cache here is a cool feature. TTS uses online cloud access but if you were to use that every time, it will have the cloud latency and when internet is not working the doorbell stops working, which is a major issue. Cache will basically access the cloud for the first time and reminder will be locally processed so it becomes really fast after the first ring.

I have duplicated above action for each of my speaker. To do this, you can click […] and hit duplicate.

You just need to change entity to each Sonos speaker.

Performance Check

This works phenomenally well. Below is a quick, subjective test.

I basically have zero issue with speed/performance here.

Initially, I had disconnection of Door bell ring trigger (as well as motion trigger) on Unifi Doorbell, which happened only on NUC10i7 Virtual Machine based Home Assistant OS Setup. This was not an issue with Rasberry Pi 3B version of Home Assistant. However, the similar issue was noted with Homebridge when it was running on the docker. After the recent upgrade of UniFi Dream Machine to 1.9.4 version, I no longer have this issue and the system is running solidly for a week so the issue must have been on the UniFi side.

1 Comment

  1. Thanks for writing this guide, it’s awesome and exactly what I was trying to accomplish, so you saved me a lot of hassle figuring it out for myself. A couple things I found:

    The service is no longer called tts.cloud_say, it is tts.google_translate_say

    The audio on my Sonos is a bit low by default so I had to add another action before it that specifies media_player.volume_set with a volume_level of 0.6.

    I’m now going to try and figure out if it can play a dingdong wav file.

Comments are closed.