Preparing your webserver
While you are capable of using Amazon's AWS Lambda free tier for this, I will be covering how to do it with your own server. You need to have a web server that is accessible online and is configured to use HTTPS SSL encrypted connections. Amazon enforces HTTPS for the Echo. But you can create your own self-signed certificate and supply it to Amazon as a temporary development solution. For a cheap SSL certificate, I use Comodo Positive SSL.
Python script for My Total Comfort
Make sure you have configured my python script, as mentioned on my previously article, and that it is working correctly. Also verify that it is executable by the same user that runs your web server (http, www-data, wwwuser, etc...).
PHP file to interface with the Amazon Echo
You will need my PHP file that the Amazon services will send the request from your Echo to. The one I created is a modified version thanks to OurAce.com. Their version is available here. I am not very experienced with web-based programming, so I am glad they provided that 'Hello World' example that I can hack.
Link to my PHP file
Place the PHP file in a directory that will be accessible by Amazon through the web. Make sure to edit the variable $cmd to correctly point to where you have the thermostat python script!
I have added comments and set configurations as variables so you can copy my PHP file and use it for any other projects that would like to interact with Alexa. The section of interest would be Responses. You set two things: 1. The speech Alexa will respond with. 2. The little web card that appears on your Echo homepage.
Create an Alexa Skill
If you do not have one already, create an Amazon developer account. We will create a new "Alexa Skills," which is what Amazon calls the scripts/applications that the Amazon Echo can use.
When ready, go to your Developer Console. At the top menu go to App & Services, and then select Alexa in the submenu.
When ready, go to your Developer Console. At the top menu go to App & Services, and then select Alexa in the submenu.
Skill Information
- Click on the Add a New Skill button.
- Set the Name to be any name you want to call this Skill (for reference).
- The Invocation Name will be the name you tell Alexa to let it know it is your application. I set it to thermostat.
- Set the Endpoint to the address you have the PHP file on your web server.
- Press Next.

Interaction Model
- The Intent Schema is the JSON data structure that our PHP file will be parsing. You pair a name with a data type. Data type options are available here. The structure I am using is below:
- The Sample Utterances is very important! This is essentially how the Echo will understand what you are saying. You should place every type of voice combination that you think you will say. The first word, in this case SetTemp, references the data structure in the Intent Schema. The rest are words that are to be said after "Ask Invocation_Name." So for my setup with the Invocation Name thermostat, I will not be writing the "Ask thermostat" part here. I will add any words that follow it. Do not use any numbers- spell everything out. My structure is below:
- Press Save to check for errors. Then press Next.
{ "intents": [ { "intent": "SetTemp", "slots": [ { "name":"action", "type":"LITERAL" }, { "name":"temp", "type":"NUMBER" }, { "name":"duration", "type":"NUMBER" } ] } ] }
SetTemp {eighty|temp} degrees SetTemp {eighty one|temp} degrees SetTemp {eighty two|temp} degrees SetTemp {eighty three|temp} degrees for {one|duration} hour SetTemp {eighty four|temp} degrees for {two|duration} hours SetTemp set my temperature to {eighty |temp} SetTemp set my temperature to {eighty one|temp} degrees SetTemp set my temperature to {eighty two|temp} fahrenheit SetTemp set my temperature to {eighty |temp} for {one|duration} hour SetTemp set my temperature to {eighty one|temp} degrees for {two|duration} hour SetTemp set my temperature to {eighty two|temp} fahrenheit for {three|duration} hour
SSL Certificate
Select the corresponding certificate setup that you are using. If you are using a purchased SSL certificate that is correctly set up, keep the first option. The other options are self-explanitory.
Testing
You are now ready to begin testing your script. Go to your Echo homepage. On the left side you should see Skills under Alarm. Go in there and make sure the Skill we created is enabled. If you are using my setup, you can now ask Alexa to control your thermostat. Some examples are:
- Alexa, ask thermostat for status.
- Alexa, ask thermostat for settings.
- Alexa, ask thermostat for 78 degrees.
- Alexa, ask thermostat for 78 degrees for two hours.
- Alexa, ask thermostat to cancel.
If Alexa does not respond with anything after you ask it, check the Sample UtteIrances you have set. It is very picky. For example, I had "eighty one" as an invocation. So when I said "eighty," it did not understand and I had to add it.
If Alexa responds that there was an error, check the Echo homepage for more information such as an issue with your SSL certificate. Use your web card to debug as well as PHP error_log functions to get more information.
Success!
I would prefer to say "Alexa, set thermostat..." but it seems to be a keyword reserved for other devices. Alexa will reply that there are no devices set up with that name. Hopefully my steps have been successful for you and you are now dangerous with the Amazon Echo. I found the Echo to be a great additional to my home automation setup! I'm excited to see more creative applications people can come up with.
I was hoping that this was possible so thanks for putting it up here!
ReplyDeleteI did have a question about using this on Lambda. I have everything set up on Lambda and have the trigger set to Alexa. When asked, Alexa says that it can't communicate with my Honeywell app. I have limited programming knowledge but my thought was that since I don't have your PHP code anywhere (on a web server), then this isn't going to work. So my question is can your python code work alone with Lambda or do I need to have the PHP used (for triggering, etc.).
I'm not looking for tech support so if this is more than a brief answer, I'll just set up the web server per your instructions and go from there. I thought using Lambda might be an easier solution for me.
Thanks!
Hi Mark! Thanks for checking out my article.
DeleteYou are correct. The Python script does not have the ability to talk directly with the Echo service. When Amazon does not receive a reply, it will say it could not communicate. The PHP code acts like the middle-man between Amazon and the Python script. It will capture the request from Amazon and then give it the reply Amazon is looking for.
I am not too familiar with Lambda, but it seems it could handle the Python part but not the PHP part.
Your sample utterances doesn't include status or settings. How can you say "Alexa, ask thermostat for status." if it's not in the sample utterances?
ReplyDeleteYou are correct that it is required. My example did not fully include everything. My complete set is:
DeleteSetTemp {cancel|action}
SetTemp {status|action}
SetTemp {settings|action}
SetTemp {eighty|temp}
SetTemp {eighty one|temp}
SetTemp {eighty two|temp}
SetTemp {eighty three|temp}
SetTemp {eighty|temp} degrees
SetTemp {eighty one|temp} degrees
SetTemp {eighty two|temp} degrees
SetTemp {eighty|temp} degrees for {one|duration} hour
SetTemp {eighty three|temp} degrees for {two|duration} hours
SetTemp {eighty four|temp} degrees for {three|duration} hours
SetTemp set my temperature to {eighty |temp}
SetTemp set my temperature to {eighty one|temp} degrees
SetTemp set my temperature to {eighty two|temp} fahrenheit
SetTemp set my temperature to {eighty |temp} for {one|duration} hour
SetTemp set my temperature to {eighty one|temp} degrees for {two|duration} hour
SetTemp set my temperature to {eighty two|temp} fahrenheit for {three|duration} hour
This comment has been removed by the author.
ReplyDeleteI tried this step by step, and as it is my first time to ever attempt something like this, Alexa says there was a providence with the requested skills response. Any pointers?
ReplyDeleteDoes Amazon ever reach your server? It could be an issue with the SSL certificate. If Amazon doesn't like it, it kills the connection immediately.
DeleteWhen debugging, I would put error_log() statements in the php file to know where exactly the session would die.
I am using a Mac and have set up the Python script with no problem as I have done it with Smartthings and plan to host it on the Amazon's AWS Lambda free tier. But from there on I am lost, is there any more details or an easier step by step? I hate being a pain in the butt, but I am really confused with this.
ReplyDeleteI would like to get it working with AWS Lambda too, but since they only allow JavaScript the entire script would need to be converted from python. I would like to eventually take a shot at trying to port it though.
DeleteI just got it working on a Debian box after trying first on Raspberry Pi and then Ubuntu. My biggest obstacle was the SSL stuff but finally got that fixed this morning after 6 hours the day before.
ReplyDeleteNow I'm trying to find the API so I can expand on what it does. I would like to turn the fan from Auto to Circulate to Off and a few other things but your program doesn't really tell me what the other stuff requires.
I do want to thank you for the excellent documentation though.
Another user seems to have commented on adding the fan on the bottom of the github page:
Deletehttps://gist.github.com/ghostbitmeta/694934062c0814680d52
I will take a look at it and merge it in when I get the chance.
The python script works great on my server. But no matter what I try Echo tells me it has a problem communicating with requested skill. I have my own self signed certificate on apache server running on Ubuntu. Getting skills to work with the echo is very frustrating.
ReplyDeleteI know my server is open as I can reach it via https so that is not the issue. I have the python and php files both in my var/www/html folder and have the $cmd line in php pointing to /var/www/html/echo.php also tried just echo.php. I suspect the issue is somewhere in the certificate but no idea where to start.
Have you taken a look yet at Amazon's documentation for using self-signed certs?
Deletehttps://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/testing-an-alexa-skill#Configuring%20Your%20Web%20Service%20to%20Use%20a%20Self-Signed%20Certificate
What do you have your echo.php and therm.py chmoded to?
ReplyDeleteNever looked at that. What should it be? I do not do much Linux so bare with me.
DeleteHi,
DeleteMy echp.php is set to 644: RW for owner and read for others. therm.py is set to 755, allowing anyone to execute it.
This comment has been removed by the author.
ReplyDeleteHi
ReplyDeleteWhat to do, if I have more than one Honeywell RTH9580WF WiFi thermostat?
I have three for three zones. Any idea appreciated.
Thanks
Jozsef
I just got my Echo for Christmas and I've been scouring the internet to learn more about providing custom programmed tech for it. Thank you for providing a wonderful post on setting up a thermostat with this.
ReplyDeleteI wanted to note that now LetsEncrypt.org is live and out of beta, so getting Free SSL certs is easy :)
Echo skill to control Honeywell WiFi is now available.
ReplyDeleteHi. It was very interesting to read. Thanks for sharing. Smart home is very popular now. I've tried to make my air conditioning system a part of general controling device, but I failed. I've asked this guys http://myairmatics.com/ for help and they helped me out. I decided to get an AC controll over my phone for now.
ReplyDeleteDan, my name is Scott. I have some questions I'd like to ask you about the Honeywell script (I wish to have the thermostat set as a result of data coming from my solar array). How can I reach you by email? Perhaps email me, and I can reply? My address is my name, sterlingservices is the domain, and it is the original commercial TLD. Sorry, but spam, y'know! :)
ReplyDeleteHi, I hacked your PHP code about to do something slightly different for my own purposes: https://gist.github.com/Westlad/d6c72a0e6597e9723dcc974018e9eae0
ReplyDeleteI just wanted to check you are ok with that, as the original author.
No problem!
DeleteI was reading some of your content on this website and I conceive this internet site is really informative ! Keep on putting up. Unique wifi names
ReplyDeleteI am come here first time, i find the perfect article. Thanks for sharing interesting and informative post. lemigliorivpn.com
ReplyDeleteI couldn't locate the ideal words to value this. This is genuinely one in a millions.
ReplyDeleteclicca qui
The post you wrote which is full of informative content. I Like it very much. Keep on posting!!
ReplyDeleteAngularjs Training in Chennai
Angularjs course in Chennai
Big Data Training in Chennai
German Classes in Chennai
AngularJS Training in Porur
AngularJS Training in Velachery
AngularJS Training in Adyar
I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts.
DeleteCyber Security Projects for Final Year
JavaScript Training in Chennai
Project Centers in Chennai
JavaScript Training in Chennai
Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. 192.168.0.254
ReplyDeleteThese points are to be noted. These services must be under taken before winter. In order to safe yours HVAC unit. Heating and Cooling Ottawa
ReplyDeleteExcited by the writer's ability to write in this magnificent way.
ReplyDeleteAlexa.Amazon.com
Yes, usually and yet as many companies attempted to streamline their distribution systems, inventory warehouses and cut costs, check over here
ReplyDeleteThe counter radiation WiFi modem recieving wire boxes can retain the electromagnetic radiation and afterward convert it into heat vitality expend, which would not cause the subsequent contamination. wifi router
ReplyDeleteGood job! Fruitful article. I like this very much. It is very useful for my research. It shows your interest in this topic very well. I hope you will post some more information about the software. Please keep sharing!!
ReplyDeleteSEO Training in Chennai
SEO Training in Bangalore
SEO Training in Coimbatore
SEO Training in Madurai
SEO Course in Chennai
SEO Course in Chennai
SEO Course in Bangalore
SEO Course in Coimbatore
Rather than put off repairs to your major home appliances, you should deal with appliance problems right away. Sears Appliance Repair
ReplyDeletehttps://memorialdaydeal.com Wonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Appreciate it.
ReplyDeleteWhat's more, practically most families would interface an additional WiFi router regardless of whether they as of now have a wired web so they can utilize their cell phones anyplace in the house. modem router
ReplyDeleteReally awesome blog!!! I finally found great post here.I really enjoyed reading this article. It's really a nice experience to read your post. Thanks for sharing your innovative ideas. Excellent work!
ReplyDeleteDigital Marketing Training Course in Chennai | Digital Marketing Training Course in Anna Nagar | Digital Marketing Training Course in OMR | Digital Marketing Training Course in Porur | Digital Marketing Training Course in Tambaram | Digital Marketing Training Course in Velachery
Thanks for sharing this with us it is a worth read.
ReplyDeleteDigital Marketing Training Course in Chennai | Digital Marketing Training Course in Anna Nagar | Digital Marketing Training Course in OMR | Digital Marketing Training Course in Porur | Digital Marketing Training Course in Tambaram | Digital Marketing Training Course in Velachery
Selecting a promotional product that suits the likings and temperament of customers or clients Technology
ReplyDeleteIf there is a Power Save mode option, it is better the user turns it off completely from the drop down list. As it is found that the laptop saves power by tuning down the wireless adapter, which may cause less performance due to decreased WiFi signal. Funny WiFi Names
ReplyDeleteI appreciate this article for the well-researched content and excellent wording. I got so interested in this material that I couldn’t stop reading. Your blog is really impressive. https://wifibooster.link/
ReplyDeleteThis blog was really good formatting, thanks for sharing with us. Visit Ogen Infosystem for professional website designing and digital marketing services at good price.
ReplyDeleteWebsite Designing Company in Delhi
Đại lý vé máy bay Aivivu, tham khảo:
ReplyDeleteVe may bay di My
đặt vé máy bay giá rẻ từ mỹ về việt nam
lịch bay từ canada về việt nam
mở lại đường bay việt nam - hàn quốc
wonderful article contains lot of valuable information. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. . AWS Training in Chennai Velachery OMR
ReplyDeleteAppreciate it! An abundance of posts.
ReplyDeleteHere's my website : --대구오피
List with Confidence Real Estate Company all of our agents are long time locals and experts in the local real estate market. Find out about them here.
ReplyDeletereal estate marketing agency toronto
real estate marketing companies canada
Grammarly Crack Free Download that is number one software in the whole world people. The program for Windows PC will make user messages, it's provides the .! Grammarly Crack
ReplyDeleteThis very informative and interesting blog.
ReplyDeleterent a car in lahore
This very informative and interesting blog.
ReplyDeleteSecurity Services
This very informative and interesting blog.
ReplyDeleteTruck Repair Shop
This very informative and interesting blog.
ReplyDeleteproperty brokerage