Table of Contents
Alexa and Home Assistant
I always wanted to integrate my Alexa and Home Assistant the right way, but until now my success was partial.
I hope that this time it will be different, because the method I found mimics the Official Alexa App and in my opinion it has a very good chance to stick around for more than a minute.
In this video I will show you how to integrate Alexa and Home Assistant, so you can:
- Send notifications including text-to-speech, announcements and different sound effects.
- Play on demand sequence commands like commute, news, weather and others
- Control Alexa devices as media player through Home Assistant with enabled TTS field.
I have a very important message for you later in the article, so you better read this till the end.
Installing the Alexa Media Player
Alexa Media Player is the the integration that we need to install in order to proceed further. You can either install it manually or using HACS (Home Assistant Community Store).
If you don’t have HACS, this is not an issue, just check this tutorial first and then come back here.
Now open your Home Assistant, tap on HACS and search for “Alexa Media Player”
Click on the “Alexa Media Player” result and tap on “INSTALL”.
Then go to your Home Assistant “Configuration” menu and find the “Integration” tab. Click on the BIG orange button in the lower right corner and search again for “Alexa Media Player” and click on it and.
You should see the following dialog where you need to enter your Amazon credentials.
You will be greeted by Captcha window after that and you have to guess it. I don’t know about you, but most of the time I’m unable to guess the Captcha from the first time 😭.
And finally if you see this dialog, that means everything is OK and you can continue.
Testing the Alexa Media Player
Now you probably can ask what I can do with all of this? Stick with me and I will show you how to use Alexa and Home Assistant.
TTS (Text-To-Speech)
The first test will be to make our Alexa (Amazon Smart Speaker of any kind) to speak what we want to.
Just go to Developer tools -> SERVICES and choose notify.alexa_media service
In the “Service Data” field paste the following:
message: Hello dear friends from around the World!,
data:
type: tts
target: media_player.CHANGE_ME_TO_YOUR_DEVICE
Don’t forget to change the “CHANGE_ME_TO_YOUR_DEVICE” with you device and then you can click on “CALL SERVICE” button.
If you hear the text in the message: variable from your Alexa – you are in the TTS game.
Announcements and Whispering
The differences between announcements and normal TTS are:
- There is always a ding dong sound before the announcements.
- Only in announcements you can use SSML markup to add effects to your speech (actually Alexa speech).
To test an whispering announcement just change the text in the “Service Data” field with this one:
{
"message":"<amazon:effect name='whispered'>I am whispering this.</amazon:effect>",
"data":{"type":"announce", "method":"speak"},
"target":["media_player.CHANGE_ME_TO_YOUR_DEVICE"]
}
And again can click on “CALL SERVICE” button.
Sequence commands
Sequence commands are predefined in Alexa and they are usually triggered by voice to tell the user some info about the weather, commute, news, jokes, etc.
To test this you have to choose media_player.play_media under service in SERVICE tab which is available in the Developer menu of Home Assistant.
Paste the following to hear a random Joke from your Alexa.
{
"entity_id": "media_player.CHANGE_ME_TO_YOUR_DEVICE",
"media_content_id": "Alexa.Joke.Play",
"media_content_type": "sequence"
}
The full list of the available sequence commands can be found here – link.
To test them just replace the “Alexa.Joke.Play” in the example above with something from the Sequence commands link.
Sound Effects
While you are still on the media_player.play_media under service in SERVICE tab, just change the text in the “Service Data” text box with the following:
{
"entity_id": "media_player.CHANGE_ME_TO_YOUR_DEVICE",
"media_content_id": "amzn_sfx_doorbell_chime_01",
"media_content_type": "sound"
}
When you hit the “CALL SERVICE” button you should hear a door 🔔 sound (ding dong). Additional sounds to test can be found here – link.
To hear different sound from your Alexa just like the Sequence commands you should replace the “amzn_sfx_doorbell_chime_01” with “fire_extinguisher_01” for example.
Of course you can choose whatever you like from the Alexa Skills Kit Sound Library.
Automations, Scripts and Templates
All of these TTS, Announcements, Sequence Commands and Sound effects can be embedded and used in Home Assistant Automations, Scripts and Templates to make your Smart Home full of voice and sounds.
A lot of ready to use examples are available in the Alexa Media Player documentation – link
I can’t wait to find some time and start experimenting with all of this Alexa and Home Assistant stuff.
I will also be very thankful if you find something very cool/useful and share it in the comments section below. I promise I will do the same here.
Mini Media Player
This the desert of this article. We will add a media player in the Home Assistant dashboard that can control Alexa and it has enabled TTS (Text-To-Speech) field.
To do that just search and install “Mini Media Player” from you HACS menu under Plugins tab.
After the successful installation of the Mini Media Player plugin.
Don’t forget to click on the “Add to Lovelace” button.
To visualise a Mini Media Player card in your Home Assistant Lovelace Dashboard you need to click on the three dots in the upper right corner of your Home Assistant, and you have to choose “Configure UI” button.
Then scroll down on the adding card dialog and choose “Manual”
Add the following text inside the “Manual” card and don’t forget to change the entity and entity_id with yours in order everything to work as expected.
type: 'custom:mini-media-player'
artwork: full-cover
entity: media_player.CHANGE_ME_TO_YOUR_DEVICE
icon: 'mdi:amazon'
tts:
platform: alexa
enity_id: media_player.CHANGE_ME_TO_YOUR_DEVICE
You have to see something similar (actually exactly the same if you didn’t change anything else except the entity)
When you click “SEND” button you should hear your Alexa device saying the text entered in the text box.
The important Message
This Smart Home, IoT and Home Automation stuff is really hard and it is constantly changing and evolving (the real example is this Alexa and Home Assistant integration).
I cannot keep up lately, so I decided to change the focus of this blog from Smart Home tutorials to Birds Watching tutorials.
And I will give you my biggest reason why Birds Watching is better than Smart Home. It is actually very simple – no new birds are invented these days.
Please expect that my next video to be for pigeons as one of the most popular birds on the planet.
I got you! Happy April’s Fool day. I hope that you like my joke and you didn’t hit the close button during my last few sentences.
I will continue with the Smart Home tutorials and I will postpone the birding for now.
Question for You!
Did you believe my Aprils Fool joke about the birds watching?
You can say simple “yes” or “no” in the comments and I will know for what are you talking about.
One more thing
If you happen to be a Node-RED guy and you don’t want to mess around with Home Assistant for some reason. Check my other tutorial about Alexa, Node-RED and TTS.
Support my Work
Any sort of engagement on this channel does really help out a lot with the YouTube algorithm, so make sure you hit the Subscribe If you enjoy this article.
Also feel free to add me on Twitter by searching for @KPeyanski.
I really hope that you find this information useful and you now know how to control and use your Alexa and Home Assistant.
Thank you for watching/reading, stay safe and see you next time.
Perfect i configure now my echo dot in HA
Grande !!
Saluti dall’ Italia
Great to hear that, let me know if you happen to have any issues! Greetings to Italia.
The sounds code doesn’t work? The service gets called but nothing actually happens?
That is strange, What about other stuff like sequences, TTS, etc are they working? Can you share a snippet of yourvconfig either here or at my discord server?
Weirdly, the example one does work if you put the type (sound) up to the middle line.
But the link to the sound library, every single one of those that I’ve tried haven’t worked.
I haven’t added anything to my config yet, just trying things out under the call service tab.
There are only a few sounds that work.
https://github.com/custom-components/alexa_media_player/wiki#known-available-sounds-
The sounds listed under “https://github.com/custom-components/alexa_media_player/wiki#known-available-sounds” seem to work.
What’s really weird is that amzn_sfx_trumpet_bugle_04 works but not amzn_sfx_trumpet_bugle_03, which is in the same soundlibrary path.
Hey Robert! Thanks for that series of useful tests that you perform about the sounds. They will surely help the others.
No problem. It’s very strange that only certain sounds work. I thought I’d figured out the pattern but I’m still confused.
I guest that not everything is supported by this integration that’s all.
I can’t get any sound to play other than amzn_sfx_doorbell_chime_01. I’ve tried a few listed in the Skills kit. Any suggestions?
It seems to work with any sound in the “home” path, but no others:
Looks like only the “Alarms/Chimes_and_Bells” category works.
Nope! Only the doorbells, which are in /home/ :
audio src=”soundbank://soundlibrary/home/amzn_sfx_doorbell_chime_02″
Many thanks kiril! works great!
I have just 1 little problem – I can’t contrl echo dot volume…
the volume bar appear but i cant control it and the speaker icon on mute.
can you tell why?
Hi,
I cannot seem to get my alexa to TTS the message?
I have followed the instructions perfectly? Do I need the cloud integration?
anything in the logs?
Awesome blog.Really thank you!
Hello Kiril
i have make a new installation of Home Assistant
and i have issue with installation of Alexa from Hacs
i put user and password but the add tell me that’s incorrect.
i don’t see captcha too
Amazon block this add ?
Is there any reason why alexa can’t reproduce all the sound effects?
on an old installation of home assistant I set up alexa media player but had to do it to manual way. I’m sure that if I set a timer on an alexa it showed it on the player on home assistant. I have since reinstalled my system as hass.io and used hacs to install the alexa media player but it doesn’t show the timers.
Since yesterday I receive the following error message:
“Failed to call service media_player/play_media.play_music() got an unexpected kexword argument ‘extra’
When I call the service like this:
{
“entity_id”: “media_player.CHANGE_ME_TO_YOUR_DEVICE”,
“media_content_id”: “amzn_sfx_doorbell_chime_01”,
“media_content_type”: “sound”
}
Any ideas?
reported here:
https://github.com/custom-components/alexa_media_player/issues/957
Did you update something? And you did the right thing with the GitHub issue. Hope that it will be fixed soon
I just wanted to say thank you for making this post, i’ve been racking my brain for a few months trying to get the Alexa Media player working again after it just quit working one day after many months of working great. Anyway, thanks again!
Colby
Glad that I could help. You can check my other Home Assistant articles as well!
does this solution use this media player setup? https://community.home-assistant.io/t/echo-devices-alexa-as-media-player-testers-needed/58639/4497
My version of Home Assistant looks nothing like yours. HACS now on has Integrations and Frontend. I have found the mini-media-player on github but just cannot get HA to install it. I have added the .js file to my /config/www directory but no luck. Any ideas?
Try test the Alexa integration from Developer tools to see if it is working. I didn’t test the Mini media player recently so it may have some issues.
It’s in Frontend https://i.imgur.com/3H45VPH.png
Thanks for the comment, Anon!
Thank you so much for your tutorials! I finally got Alexa integration up and running with the help of your YouTube video and this article. I have a question though, is there a way to group Echo devices in Home Assistant and then send a notification that goes out to the group instead of creating an action for each one? I’m not talking about all of my echo devices, just 4 of them. I’ve tried creating a group in my configuration.yaml, but can’t get it to show up in my notify.alexa_media list. Do you have any suggestions? Thanks again!
Hi Debbie, thanks for thanking me 🙂 About the grouping I’m afraid I can’t help much as I have only one Alexa in my house and just got my second one (which is still in the box, cause I will make a video about it) I quickly check the documentation and I only found this statement – https://github.com/custom-components/alexa_media_player/wiki#play-in-alexa-groups Hope it helps. See you around!
Thank you for the tip! I’ll give it a try and let you know if it works.
What happen to alexa media player in hacs? I don’t see it.
Several other people reported this. I have to double check on my site is it still visible. Maybe it’s gone.
I’m still fairly new at this, but I ran across the same thing and I had to enable Home Assistant Community Addons. https://addons.community/
[2800618056] Error handling message: expected a dictionary for dictionary value @ data[‘target’]. Got ‘media_player.white’
service: notify.alexa_media
message: Hello dear friends from around the World!,
data:
type: tts
target: media_player.echo
I get that error message whaen I call service.
Any ideas?
Same, used to work but stopped recently and now I get this error message
Hey Dr. Strange, I had the same issue, (also had some authentication failure on Alexa integration and struggled to get it to re-connect) – so I rolled back to a previous restore point from 3 weeks ago.
That fixed my issue.
I have now just upgraded to latest version oh HA and so far, everrthing is working OK.
I have an issue with the mobile app on iPhone not displaying the mini media card. It works great on the web app but not on the iPhone app.
I don’t know how I can help you with that. Maybe someone else can jump in.
I am having issues getting tts to work. I removed the integration and went through your steps again. and now I get a Fail to call service notify.alexa_media_xxxxxx. Unknown error. On the previous integration i would at least get an error from the Alexa device. Any help would be appreciated.