Alexa in Home Assistant - TTS, Sound Effects, Sequence Commands, Media Player, Scripts + Automations

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in today's video we're going to be having  a look at how we can integrate alexa   into our home assistant to allow us to  make use of features such as text to speech   the media player and running home assistant  scripts with our voice check it out   what is going on guys i hope you're all doing well  first things first i am going to be saying the   word alexa a lot so if your echo is in the same  room as you you want to make sure that's on mute   for this tutorial there's going to be a few things  that we need first of all we're going to obviously   need an amazon echo device now you can use any  device in the echo range so this covers all of the   different echo speakers but it also covers things  like the amazon fire tv or anything that has the   alexa ability so you're signed into your amazon  account and you can physically talk to a device   so if you have the device and it's registered to  your amazon account you should be able to access   it with this tutorial next up we're going to need  to make sure our amazon account is two two-factor   authenticated now if it's not or you have no  idea how to do this i'll leave a link in the   description below so go ahead and follow that and  set your account up with two-factor authentication   we're also going to need hacks installed in our  home assistant now again if you've got no idea   what this is or how to do it i'll have a handy  video that i've created linked in this video and   also in the description so go ahead and check  that video out and then come back to this one   and the last thing we're going to need to do  is press that subscribe button if you haven't   already and if you ding dong the notification  bell you'll be alerted to any future videos i do   if you've got all of those things let's carry on  with this tutorial okay we're back here on our   demo dashboard the first thing we're going to need  to do is open up hacks so i'm going to open hacks   here in the sidebar then we're going to head into  integrations i'm going to click the plus in the   bottom right corner here so i'm going to press on  that and we're going to do a search for the alexa   media player now i can see it in the top of the  list here so i'm just going to press it if it's   not there in your list just do a little search  for alexa media player and once that's opened up   we're going to just hit on install this repository  in hacks at the time of recording this the most   recent version is 3.8.5 and i'm just going to  hit install on that once that's done if we just   scroll down to the bottom we should see our new  alexa media player integration so i can see that   there and it's telling us it's pending a restart  so if we just choose hacks again we can see that   restart and if we just click on that it's going  to jump us into the configuration and we're just   going to hit restart in server management okay  once our home assistant's restarted we're going   to press configuration again and we're going to  jump into integrations we're then just going to   hit that plus in the bottom right again and we're  going to do a search for the alexa media player   and we're going to just press on that this might  take a couple of minutes for it to actually load   the integration and when it has loaded we're going  to get a configuration page like this so we're   going to need to enter our email address and our  password so go ahead and enter your details there   the other thing you're going to need to update  is your amazon region so i'm in the uk so mine's   going to be dot co dot uk but if you're in the  us or anything like that you'll need to change   your amazon domain to match where your account is  registered to there are a few other extra things   you can do with this configuration i'm just going  to keep it basic so you can do things like include   only set devices or you can exclude certain  devices i'll have a link for this integration in   the description below so you can go and read the  documentation if you're interested in some more   advanced configuration but as i said we're keeping  it basic so email password and update your region   we're then just going to press on submit pressing  submit should take us to the amazon two-factor   authentication page and from here we're gonna just  need to enter our credentials and press sign in   we're then going to need to enter a captcha and if  you're lucky it will work first time so enter that   and press sign in if you're stuck on the captcha  and you constantly enter capture after capture   and you know your email and password are both  right i'd recommend you try a different browser   when i first did this i was using the new version  of microsoft edge and it just wouldn't get past   the captcha i switched over to google chrome and  it went through straight away now i don't know   if this is a browser issue or not but they are  both chromium but for whatever reason it didn't   work in edge so yeah if you're stuck have a go at  using a different browser once you have made it to   this step it's going to ask us for our two-step  verification method i'm going to choose enter a   one-time password for my authenticator app so  i'm just going to hit send one time password   that should then redirect us back to home  assistant and after a second the success message   should pop up and we should be able to see all of  our echo devices if you want to at this point you   can assign these devices to specific areas using  the drop downs i'm going to leave that for now and   just press finish once that's finished we should  be able to see our alexa media player and all   of our devices and entities that are associated  with our amazon account if we then choose devices   it will then take us into a list of all of our  available amazon devices and we should be able   to control these with the integration before we  start playing around with the fun stuff like the   text-to-speech we've got one more thing that we're  going to need to add and this is the mini media   player and we're going to get this through  hacks again so let's jump back over to hacks   and this time we're going to choose front end  and we're going to just click the little blue   explore down the bottom for me the mini media  player is just there at the top if it's not   there for you just do a search for it using the  search bar at the top so i'm just going to press   on that and from here we get a little preview  of what's capable with the mini media player   so what we're going to be using this for is  to allow us to create a little media player   and it's going to have this little  text-to-speech option like on this one here   and what that's going to allow us to do is just  have that control somewhere on our home assistant   dashboard and when we enter text into that box  amazon echo will say whatever we type in the box   so let's go ahead and click install  on that and at the time of recording   this the latest version is currently  1.12.0 and i'm just going to hit install   once that's done it's going to pop up a message  telling us it needs to reload the browser cache   so just hit reload there and if we just scroll  down we can now see the mini media player there   okay from here we're going to just  head over to our main dashboard   and we're going to add a new card we're  now going to have to create this media   player card that we've just added from hacks  so we're going to search for a manual card and then we're just going to manually enter the  card configuration i'll have this configuration   linked in the description below so you can go and  copy that and just modify it to fit your echo so   go ahead and paste that in and the parts you're  going to want to change are the entities so you're   going to need to update the media player to be the  name of whatever echo you're using in your house   and the same with the entity id there and once  we've done that we're just going to press save   if you're not sure what your echo's entity ideas  a simple way to get it is if you just open the   alexa media player integration and go into your  device list then you're going to want to find   the echo that you want so in my example i'm using  the kitchen echo i'm just going to press that and   then from here i can just click on the kitchen  echo and it will tell me what the entity ideas   this will then be the id that i use on the card on  the dashboard on our dashboard we've now got this   nice little card and from here we've got a little  volume slider to control the volume of the echo   and there's also a little text input there that we  can control what the echo is going to say there's   also some nice little track controls there  to control any music that's currently playing   i'm a big fan of this card and there's quite a few  different things you can do with it again this is   linked in the description below so if you want to  play around with the configurations for the card   then go and check that out this particular echo is  my kitchen echo but it's currently sat right next   to me here so if i do some text-to-speech  hopefully you should be able to hear it   so let's go ahead and enter a message here  i'm just gonna press send this is a test   and hopefully if that was loud enough you  should have heard it say that this is a test   so any text that we enter in that box the amazon  echo will just say as this card is also a media   player whenever you play music it will take  on the album art of whatever song's playing so   here is an example i've got some arctic monkeys  on and we can see that it's grabbed the album art   for that and it's playing i can also pause and  skip the track using the little controls here   so that's the manual way of doing text to speech  but what if we want to use text to speech in an   automation let's start off by having a look  at a demo using the developer tools so in the   sidebar here we're going to choose developer tools  we're then going to choose services up at the top   and the service that we want is going to  be notify dot and then this is going to   be the name of your echo so if i keep typing  here i'm going to put alexa and in that list   now i can see the actual echo i want so for my  example i'm using my kitchen echo so i want the   notify.alexa underscore media player underscore  kitchen underscore echo but the mouthful   so for you you'll need to choose whichever echo  you're using a quick tip here if you've got a few   groups they might also show up in the list so in  my list there i've also got this media underscore   kitchen but that's a group so i don't want that  i want the actual echo so i want the kitchen   underscore echo so if you've got something similar  make sure you've got the echo at the end there   okay so we've chosen our echo we now need  to give this service a couple of parameters   so we need to give it a message and this is going  to be the actual body of the message so what we   want the actual echo to say so let's just fill  this in i'm just going to say this is a test again   for the title we can leave that one blank  because we don't need a title for this type of   notification and the data we need that and this  is where we're going to tell the notification   what kind of a type it is so we're going to  enter that and the type for this one is tts   and that tts tells the service that this  particular notification is of type text to   speech so when we press call service it should  pick that up and hopefully our echo will say   what we've got in that box so let's  go ahead and press that call service this is a test so that's working and hopefully  you should have heard that the developer tools   are great for this kind of thing because we  can just quickly test a few different things   and get the end result that we want now that  we've got that working demo we could easily   convert this into an automation one simple thing  to do is you could just click this go to yaml mode   and once we press that we can actually see the  yaml for that type of notification before we move   on to automation turn i want to just quickly touch  on sequences and sounds now these are things that   we can do with the echo to make our text-to-speech  a little bit more interesting let's start off with   sequences then so here's a list of different  sequences that we can trigger with the echo   and we can use any of these sequences with the  media player play media service and using these   sequences we can do things like get alexa to tell  us a story tell us a joke tell us what the weather   is you get the idea let's have a look at how we do  this then so we're going to be using the developer   tools again just to show off an easy example and  the service that we're going to want to use to do   this is the media player play media now there  are a few different play options so make sure   you choose the right one so here we can see media  player play media player play pause the one that   we want is this media player play media and then  from here we can either use the gui or we can   use the yaml mode so i'm gonna do with the gui  and then i'll switch over just to show you the   difference so let's pick our entity and the entity  we're gonna use again is just my kitchen echo the   next parameter we've got is the content id and  this content id is going to be the option for the   sequence so let's just say we want alexa to tell  us a joke we could go with alexa joke.play so if   we just copy that and then we come back into our  content id we're just going to paste that in there   and the content type for this particular thing  is a sequence so we're just going to type in   sequence there and that's everything we need so if  we hit call service we should hopefully get a joke   there are two fish in a tank one says to  the other how do you drive this thing nice   so that's how you call a sequence with the gui  and again you can just hot swap these out so   if you didn't want joke and you wanted one of the  other sequences you can just come in here and just   pick whichever one you want and if we jump over to  the yama mode we can see what that would look like   in yaml and again we could take this straight from  here and turn that into an automation next up then   we've got sounds and you can probably guess  what this one's going to do so here's a list   of different sounds and we can choose one from  here i'm just going to grab this doorbell one here   i'm going to hop back into our developer tools  page and the content id is going to be the sound   that i've just copied so i'm going to paste  that in there and this time we're not using   sequences we're using sound so all we need to  do here is just change this sequence to be sound   and we're going to target the kitchen echo  again and we're just going to hit call service   that one was quite quiet but you might  have been able to hear that and it was   just a little doorbell sound effect and if  we just have a look at the yaml mode again   that would be the yammer that we  could again turn into an automation   so that was a quick look at sequences and sound  now there are a ton of different things that you   can do with the custom alexa component you can  do things like trigger specific songs to play   on the echo you can launch echo skills you can  launch echo routines and you can do things like   actionable notifications so this will be where  alexa will ask you something and then you can give   alexa an answer like yes or no and based  on whatever answer you give she'll go and   do something i'm not going to be covering those  things in this video but i will be covering them   in a future video so if you're interested in that  make sure you hit that subscribe button and if you   ding dong notification bell you'll be alerted to  whenever i bring a video out alexa uses the speech   synthesis markup language or ssml for short and by  using this markup language you can add effects to   the voice that alexa uses so i'll show you a very  quick demo of this now to do this we'll use the   notify service again so we're going to use notify  and then the name of our echo again so i'm going   with the kitchen echo again just like our other  notification then we're going to add a message as   a parameter but this time the message is going  to be surrounded by the ssml markup so let's   go ahead and paste this in and this will be in the  description below so feel free to go and grab this   looking at this then we can see that our message  is this is a whispered notification and we can see   that it's surrounded by this markup and what this  is doing is just telling alexa what effect needs   to be used when she speaks so we can see here  we're using an amazon effect called whispered   we then also need to add data but as the type this  time we're not going to be using text-to-speech   we're going to be using two different  ones we're going to be using an ounce   and we're also going to be  adding the method of speak and then let's just give  that a go by pressing call this is a service notification and that's a quick  look at some of the things that are possible with   ssml now i will be covering this along with those  other topics that i mentioned in a future video   but what we're going to do now is have a  look at how we can take what we've learned   and turn it into an automation okay so  let's say you've been playing around with   the developer tools and you've created  a notification for one of your echoes   and you want to turn that into an automation  what do we do in the latest version of home   assistant they've streamlined the user interface  so this actual service call and the setup of it   is now the same across all the different parts of  home assistant where you can access the services   and this just simplifies live for us because  we now know how to create a notification   and we know what parameters we need so we can just  copy this straight across to an automation and   i'll show you how to do that now so we're going to  go into configuration and then we're going to head   straight into automations and we're going to add  a new automation here so the blue button in the   corner we're just going to press on that and we're  just going to say start with an empty automation   and then let's go ahead and fill this automation  in so we'll give it a name and a description   we'll leave the mode as the default one let's  set a trigger then to kick off our automation   so we'll keep it nice and simple and we're  going to set the trigger type to just be sun   and we'll go with sunrise and we're then going  to want to add an action for the sunrise so   the action we're going to use is call service and  the service that we're going to use is the notify   service that we've been using to actually get the  tts to work so we're going to use notify and we're   going to use the echo that we've been targeting  so my one is the kitchen echo and you can now see   that we're presented with a familiar screen that  we've been using throughout the video so we've got   a message a title and data so again we're going  to set the message and the data so the message is   going to be the message that we want the echo to  say and the data is going to be the type tts and   that's basically it you can see how the screens  are the same so if you've managed to get something   work in the developer tools it's very easy to  just transfer it over so we could press save there   and then when our trigger's fired this server  should be cooled now that's a super basic use for   the automation but they can get more complicated  here's another example and in this example i'm   using the zone trigger and what this is doing  is when a person is detected as being home   the notify service is being called and the echo  is announcing that that particular person is home   again that one's not super complicated but the  power of this comes when you start combining it   with other automations and other services a good  example of this is room assistant now if you're   not sure what room assistant is i've done a couple  of videos on that and i've got a few more planned   so go ahead and check that out but one that  i use with room assistant is the day before   bin day at about 7 p.m if room assistant detects  i'm in a room the echo will ask me if i've taken   the bins out and this is just a nice little  reminder then to you know take the bins out   you can also make use of sequences and sounds  that we had a look at earlier on in the video   a good example of incorporating these is you  could use something like a motion sensor and   when that motion center detects motion it could  play an alarm sound or it could run a specific   sequence have a play around and let me know any  cool things you plan to make in the comments below   the last thing i'm going to touch on then is  calling scripts using alexa and what this is   going to allow you to do is you're going to be  able to use your voice to trigger a script and   have home assistant do something in this  particular example i'm able to get the   temperature of my raspberry pi and have alexa  announce the temperature using the text-to-speech   so in order to make use of this your home  assistant needs to be accessible externally from   your network either by using nabucassa or another  method i'm not going to be going into details on   how to do all of those things but the idea of this  was just to give you an idea of what's possible   so if you have those things set up you can expose  this script to alexa and alexa will then just see   this as a scene you can then combine this with an  alexa routine so in my case i'm using a command   to say what's the temperature of home assistant  and when i say that it causes alexa to cool the   script which in turn triggers the text to speech  which announces the pi's temperature in a future   video i will be going into more detail about  scripts skills actionable notifications routines   and play music to summarize then we've had a look  at how we can set up the alexa custom component   and also the mini media card we've then had a look  at how you can use text-to-speech and some of the   text-to-speech options like the sequences  sounds and the effects then we had a brief   look at how you could make automations using the  text-to-speech and a couple of different examples   for that and that's all for today if you've  enjoyed the video don't forget to leave me a like   if you've enjoyed the video and want to  see more then hit that subscribe button   i will be back with more alexa videos going  through some of the topics that i've spoken   about today but thank you for watching  and i'll catch you in the next one cheers   alexa uses the speech synthesis  this particular echo is my
Info
Channel: Mark Watt Tech
Views: 109,467
Rating: undefined out of 5
Keywords: MarkWattTech, HomeAssistant, Hassio, Home Assistant, Smart Tech, Smart Home, Mark Watt, Automations, Home Asistant, alexa tts, How to use alexa home assistant, Setup text to speech, Alexa control in home assistant, Alexa media player, Alexa home assistant player, Alexa custom sounds, Alexa sound effects
Id: 0ElXDPw5c1Q
Channel Id: undefined
Length: 20min 2sec (1202 seconds)
Published: Wed Mar 24 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.