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.

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.

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.

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.


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

      Pete · 06/04/2020 at 9:48 am

      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.

    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?

Leave a Reply

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