{"id":565,"date":"2019-08-25T22:14:35","date_gmt":"2019-08-25T22:14:35","guid":{"rendered":"https:\/\/www.protowrxs.com\/?page_id=565"},"modified":"2019-08-25T22:14:37","modified_gmt":"2019-08-25T22:14:37","slug":"talking-to-the-house","status":"publish","type":"page","link":"https:\/\/www.protowrxs.com\/index.php\/home-automation\/talking-to-the-house\/","title":{"rendered":"Talking to the House"},"content":{"rendered":"\n<h2>Echo Dot \/ Alexa and Home Automation<\/h2>\n\n\n\n<p><strong>December 2016<\/strong><\/p>\n\n\n\n<p><em>09\/2017 Note: This is no longer used as it was designed for my old setup and the current Home Assistant (Hassio) solution has an integration for Alexa that pretty much plug and play. Along with having unsigned SSL cert issues back then, I simply gave up taking this any further.<\/em><\/p>\n\n\n\n<p>Getting your Echo to talk to something out there after you have talked to it isn&#8217;t that hard to do  after all. There are different ways of making this happen using online cloud  services BUT using the HTTPS posting feature for  your skill can get things done and keep most of your work on your own server  instead of off in yet another cloud option. This is how I accomplished  integrating my Echo Dot into my old time home automation system and it&#8217;s web  interface. Granted, I have much more control over my home web interface than  others may but doing this with an Echo, Amazon Alexa developer account and good  old Classic ASP coding would pretty straight forward.<\/p>\n\n\n\n<p>Below is the basic flow concept of getting things working. You speak, the Dot \nlistens, sends your stuff to the Amazon cloud that compares your request with \nyour &#8220;Sample Utterances&#8221; and hopefully applies one or your &#8220;Intent \nSchema&#8217;s \nagainst the utterance. If it figures it out, it sends off a JSON post with the \nneeded information for you to process and return a reply. Sure this is a very \nround about way of doing this and my old voice control options like BoxHead just \ntalked to my local server directly. But the Echo Dot is much better at \nrecognizing and parsing through voices and you get the benefit of all the other \nEcho features on top of it.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"664\" height=\"453\" src=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/EchoHome.png\" alt=\"\" class=\"wp-image-566\" srcset=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/EchoHome.png 664w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/EchoHome-300x205.png 300w\" sizes=\"(max-width: 664px) 85vw, 664px\" \/><\/figure>\n\n\n\n<h2>Amazon Basic Setup<\/h2>\n\n\n\n<p>To get things working on the Amazon side you need to get a developers account \nat <a href=\"http:\/\/developer.amazon.com\">http:\/\/developer.amazon.com<\/a>. This \nis where you will add your new Alexa &#8220;Skill&#8221; to work with your Echo. You will \nhave to hook your echo to this account so make sure it is linked up with your \nother Amazon stuff if you want more integration.<\/p>\n\n\n\n<h3>Skill Information<\/h3>\n\n\n\n<p>Next you need to add the new Skill. Pick the Add a New Skill button to create \nyour new skill. You&#8217;ll need a customer skill and a name for it along with an \n&#8220;Invocation Name&#8221;. The main name doesn&#8217;t really matter but the &#8220;Invocation Name&#8221; \ndoes as this is how the Echo will know to fire off this skill. Since I will \nnever be publishing this skill for others, I used &#8220;the house&#8221; as the name. That \nway I can say &#8220;Alexa, ask the house to&#8221; and this skill runs. I&#8217;m sure &#8220;the \nhouse&#8221; is already used somewhere else but it works for me as I will not be \npublishing this skill. Be sure and keep your Application Id private as that is \nwhat you use to insure it is YOUR skill calling your server and not someone \nelse.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"640\" height=\"519\" src=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img26_small.jpg\" alt=\"\" class=\"wp-image-567\" srcset=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img26_small.jpg 640w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img26_small-300x243.jpg 300w\" sizes=\"(max-width: 640px) 85vw, 640px\" \/><\/figure>\n\n\n\n<h3>Interaction Model<\/h3>\n\n\n\n<p>This is where you will spend most of your time (besides testing at least for \nme) to setup your &#8220;Intents&#8221;, &#8220;Slots&#8221; and &#8220;Utterances&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"800\" height=\"787\" src=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img5.jpg\" alt=\"\" class=\"wp-image-568\" srcset=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img5.jpg 800w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img5-300x295.jpg 300w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img5-768x756.jpg 768w\" sizes=\"(max-width: 800px) 85vw, 800px\" \/><\/figure>\n\n\n\n<p>Initially the Intents looked a little weird to me and still kind of do but \nthey are really just in JSON format. You have the overall &#8220;intents&#8221; section with \neach &#8220;intenet:YOURCOMMAND&#8221; inside with &#8220;slots&#8221; options. If your command is \nsingular without other options like &#8220;say goodnight&#8221; the the format is easier \nlike this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">      {\t\"intent\": \"SAYGOODNIGHT\",\n       \t\"slots\":[]\n      },\n\n<\/pre>\n\n\n\n<p>\nIf you need to pass some more parameters along like &#8220;As the house to \nturn (on\/off) the (which one) light&#8221; there is a litte more to it. \nAs an example if you want to be able to say &#8220;Alexa, tell the house to \nturn (on\/off) the fireplace&#8221; you need to pass that on or off to your end\n point.\nThere are a lot of built in slot options but I wanted to figure out the \ncustom ones since I needed them so I made a simple on\/off custom slot.\nYou do this in the Custom Slot Types area of the page and simply name \nyour slot and add the words or phrases that should be used.\nOnce you&#8217;ve added your custom slot you can then add it to the slot \ninformatio in the intent schema. I called my on\/off slot &#8220;lcommands&#8221; for\n some dumb reason.\nWe that in mind, now have the follows for our fireplace option.\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">      {\t\"intent\": \"FIREPLACE\",\n       \t\"slots\":[{\"name\":\"lcommand\",\"type\":\"lcommands\"}]\n      },\n<\/pre>\n\n\n\n<p>\nThat basically sets up a variable names &#8220;lcommand&#8221; that will use the \n&#8220;lcommands&#8221; slot options to fill in the variable you will see in your \nutterance setup.\nNow we need to setup the utterances that will trigger our FIREPLACE \ncommand. These are rather simple but can get messy quickly. \nI&#8217;ve kept mine to a minimum but if you think about it there are several \ndifferent ways to even tell the fireplace to come on or off.\nLike &#8220;Turn on the fireplace&#8221;, &#8220;Turn the fireplace on&#8221;, &#8220;Turn fireplace \non&#8221;, &#8220;Turn on fireplace&#8221; and I&#8217; sure the creative can come up with other\n ways like &#8220;Turn the #()*$#$ fireplace on&#8221;\nI only setup two options, &#8220;Turn the fireplace (on\/off)&#8221; and &#8220;Turn \n(on\/off) the firepleace&#8221;. Alexa is actually pretty good at removing the \n&#8220;the&#8221;s and other uneeded words to get to the point.\nSo our two basic utterences needed for this are input as follows.\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">FIREPLACE turn the fireplace {lcommand}\nFIREPLACE turn {lcommand} the fireplace\n<\/pre>\n\n\n\n<p>\nEither of those utterances *should* trigger the intent. Note how the \nvariable was passed through. The { } is used to place the Slot variable \nin your utterance.\n<\/p>\n\n\n\n<h3>Configuration Tab<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"786\" height=\"514\" src=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img9.jpg\" alt=\"\" class=\"wp-image-569\" srcset=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img9.jpg 786w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img9-300x196.jpg 300w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img9-768x502.jpg 768w\" sizes=\"(max-width: 786px) 85vw, 786px\" \/><\/figure>\n\n\n\n<p>If\n you&#8217;ve gotten this far you&#8217;re likely itching to try things out BUT not \nso fast. We haven&#8217;t even setup HOW we are going to trigger this thing \nyet. \nAgain, you can use the Amazon AWS Lambda ARN adn it&#8217;s functions but I \nhad no clue what it was and would rather it just talk to my server \ndirectly.\nselecting the HTTPS option and plugging in your server URL with the \nhttps:\/\/ prefix gets this done. \nIf you are using a self signed cert, you will have to upload that in the\n SSL Certificate portion next.\nIf are working off a published cert you just need to check the right box\n on the SSL page.<\/p>\n\n\n\n<h3>SSL Certificate<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"852\" height=\"450\" src=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/imgD.jpg\" alt=\"\" class=\"wp-image-570\" srcset=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/imgD.jpg 852w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/imgD-300x158.jpg 300w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/imgD-768x406.jpg 768w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p>If\n you are running a server with a published cert you can simply check the\n appropriate box either as the main trusted version of the \nwild carded version. \nOtherwise your self signed certificate needs to exactly match the URL \nyou are using on the other tab.\nDoing an self signed SSL on a windows machine isn&#8217;t too hard and there \nare many sites showing how to do it.\nOnce you have added your cert to your site you will need to export it in\n x.509 format and paste the information here.\nI would advise getting this working early before creating a lot of \nschema&#8217;s and utterance&#8217;s to make sure you have it figured out.\n\n<\/p>\n\n\n\n<h3>Testing Testing<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"800\" height=\"742\" src=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img11.jpg\" alt=\"\" class=\"wp-image-571\" srcset=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img11.jpg 800w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img11-300x278.jpg 300w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img11-768x712.jpg 768w\" sizes=\"(max-width: 800px) 85vw, 800px\" \/><\/figure>\n\n\n\n<p>So\n you have it all figured out, have your &#8220;intents&#8221; and &#8220;slots&#8221; and \n&#8220;utterances&#8221; and &#8220;ssl&#8221;s and your &#8220;globly-gooks&#8221; all done? Ready to test.\nFirst make sure the Enabled button in turned on for the &#8220;This skill is \nenabled for testing on your \naccount&#8221;. \n<\/p>\n\n\n\n<p>\nThe testing tab is cool but not cool. It&#8217;s cool that you can type in an utterance and see the service request and response, \nit&#8217;s not cool that if your end point fails to respond right you just get a pretty generic error.\nIt will tell you if it&#8217;s a 500 error, etc. but no detail beyond that.\n<\/p>\n\n\n\n<p>\nI ended up adding code to do a URL get back to my own site and can \ncopy\/paste the service request into that file and then toggle a variable\n to make my responding code read that and output information.\nThat way if there is an error I can print it to the screen or see the \nfull error with line number column for \ndebugging. A bit of a pain but it works.\n\n&nbsp;<\/p>\n\n\n\n<p>\nSo now if I type in &#8220;turn off the fireplace&#8221; OR &#8220;turn the fireplace off&#8221; we get \nthe service request and hopefully a valid response back. <\/p>\n\n\n\n<p>\nBut Wait! You still \nneed to write your end point code to return the response! We&#8217;ll get there but \nfollow along.\nASSuming your end point is working you would see something like this in the \nservice request and the response. <\/p>\n\n\n\n<p>\nYou can see we get some special variables about our application ID, your user \ninformation, and then the &#8220;request&#8221; section that we are most interested in.\nThe request &#8220;type&#8221; tells us what this type is. Generally we get &#8220;IntentRequest&#8221; \nwhich means our voice command matched one of our intents and we should do \nsomething about it.<\/p>\n\n\n\n<p>\nWhen then see that the actual &#8220;intent&#8221; was the FIREPLACE and we also see our \n&#8220;lcommand&#8221; was off. Now we have what we need to pass along to our code to \nmake something happen. In my local server code I parse out the request.type and \nthe request.type.intent and the request.type.intent.slots.lcommand to get what I \nneed. Since you CAN have different request types that is the first thing I do in \nmy local server code to make sure what to do but we will address that later. In \nany manner this is what you have to work with depending on if what you said \nmatched any of your utterances. By default I set a reply to &#8220;The house couldn&#8217;t \nunderstand what you want to do&#8221; or similar and if no commands match that gets \nsent back to the cloud to forward to the Echo.<\/p>\n\n\n\n<h2>What we get from the Amazon cloud<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n  \"session\": {\n    \"sessionId\": \"SessionId.XYZ\",\n    \"application\": {\n      \"applicationId\": \"amzn1.ask.skill.ABC\"\n    },\n    \"attributes\": {},\n    \"user\": {\n      \"userId\": \"amzn1.ask.account.123\"\n    },\n    \"new\": true\n  },\n  \"request\": {\n    \"type\": \"IntentRequest\",\n    \"requestId\": \"EdwRequestId.XXX\",\n    \"locale\": \"en-US\",\n    \"timestamp\": \"2016-12-02T22:13:53Z\",\n    \"intent\": {\n      \"name\": \"FIREPLACE\",\n      \"slots\": {\n        \"lcommand\": {\n          \"name\": \"lcommand\",\n          \"value\": \"off\"\n        }\n      }\n    }\n  },\n  \"version\": \"1.0\"\n}<\/pre>\n\n\n\n<h2>Service Response<\/h2>\n\n\n\n<p>So let&#8217;s talk about what you need to send back to the Amazon cloud. There is \na pretty basic expectation to speak something so I just drop in two variables \nfor what to say and if we should end this session or not. For normal &#8220;IntentRequest&#8221; \nI set the shouldEndSession to true so we close the channel and stop listening on \nthe Echo side. There are other ways to response to different intents that can be \ncovered later though.<\/p>\n\n\n\n<p>\nSince generally you want to send something back to the echo to say, your \nresponse should be similar to this even if it&#8217;s just &#8220;OK&#8221;<\/p>\n\n\n\n<h2>What we send back to the cloud.\n<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n  \"version\": \"1.0\",\n  \"response\": {\n    \"outputSpeech\": {\n      \"type\": \"PlainText\",\n      \"text\": \" Well, I told the house to turn the fireplace off \"\n    },\n    \"shouldEndSession\": true\n  },\n  \"sessionAttributes\": {}\n}\n<\/pre>\n\n\n\n<p>\nIn this case my code has parsed the JSON, found the command to be FIREPLACE and \nthe option to be to turn it off. It then signaled the old JDS Timecommander to \nsend the X10 command and populated the MyResponse variable I used for speech \nresponse with the above. There are a couple other things going on there like the \n&#8220;Well,&#8221; which is from a random prefix response of things like &#8220;Well, OK, Thanks&#8221; \netc. just to keep it interesting. I also passed the device name and the option \nback to the echo to say to make it more logical.<\/p>\n\n\n\n<p>\nSince we set the shouldEndSession variable to true the Echo speaks the text and \nstops listening so you will have to say &#8220;Ask the house&#8221; or &#8220;Tell the house&#8221; \nagain to restart the session. If you just said &#8220;Open the house&#8221; the Echo sends a \nLAUNCHREQUEST request type and you should be prepared to leave the session open \nand do some interaction. What I do with a LAUCHREQUEST is send back &#8220;Ok, the \nhouse is listening, what do you want to do?&#8221; or similar and then you can speak \nthe command without having to say &#8220;Ask the house&#8221;. This requires sending back \nthe shouldEndSession as false. Currently once a command is received as after a \nlaunch request I still close the session to move on but you could work it out to \nkeep the session open and continue prompting.<\/p>\n\n\n\n<p>It&#8217;s really just basic JSON back and forth with your end point doing what you \nwant with the commands in the middle.<\/p>\n\n\n\n<h2>Home Automation Setup<\/h2>\n\n\n\n<h3>The SSL Side<\/h3>\n\n\n\n<p>On my home automation side I had to do a few things to make it all work. I&#8217;m \nsure there are multiple pages out there on how to setup your own SSL cert on a \nWindows personal web server. I found a few and used them to set mine up. I did \nhave to add another local net IP as the self signed certificate cannot be a \nwildcard on the Amazon side I found out the hard way and I have a couple other \nbasic domains on my server. I had to have the certificate set to the \nhouse.protowrxs.com domain but my www.protowrxs.com site is there too so I \nsimply added an additional IP and configured things around that. Remember you \nhave to expose port 443 on your router and port it over to your hosting machine \nas well. Once you an hit your site with https both locally and from the world \nyou should be able to export the certificate as an X.509 and past the BASE64 \ntext into the Amazon skill page.<\/p>\n\n\n\n<h3>The Code Side<\/h3>\n\n\n\n<p>Remember, I&#8217;m stuck in the 1990&#8217;s and still use Classic ASP for most of my \ncode. Don&#8217;t bitch, whine, and complain about it. It works but can be done in a \nmultitude of other languages as well so just assume the sample process and \nchange the details out as needed. If YOU are coding in Classic ASP then cool, \nyou should be able to copy\/paste and give things a try.<\/p>\n\n\n\n<h4>Getting the JSON<\/h4>\n\n\n\n<p>This was my first challenge as JSON post are not &#8220;gettable&#8221; by Request.Query \nor Request.Form commands and I found that out the hard way. Finally I found some \ninformation online how to stream the request into a variable and take it from \nthere. Not sure where I found it but it&#8217;s pretty straight forward code as \nfollows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">'** Get the body to process the JSON data\nIf Request.TotalBytes &gt; 0 Then\n\tDim lngBytesCount\n\tlngBytesCount = Request.TotalBytes\n\tjstring = BytesToStr(Request.BinaryRead(lngBytesCount))\nEnd If<\/pre>\n\n\n\n<p>\nOnce you have the JSON information in the jstring or whatever you like to call it we can parse it. \nBut how? It gets messy trying to roll your own unless you know what you&#8217;re doing \nand the ASP based JSON functions I found didn&#8217;t work for me at least. \nFortunately I rand across the JSON2.js library (<a href=\"https:\/\/github.com\/douglascrockford\/JSON-js\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/douglascrockford\/JSON-js<\/a>) \nby Douglas Crockford that works great and still \ninterfaces with the web server so I can get JScript variables into my ASP code. \nI guess that&#8217;s how it works but I&#8217;m a hack coder so not completely sure of the \nback&nbsp; side details. I just know it works for me.<\/p>\n\n\n\n<p>\nTo parse the JSON data I used this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;script language=\"JScript\"; runat=\"server\"; src=\"\/json2.js\"&gt;&lt;\/script&gt;\nSet myJSON = JSON.parse(jstring)\n'** First we check what type of request we have\n'** if an intent then we get our intent or command from Alexa\nMyRequest = UCase(myJSON.request.type)\n<\/pre>\n\n\n\n<p>Now I have that request type in the MyRequest variable and can move along \nfurther. The next thing is to see what type of request we have an act \naccordingly so I test it to see. If we have a SESSIONENDEDREQUEST then we had \nthat command from the Echo or Amazon cloud so make the response say I am no \nlonger talk to the house so the speaker knows the Echo needs different \ninformation and end the session. If we have a valid intent then default our \nresponse to expect failure by saying we didn&#8217;t understand that command but we \nare going to do to process the intent. If we get a LAUNCHREQUEST then we say \n&#8220;Open the house&#8221; so we leave the session open and ask the user what they want to \ndo. This is at least my hack as to how to deal with these initial. Likely I will \nneed to improve these over time but they seem to work for now. Note that we \nloaded up the intent.name in the MyCommand variable. This the what the intent \nwas figured out to be from your utterances so we need to try to do this.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\t'** if we get an end session then just send back the end info\nIf MyRequestIf MyRequest = \"SESSIONENDEDREQUEST\" then\n\tMyResponse = \"I am no longer talking to the house.\"\n\tMySessionEnd = \"true\"\n\tMyCommand = \"\"\nEnd If\n\nIf MyRequest = \"INTENTREQUEST\" then\n\tMyCommand = myJSON.request.intent.name\n\tMySessionEnd = \"true\" '** End the session as we have an intent\n\tMyResponse = \"Sorry, the house didn't understand that command \" &amp; MyCommand '** default this in case we cannot find a function\nEnd If\n\n'** If we have a launch request which is basically \"Alexa open the house\" we just send back the question\n'** They can then say turn on xx and we will get the intent back\n'** We may need to think about if we keep the session open after the intent of just close it\n'** leaving it open would allow multiple commands???\nIf MyRequest = \"LAUNCHREQUEST\" then\n\tMySessionEnd = \"false\"\n\tMyResponse = \"The house is listening, what do you want it to do?\"\nEnd If\n<\/pre>\n\n\n\n<p>So now we know we have an intent we need to get the details if required. Our \nexample is the FIREPLACE so we know we should have an &#8220;lcommand&#8221; to either turn \nit on or off. We need to get that value and then process it. For my system that \nmeans turning on an X10 device that the fireplace is hooked up to through the \nJDS Timecommand system. Your system will obviously be very different or maybe \nyou are talking to a local ESP8266 device by http to turn something on or off. \nLots of options but this is how my code works for this need.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">'** Simply turn on \/ off the fireplace command - THis is on an X10 module\nIf MyCommand = \"FIREPLACE\" then\n\tMyresponse = \"\"\n\tMyDeviceCmd = myJson.request.intent.slots.lcommand.value\n\tMyCommand = \"X\"\n\tMyDevice = \"FirePlace\"\n\tIf UCase(MyDeviceCmd) = \"ON\" then\n\t\tMyValue = 1\n\tElse\n\t\tMyValue = 0\n\tEnd If\n\tMyresponse = \"The Fireplace should now be turned \" &amp; MyDeviceCmd\n\nEnd If\n'** Then further down in the code...\n'** MyDevice is device name, value = 0 or 1\nIf MyCommand = \"X\" Then\n\tDevices.X10Devices.Item(Mydevice).State = MyValue\nEnd If\n\n<\/pre>\n\n\n\n<p>\nIf you wanted to have your home server hit an ESP8266 \non your local network you could easily accomplish that by simply connecting to the ESP URL and executing that command.\n\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\tSet objHttp = CreateObject(\"Msxml2.ServerXMLHTTP\")\n\tobjHttp.Open \"GET\", \"http:\/\/192.168.123.XXX\/gpio\/\" &amp; LEDcmd, False\n\tobjHttp.Send\n\tMyresults = objHttp.ResponseText\n\tMyResponse = \"The E S P device said \" &amp; MyResults\n\n<\/pre>\n\n\n\n<h3>System Response<\/h3>\n\n\n\n<p>So far we have received the request, parsed the JSON, found the type of \nrequest, and executed that request. The last thing is we need to respond back \nto the Echo and tell it what to say. Since for my purposes every response has \nsomething to say, I have the default JSON response hard coded and just dump the text to say \nand the session end variable into the response.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n\t\"version\": \"1.0\",\n\t\t\"response\": \t\"outputSpeech\": {\n\t\"type\": \"PlainText\",\n\t\"text\": \"&lt;%=MyResponse%&gt;\"\n},\n\t\"shouldEndSession\": \"&lt;%=MySessionEnd%&gt;\"\n\t\"sessionAttributes\": {}\n}}\n<\/pre>\n\n\n\n<p>The above &#8220;code&#8221; becomes the following response that goes back to the Amazon \ncloud.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\n{\n\t\"version\": \"1.0\",\n\t\t\"response\": \t\"outputSpeech\": {\n\t\"type\": \"PlainText\",\n\t\"text\": \"The Fireplace should now be turned off \"\n},\n\t\"shouldEndSession\": true\n\t\"sessionAttributes\": {}\n}}\n<\/code><\/pre>\n\n\n\n<p>The Echo now says &#8220;The Fireplace should now be turned off&#8221; and we&#8217;re done  with that request. Easy enough but anything can be done in between the request  and the return. You can have your code add cute little sayings at the beginning  and ending of your response, insert variables, etc. Nasty Mouthed For better or worse Alexa does NOT have a dirty mouth. Plugging in words like  Shit, BullShit, etc ends up with &#8220;bull&#8221;. I haven&#8217;t tried many  other words but it can be kind of funny to use some randomized nasty words when  things do not go right. For example, if something fails to work, I may send back  &#8220;Well shit, that didn&#8217;t work. Try that again please.&#8221; and you get Well S,  that didn&#8217;t work, Try that again please.&#8221; Humorous sometimes at least. Wrapping Up That&#8217;s the basics, you mileage will vary, your systems will be  different, your approach may be much better but that is how I have it  working for now. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Echo Dot \/ Alexa and Home Automation December 2016 09\/2017 Note: This is no longer used as it was designed for my old setup and the current Home Assistant (Hassio) solution has an integration for Alexa that pretty much plug and play. Along with having unsigned SSL cert issues back then, I simply gave up &hellip; <a href=\"https:\/\/www.protowrxs.com\/index.php\/home-automation\/talking-to-the-house\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Talking to the House&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":22,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"spay_email":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/pages\/565"}],"collection":[{"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/comments?post=565"}],"version-history":[{"count":1,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/pages\/565\/revisions"}],"predecessor-version":[{"id":572,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/pages\/565\/revisions\/572"}],"up":[{"embeddable":true,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/pages\/22"}],"wp:attachment":[{"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/media?parent=565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/categories?post=565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/tags?post=565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}