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.

Alexa and Home Assistant – TTS, Media Player, Announcements, Sound Effects, Sequence Commands (2020)

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.

Searching fro Alexa Media Player in HACS

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.

Alexa and Home Assistant integration the right way

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 😭.

Successful adding Alexa Media Player to Home Assistant

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.

Alexa and Home Assistant - TTS, Media Player, Announcements, Sound Effects, Sequence Commands 1

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"]
}
Calling the notify.alexa_media service in order to hear whispering announcement.

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.

Sequence command in Home Assistant Developer Tools that will make Alexa to tell a joke

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.

Alexa and Home Assistant - TTS, Media Player, Announcements, Sound Effects, Sequence Commands 2

After the successful installation of the Mini Media Player plugin.

Alexa and Home Assistant - TTS, Media Player, Announcements, Sound Effects, Sequence Commands 3

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.

adding manual card on home assistant dashboard

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)

Mini Media Player with enabled TTS field and custom Amazon icon
Mini Media Player with enabled TTS field and custom Amazon icon

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.


43 Comments

Rosario · 03/04/2020 at 2:12 pm

Perfect i configure now my echo dot in HA
Grande !!
Saluti dall’ Italia

    Kiril Peyanski · 03/04/2020 at 2:22 pm

    Great to hear that, let me know if you happen to have any issues! Greetings to Italia.

Pete · 06/04/2020 at 1:11 am

The sounds code doesn’t work? The service gets called but nothing actually happens?

    Kiril Peyanski · 06/04/2020 at 9:26 am

    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?

    Robert Cipriani · 18/04/2020 at 4:37 am

    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.

      KIril Peyanski · 18/04/2020 at 2:00 pm

      Hey Robert! Thanks for that series of useful tests that you perform about the sounds. They will surely help the others.

        Robert Cipriani · 18/04/2020 at 7:20 pm

        No problem. It’s very strange that only certain sounds work. I thought I’d figured out the pattern but I’m still confused.

          Kiril Peyanski · 19/04/2020 at 7:24 pm

          I guest that not everything is supported by this integration that’s all.

Robert Cipriani · 18/04/2020 at 3:20 am

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?

    Robert Cipriani · 18/04/2020 at 4:06 am

    It seems to work with any sound in the “home” path, but no others:

      Robert Cipriani · 18/04/2020 at 4:11 am

      Looks like only the “Alarms/Chimes_and_Bells” category works.

        Robert Cipriani · 18/04/2020 at 4:13 am

        Nope! Only the doorbells, which are in /home/ :

        audio src=”soundbank://soundlibrary/home/amzn_sfx_doorbell_chime_02″

Dror · 06/05/2020 at 10:37 am

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?

Rahul · 09/06/2020 at 1:44 am

Hi,

I cannot seem to get my alexa to TTS the message?

I have followed the instructions perfectly? Do I need the cloud integration?

    Kiril Peyanski · 09/06/2020 at 7:28 am

    anything in the logs?

Add Your Website · 09/06/2020 at 2:38 pm

Awesome blog.Really thank you!

Rosario · 15/06/2020 at 11:50 am

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 ?

Randall · 17/06/2020 at 1:21 am

Is there any reason why alexa can’t reproduce all the sound effects?

Dave · 05/09/2020 at 9:51 pm

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.

Nixx · 28/09/2020 at 9:22 pm

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?

    Kiril Peyanski · 29/09/2020 at 9:46 pm

    Did you update something? And you did the right thing with the GitHub issue. Hope that it will be fixed soon

Colby · 08/12/2020 at 5:43 am

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

    Kiril · 11/12/2020 at 11:29 pm

    Glad that I could help. You can check my other Home Assistant articles as well!

Brad · 15/12/2020 at 11:31 pm

does this solution use this media player setup? https://community.home-assistant.io/t/echo-devices-alexa-as-media-player-testers-needed/58639/4497

Anthony Ward · 03/01/2021 at 12:33 pm

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?

    Kiril · 03/01/2021 at 1:45 pm

    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.

    Anon · 23/01/2021 at 2:04 am

    It’s in Frontend https://i.imgur.com/3H45VPH.png

      Kiril · 23/01/2021 at 5:34 pm

      Thanks for the comment, Anon!

Debbie · 28/01/2021 at 11:03 pm

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!

    Kiril · 29/01/2021 at 7:58 am

    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!

      Debbie · 31/01/2021 at 5:42 pm

      Thank you for the tip! I’ll give it a try and let you know if it works.

Kevin · 31/01/2021 at 5:20 am

What happen to alexa media player in hacs? I don’t see it.

    Kiril · 31/01/2021 at 9:29 am

    Several other people reported this. I have to double check on my site is it still visible. Maybe it’s gone.

    Debbie · 31/01/2021 at 5:44 pm

    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/

Dr. Strange · 15/03/2021 at 6:07 pm

[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?

    Andy · 01/06/2021 at 5:36 pm

    Same, used to work but stopped recently and now I get this error message

    Andy · 01/06/2021 at 7:33 pm

    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.

Chris · 24/03/2021 at 10:49 pm

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.

    Kiril · 28/03/2021 at 6:51 pm

    I don’t know how I can help you with that. Maybe someone else can jump in.

Bdiesel · 15/09/2021 at 5:48 am

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.

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *