ALEXA ACTIONABLE NOTIFICATIONS (Home Assistant + Alexa Skill)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Ever wanted Alexa to ask you a question, and have your answer trigger a Scene, Script or Automation?

That's exactly what you can do with Alexa Actionable Notifications!

( I will be sharing a shorter quick install and full written version in the coming days)

👍︎︎ 2 👤︎︎ u/Sparky3295 📅︎︎ Jun 10 2021 🗫︎ replies
Captions
in today's video we're going to be having a look at how to set up and use actionable notifications using the amazon echo and home assistant check it out what's going on guys i hope you're all doing well so this video is just a continuation of my alexa and home assistant setup in the very first video i went through the full setup of the custom alexa component and some of the different things that you can do with it i've also done a video on custom mp3s and with this you can upload your own custom mp3 files to your home assistant instance and then use those mp3s in things like automations and scripts and if you're interested in either of those two things there will be links for them in the description below for this video you will have at least needed to complete that first video as you're going to need to have the alexa custom component set up and ready to go so before we get into it let's have a quick look at what an actual actionable notification is so usually with the amazon echo it's us asking the echo a question or us asking the echo to do something but this time it's going to be the other way around so we're going to have the echo ask us a question and whatever our response to that question is is going to cause something to happen and in our case that something is going to be home assistant related so this could be calling the script running an automation turning on a set scene or something else to get the most out of actionable notifications you'd couple them with your normal automations and have that automation fire off the actionable notification an example that's used in actionable notification documentation is that when a front door is left open for more than five minutes the actionable notification gets called and your echo is going to ask you if you want to lock the door as it's been open for more than five minutes you've then got the choice of saying yes or no obviously if you say yes your door would lock and if you said no then it wouldn't lock another great way to make use of actionable notifications is reminders so you could have a reminder on bin day that it's going to say to you hey it's been day have you remembered to take the bins out and you could then say yes or no if you say yes it's not going to remind you again and if you said no you could have a timeout period where it's going to ask you again in say 15 minutes that way it's kind of like pressing snooze and it's just going to remind you again in 15 minutes and it will just keep asking you until you finally do it so in short we're going to be using those notifications to get feedback from our automations and whatever feedback we give it could be yes no or maybe not even answer and whatever feedback we give we'll get the automation to run a set path hopefully that makes sense if it doesn't just follow along and it should become more apparent as we get into it as always this video will be chaptered so be sure to make use of those chapters in the description below to just jump over any irrelevant parts to you to get started with this project there's going to be a few things that we need first of all you're going to obviously need an amazon account with echo devices tied to it you're then also going to need public access to your home assistant so this can be done through naboo casa duc dns or some other service if you don't have public or cloud access to your home assistant you can still set up these actionable notifications but i'm not covering that process in this video if enough people are interested in seeing how to do it without that access then i'll be happy to make a video on it as i previously mentioned you're also going to need to have that alexa custom component installed and i went through this in that first video and the last thing that you're going to need is just to make sure that you're subscribed so if you're not already hit that subscribe button and ding dong the notification bell you'll then be alerted to any future videos that i do before we get started with creating our new skill we're going to first just need to add this input text into our configuration.yaml file we'll be using this input text to test out our new skill and the code for this will be in the description below so feel free to just copy and paste that in for this setup we're going to be making use of keaton taylor's alexa actions guide which can be found on github and i'll have that linked in the description so thank you keaton for the awesome guide the first thing we're going to need to do is head over to the alexa developer page again that'll be linked in the description when you get to this page it's going to ask you to sign in and the important thing here is you're going to need to sign in to the account that's linked to your alexa and echo devices once you're all signed in we should end up on a page like this and from here we're going to start creating our skill to do this we're going to just choose create skill it's then going to ask us to give our skill a name and you can name your skill whatever you want once you've given it a name we're going to set the default language for me i'm just going to set this to be english uk next up we're going to choose a model and for this we want to make sure that custom is selected a little further down we're going to want to choose the actual back end resource and for this we're going to have it as alexa hosted python with that selected we're going to just scroll back up to the top and we're going to press create skill the last step here then is going to ask us to choose a template and for this we're going to just leave it on start from scratch and then we're going to press continue with template this is then going to take a couple of minutes while alexa propagates and creates all the bits that we need for our new skill while you're waiting for those resources to generate if you're not already hit that subscribe button and if you ding dong the notification bell you'll be alerted to any future video that i do when that finally completes you should be presented with the developer console and you'll see these little pop-ups to tell you that the build was successful so for now we're just going to close these little help notifications as i mentioned we're going to be referencing keaton taylor's alexa actions guide and for this we're going to be copying and pasting bits from their github so just make sure you've got that opened up and ready in another tab back on the developer console the first thing we're going to want to do is to set the invocation name to do this we're going to just press invocation in the left hand menu you'll then see the skill invocation name and it will say change me and we're just going to update this as we're following along with the guide we're going to set this to be custom actions now if this is the first skill you've set up i would recommend you copy everything to the t with the guide that way if you get stuck or make any mistakes you can reference directly to the guide and everything should match up so just copy along and once you've made one or two skills feel free to come in and play around with these settings and see what else you can create so with custom actions entered we're going to just press save model and we'll see a pop-up to say that the skill successfully saved the next thing we're going to need to do is to update the skill manifest to do this we're going to press on interaction model in the left hand menu and then we're going to press json editor we're then going to want to switch over to our other tab and we're going to open up the skills manifest and we're going to choose local enus we can then just press this raw button and what that's going to allow us to do is to just copy and paste everything here a little handy shortcut as if you just press ctrl a and then control c that will copy everything to your clipboard we can then head back to our developer console and we're going to select everything here again using control a and then we're going to overwrite that using control v so just make sure you've copied everything from that file in the git repo over to this one and once you've done that we're going to press build model up at the top there when that's finished building you'll see a little pop-up like this just to tell you that the full build was successful now that that's successfully built we're going to configure our account link in and what this is going to allow us to do is to tie our alexa skill to our home assistant install with this we're going to want the highest security possible as we're going to be connecting our home assistant install directly to something external and for this we're going to use the account linking feature and this is going to ensure that our skill doesn't use any static credentials for access so to get started with this we're going to press tools in the left hand menu here we're then going to just scroll down and choose account linkin it's going to be a couple of things that we need to set up and configure in here in order to set up that account link in so let's start by just closing this little help bubble the first thing we're going to want to do is to toggle on this first option so do you allow users to create an account or link to an existing account with you so toggle that on and when we toggle that on you'll notice it also toggles on the second one and we're going to want to toggle that second one back off so just ensure that only that first toggle switch is turned on next up we're going to need to set our uris and this is going to be the web authorization uri and also the token uri this is going to look a little something like this so for the web authorization it's going to be your home assistant address followed by forward slash auth forward slash authorize and the same for the access token is going to be your home assistant address followed by forward slash auth forward token and when you're doing this just double check that both of those are correct because it's going to save you any headaches with any errors or anything like that next up we're going to need to set the client id for this you're going to want to choose one of the following urls so pick the one that's closest for you i'm uk based but i found that the dot code at uk one wouldn't work for me so i made use of the eu one if you're also in the uk i recommend you just copy along and use that eu one so go ahead and just copy the one that's relevant to you the next thing we need to do is to add a secret now we're not actually going to be using the secret so you can just set this to be whatever you want and then after the secret we're going to need to set our authentication scheme for this we're going to just press the drop down menu and we're going to choose credentials in request body the last bit of the config we need to do then is to just add a scope to do this we're going to choose add scope that's going to make a little text box appear and inside of here we're just going to enter smart underscore home and with that scope added that should be all the config that we need so let's just quickly recap this just to make sure we've got everything so working our way up from the bottom we've got the scope and that needs to be set to smart underscore home we've then got the authentication scheme which needs to be credentials in request body you've then got your client secret which you can set to be whatever you want from the list that i showed you you're going to need to choose the locale nearest to you and set that as your client id again i was uk based but that didn't work for me so i'm using the dot-com one for the token uri and the authorization uri you're gonna need to give your home assistant address followed by forward slash auth and then either token or authorize and then finally up at the top you're gonna need to make sure that you've only got the top toggle selected and if you've got all those settings correct just press that save button in the top right that's all the config done for the skill but we're now going to need to add some code in order to get it working to do this we're going to need to jump over to the code section so up at the top there we're going to choose code when that loads up we'll be presented with a page like this and this is where we're going to be editing our code this is going to be quite straightforward as we're not actually going to have to write any code but we are going to be doing a lot of copying and pasting so you're going to want to take your time here and make sure you copy and paste everything exactly as it is so open up your github tab and we're going to choose lambda and in there we're going to choose the first one which is lambda underscore function dot pi with that selected again we're going to just choose raw and we're just going to select all of the text here and copy and paste it so again we're going to use control a to select all and then we're going to press control and c again back on the developer console we're going to first make sure we're in the lambda underscore function.python file and we're going to do control a and we're just going to delete this with that all deleted we're just going to paste in what's in our clipboard and then just scroll back up to the top it's up to you how you go about copying the code from the github repo over to this you can use this import code option at the top and you can just download the files from git and just upload them but i'm just showing you the copy and paste method just because it's quite simple and as long as you copy everything over it doesn't really matter which method you use in this file that we've just pasted in at the top you'll see an option for the home assistant url you're going to need to update this here to be your public address for your home assistant so enter your public address there now two more things to point out here you can't use a private or an internal address here it has to be your public facing one and the second thing is if you're not making use of ssl you're going to want to set this option here to be false now i am making use of it so i'm just going to leave that to be true and this is actually all the changes that we're going to need to make everything else is just going to be copy and pasting so next up we're going to want to open up requirements.txt with requirements.txt open we're going to switch back over to our github tab and we're going to open up the requirements.txt on the github repo as this one's only a short document i'm not going to bother clicking raw so we're just going to highlight all the code there and we're going to copy it we're then going to head back into the developer console and we're just going to paste all of that over the top of this and that's the requirements copied over we're now going to need to create a new file to do this we're going to choose new file in the top left there and for this we're going to give it a name of language underscore strings.json and we're going to press create file we should then have this blank new file and again we're going to jump back over to the github tab and we're going to choose lambda and we're going to find that language underscore strings.json file and again we're going to choose raw and as before we're going to just select all this using control a we're then going to press ctrl c to copy that we'll then jump back over to the developer console and just paste that in with that pasted in there's going to be just one more file that we need to create and that's prompts.pi so again choose new file and we're going to type prompts.pi and create file and as you guessed it we're going to jump back over to github head into lambda again and we're going to open up prompts.pi and again we'll just select all of this copy it head back in there and then paste it back in in the left hand side we should now have five files underneath the lambda folder and the files that we should have edited are the lambda function requirements language strings and prompts if you copied all those files across and you updated your home assistant url you should now be ready and you can just press deploy in the top right so you'll get a pop-up to tell you that the deployment initiated and then after a couple of seconds it should hope to tell you that the deployment was successful that should be our skill fully set up and ready to go so the next step will be to link our skill to our home assistant to do this next step we're going to be using the alexa app on our mobile device on our device we're going to want to open up the alexa app we're then going to want to choose more in the bottom right corner and then we're going to press skills and games from here we're going to press your skills in the top right and we're going to swipe all the way to the right until we see dev we're then going to press dev and we should see our skill available so i can see mine there as marco attack and it's telling me that the account linking is required so we're going to press that and then i'm going to click enable to use it should then prompt us with our home assistant login and we're going to just need to log in once you log in you should see a message to tell you that the account has been successfully linked all of the config should now be done and our new skill should be linked to our home assistant we can now also test that our skills work in and we can do this by just getting our echo and we can say the invocation word so i can say alexa open custom actions this is a test of the alexa actions custom skill did it work yes okay okay we're back in home assistant now and if you're at this point you should now be able to trigger your new skill with your voice but triggering the skill with our voice isn't what we actually want what we want is to be able to trigger the skill with an automation that way the echo is going to ask us something and then we're going to give it feedback to get this all working we're going to need three things we're going to need an automation which is going to act as our trigger and actually fire off everything we're going to need a script and then we're going to need another automation which is going to handle our response now it does seem very cumbersome and clunky but once you've got one working and you understand the process it's very easy to just knock up more on keaton's github there is a helpful script that you can copy and this script is going to allow you to trigger actionable notifications a lot easier from within your automations so you can just copy that script and then just paste it in your configuration.yaml or wherever you call your scripts from i store all of my scripts under scripts.yaml and this is the script that i've been using to help me run my actionable notifications this code that i'm using is also in the description below so you can go and grab that once you've pasted that script in you're going to want to update this bottom line here which is the media content id and you're going to want to update this to be your amazon skill id you can get your skill idea by heading back to the developer console and going back to the main page then just find the skill that you want and press this copy skill id button pressing that button will copy your skill id into your clipboard you can just come back in here and then just paste in your skill id there and once you've got that script added and you've got the skill id added you can just hit save at the top there with the new script added we're going to head into the configuration we're going to scroll down to server controls we're going to find scripts in this list and just click it that will just reload our scripts to make sure we're using the latest version and now that we've got that reloaded and got our script we can start creating our automations before we start writing our automations we're going to just first test that our script's working so we're going to open up the developer tools and we're going to choose services in the service if you just start typing actionable you should see your script appear so it's the script activate alexa actionable notification so choose that in our script the parameters are all documented so we get this nice little description for what each parameter is so we've got the text which is obviously the text that the echo is going to speak we've got the event id which is the event responses and then we've also got the device that we're going to get the announcement to come from i've just entered some test data here to just check that my script's working so i've given it some text and the echo is going to speak that text i've given it an event id but that event actually doesn't exist and i've also given it the name of the echo that i want to use so what this is going to do is it's going to speak that text on this echo and it's going to fire off that event id usually we'd have something listening for that event id but as it's just a made up one nothing's gonna happen so let's test this out now so i've got my kitchen echo here and i'm just gonna press cool service should i turn off all of the lights yes okay and again because we've got nothing listening to that event id it doesn't really matter if i say yes no or don't answer it's not going to do anything but doing that test i can see that my script is working and i can successfully pass through all three parameters now that i know that this script works i can start building automations around it and if you're following along and you're at this point and it's working you should be good to go if this still isn't making much sense then don't worry it should hopefully become more apparent as we start working on these automations so jump into your automations and you'll remember that i said that we needed three things we needed an automation to do the trigger we needed the script and then we needed an automation to do the response so we're going to need to set up two automations now and i've already got some demo ones here so i've got these top two automations here so i've got actionable one and actionable response one action number one is gonna be my trigger and this is going to be what gets everything going and the response then is going to be what happens when i give feedback to the echo so let's dive into these now so actionable one is nice and simple it's got a simple trigger and it's just the sunrise event so at sunrise and action's going to be called and that particular action is just calling the actionable notification service here we're just calling that script which we just called a second ago with the developer tools and we're just passing in some parameters so with this what's going to happen is at sunrise the script's going to get called and these things are going to happen so it's going to do an announcement to say that the front door's been unlocked for five minutes do i want to lock it it's then going to fire off an event which is called actionable notification lock left unlocked and then it's going to play on the kitchen echo again the key factor with this one is that event id so we're looking for that actionable notification lock left unlocked if we head back and jump into the actionable response one so what the actionable response does then it listens out for an event being called and when it hears this event it causes an action to happen so we can see here that it's listening out for the alexa actionable notification event and the event id it's actually looking for is that notification lock left unlocked which we just fired off with that initial automation it's also making use of this secondary parameter here which is the event response type and it's currently set to response type yes with that event response type there's six different possibilities for what it could be so whichever one you set is going to request a different thing r1 is looking for the response type yes so the answer has to be yes in order for it to cause the action you've also got no which does the opposite so if you respond no it causes the action you've also got the response of none and if this happens no response was given then there's also response numeric response duration and response selection so with our automation we're looking for the response of yes and if we get the answer yes it's going to cause the action and this particular action is just going to call a service which is going to display a notification on my phone i hope that that made a bit of sense and was somewhat understandable all of the code for these automations will be in the description below so if you aren't sure just have a look through that code i've got another little demo for you just to show how these actionable notifications work so again we've got the action and we've also got a response so for this one what it's going to do is it's going to check if there's been any motion in the kitchen for a set period of time and if the lights are on so if there's been no motion and the lights are on the echo is going to ask us if we want to turn off the lights in that room let's have a look at this now so we've got the actionable two here so for this one it's got a trigger and it's got a condition the trigger says that there has to be no motion in the kitchen for more than 30 minutes and the condition says that the kitchen light also has to be on so if there's been no motion and the lights are also on it's going to fire off that action and that action is going to ask us if we want to turn off the kitchen lights and we can see here in the service data we've got the text of what we want the echo to say we've got the event idea of what we want to track and then we've also got the device that we want to play that announcement on let's jump back and have a look at the response then so we're going to be having a look at the response for actionable response 2. so for this one we're just listening out for that event and that event is the notification kitchen light so when we hear that we're also looking for the response of yes so if that event is fired and we answer yes it's going to fire off the condition which is going to say call the service and it's going to turn off the kitchen light let's do a bit of a live demo then so i've got my kitchen echo here on the right hand side there i've got the kitchen light and on the left i've got the actionable notifications too so what i'm gonna do here is just run those actions which is gonna bypass that timeout for the motion sensor so let's just give it a go and see what happens so i'm going to run that now the kitchen has been empty for a while should i turn off the lights yes okay let's just turn that back on and do another test so we're going to turn the kitchen light back on and we're just going to rerun the actionable 2 notification the kitchen has been empty for a while should i turn off the lights no okay from that we can see that the yes and no responses are working so when we said yes it turned off the kitchen light and when we said no it just left it on on the github page for the actionable notifications there's a ton of different examples on there so if you're after a bit more inspiration go and check those out if you're a node-red user there's a flow that you can import which has got a ton of different examples in there so be sure to add that to your node red and have a play around with those just to summarize then and get everything clear the first thing we did was set up an alexa skill the purpose of this skill is to allow us to communicate with the echo and with that we can do things like our responses to where we say yes and no and the feedback from that then causes an action after our skill was working we set up a little helper script and the purpose of this helper script is to just allow us to tie our automations and the actionable notifications together and that's pretty much the basis of the alexa actionable notifications so the actionable notification is comprised of three parts we've got two automations and the script the first automation then is the trigger and this trigger causes the script to run and when that script runs we also pass in some parameters to it the parameters are the text that the echo is going to say it's the event id of what we want to happen and then it's also the device so the advice that we want the announcement to happen on the script then is just the bit in the middle and it's the helper so it takes those parameters given to it by the first automation and passes it to our echo skill it then uses that response and passes it onto our second automation depending on the response given the second automation then causes an action to run and this could be turning on your lights or whatever you want your action to be if you're still unsure of how this all works be sure to check out my facebook group where i'll be able to share some pictures and a bit more detail on this there are some more advanced features and more advanced dialogue that you can use with these notifications and if you are interested in seeing a more advanced version of this then let me know in the comments below if enough people are interested i'll be happy to make a video on that my last alexa video got over 400 likes so if you have enjoyed this video be sure to smash that like button and let's see if we can beat that record let me know in the comments below what you plan on creating with these actionable notifications i've got more relaxer and home assistant videos planned and so if you're enjoying this topic and you're not already subscribed hit that subscribe button and ding dong the notification bell you'll then be alerted to when these videos come out as always a massive thank you to these awesome dudes these awesome dudes on my patreons if you're interested in joining these awesome dudes then they'll be linked to my patreon in the description below thank you for watching and i'll catch you in the next one cheers [Music] you
Info
Channel: Mark Watt Tech
Views: 42,412
Rating: undefined out of 5
Keywords: MarkWattTech, HomeAssistant, Hassio, Home Assistant, Smart Tech, Smart Home, Mark Watt, Automations, Home Asistant, alexa, actionable notifications, responses, alexa tts, answers, ai, voice assistant, setup alexa, notificcations, notifications
Id: uoifhNyEErE
Channel Id: undefined
Length: 26min 31sec (1591 seconds)
Published: Thu Jun 10 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.