Note– Amazon Alexa now requires 2FA App Integration. This tutorial is accurate at the time of authoring (January 2024). If you have Google powered voice assistants, this post could be applied to Google NEST by using Onju Voice
My humble doorbell has been a journey, yes it still rings a traditional doorbell chime (16V AC) but has gone through many incarnations. Pressing my doorbell is digital input to which I can act upon. The output of pressing my doorbell includes lighting, security (electric strike) to more (you will need to wait to part 2).
Smart homes and our lives generate events, sometime these events are okay as a passive notification, but sometimes you need to know about them instantly.
In the past I have solved this with many ways. It started with SMS messages (Clickatell, Amazon SNS) before moving towards Home Assistant push notifications.
If you have Amazon Alexa devices in your house, did you know there is an un-official API that allows you to send TTS (Text-To-Speech) events to a given Alexa?
Whilst I have your attention, let’s see how this works end-2-end before moving forward on how I integrated my regular doorbell chime with Amazon Alexa using TTS via the Alexa API.
My house has an abundance of Alexa devices, and I am using Alexa as a means to push messages of utmost importance.
In this part 1 of this multipart series, I will illustrate how to
- Wire in a ELK930 Doorbell module for integration with a MCU
- Install the ‘Alexa Media Player’ integration into Home Assistant
- Create an Amazon Alexa App with 2FA (Two Factor Authentication)
- Demonstrate TTS into an Alexa Device
- Create a Home Assistant Automation (MQTT Event –> Alexa TTS)
Doorbell Detection
First things first, we need to detect when somebody rings the doorbell. I am using a standard electric chime, nothing special, which is also good because it means choice and standardisation.
I use an ELK-930 Doorbell detector that runs in series to the 16v AC doorbell chime (as per the wiring diagram). You could build your own with a DPST (Dual Pole Single Throw) relay. The result of ringing the doorbell in my house, other than the internal chime making a noise is I am able to detect this on the connected MCU (Microcontroller Unit). As I can detect the doorbell being rung, I can turn this in to a MQTT message, and with this MQTT message Home Assistant can do ‘things’ based on MQTT messages.
Installing the Alex Media Player Integration
At the time of writing this post Alexa Media Player is a Home Assistant custom component, the easiest way to install Alexa Media Player is to use HACS (Home Assistant Community Store). This post is not a guide on how to install this plugin, I suggest you follow this installation guide by the creator Alan Tse on GitHub
You will need to create an Alexa App with 2FA and the summary of Alan’s guide is as folllows
- Go to Amazon.com’s 2FA page and
Add new App
. You should save this key so you can reuse it if you reinstall. - Instead of scanning the QR code, select
Can't scan the barcode
. - Select the bolded value under
Enter your Key
(e.g.,35T5 LQSY I5IO 3EFQ LGAJ I6YB JWBY JJPR PYT7 XPPW IDAK SQBJ CVXA
)(Remove spaces) - Enter the value from Step 3 in the
Built-in 2FA App Key
when adding the integration. 2FA should be automatically generated from now on and can be left blank.
The other very important thing worth noting, when you sign in with your Amazon account, ensure you use the correct amazon domain for Alexa. This caught me out, Alexa is regional. I signed in to amazon.com, but nothing was working. It wasn’t until I was signing in with amazon.com.au did my devices start to function.
After configuring Alexa Media Player all of your Alexa devices will appear in the integration, and each device will have a subset of entities such DND, Volume, Song Title, Alarms and so-on, this will be dependent on the model of your device.
Testing TTS From Home Assistant To Alexa
After Alexa Media Player has been configured, the next logical step is to test if we can inject a message into Alexa. This can be done to a specific device or to ‘everywhere’.
In Home Assistant, go to ‘Developer Tools
‘, ‘Services
‘ and select ‘Notifications: Send a notification via alexa
‘. This will auto complete to a specific device of your choosing or ‘everywhere’.
In the ‘Message
‘ field, enter in the text you wish to send, I used in the image below “Hello readers of this blog
“. Leave the ‘Title
‘ and ‘Target
‘ fields blank and in the ‘Data
‘ field enter in “type: tts
“
Then select ‘Call Service
‘. If this description is not clear, see the images below.
You should now hear your Alexa device speak with the message you entered.
Home Assistant Automation
As this has been connected up, what could you dream up. Let’s walk through an example.
Using a Home Assistant automation, we can create a very simple TTS injection to Alexa. In my example I am going to target specific Alexa devices. Our house has Alexa devices in every bedroom, select living areas and in the garage and shed, it’s not appropriate to always message every device. Between 9 AM and 7 PM I will send messages to every Alexa, but outside of those hours it is just two devices.
This YAML illustrates a MQTT trigger, conditional actions based on time.
alias: DoorBell --> Alexa
description: >-
Doorbell --> EL930 --> HVXL --> MQTT --> HA --> Alexa Media Player --> Alexa
(Kitchen, Shed)
trigger:
- platform: mqtt
topic: stat/INPUT_ELK930_DoorBell/POWER
payload: low
condition: []
action:
- if:
- condition: time
after: "09:00:00"
before: "19:00:00"
weekday:
- sun
- mon
- tue
- wed
- thu
- fri
- sat
then:
- service: notify.alexa_media_everywhere
data:
data:
type: tts
message: Ding Dong, someone rang the door bell
else:
- service: notify.alexa_media_shane_s_echo
data:
data:
type: tts
message: Ding Dong, someone rang the door bell
- service: notify.alexa_media_kitchen
data:
data:
type: tts
message: Ding Dong, someone rang the door bell
mode: single
Summary
How simple was this? If you have an Arduino or similar MCU floating about and along with Home Assistant, you can take that normal doorbell and add some smarts without paying a subscription to RING or similar. This was a basic first step and I hope it illustrated how you can detect doorbell events, how you can take action and that Alexa has a rich API that has TTS injection capabilities.
Has this inspired you to think of applications for your doorbell or perhaps Alexa in your house?
Stay creative and I will see you in future blog posts where we take what we take this to the next level.
Thanks
Shane Baldacchino
2 thoughts on “Building My Super DoorBell – Part 1 Integrating Home Assistant Notifications via Amazon Alexa with TTS and Alexa Media Player”