Friday, June 26, 2015

A python script to control my Honeywell WiFi Thermostat

I was always jealous of Google Nest users who have such an open API to interface with their thermostat as well as the ability to connect to home automation hubs or services like IFTTT. I had bought a Honeywell WiFi Thermostat (RTH9580WF) because I got an amazing price on it. It always worked fine for me since it had a webpage as well as iOS and Android apps to control it. But now that I am interested in home automation, I am finding the Honeywell thermostat to be very limiting.

After scouring the web, I was able to find and hack a python script to be able to control my thermostat. Thanks to code from Brad Goodman, my modified version is working how I like it to.


Link to my python script


There are three things you need to edit to have the script work for you. First, edit the USERNAME variable with the email login and PASSWORD with the password to your mytotalconnectcomfort.com account. When you log in and enter the page for your thermostat control, the web url will contain the device ID for that thermostat. For example, web address https://mytotalconnectcomfort.com/portal/Device/Control/542695 means that my device ID is 542695. You will enter this number for DEVICE_ID in my python script without any quotation marks.

When downloading the script, remember to check that it has execution permissions with chmod +x therm.py on linux. You can see the arguments available by doing python therm.py -help. The following are the options available:
  • Cooling: -c temperature -t hold_time
  • Heating: -h temperature -t hold_time
  • Status: -s
  • Cancel: -x
The hold_time is in the unit of hours. so -t 1 would be 1 hour. The temperature is configured to be fahrenheit, but can be set to celsius. Cancel means to cancel the current temporary settings. And status prints the following:
% python therm.py -s
Indoor Temperature: 82.0
Indoor Humidity: 37.0
Cool Setpoint: 82.0
Heat Setpoint: 74.0
Hold Until : 0
Status Cool: 0
Status Heat: 0
An example of using the script to set the temperature to cool to 76F for 2 hours would be:
python therm.py -c 76 -t 2
In the future I will be showing how I use this script to allow my thermostat to be controlled by IFTTT and Amazon Echo.

71 comments:

  1. I tried playing with this script to control my Honeywell thermostat, but only some of the functions work.
    I can get to change the cool setpoint, cancel the hold, and show status.
    However, I can't get it to set the heat setpoint (it does the same thing as if I didn't use the right syntax). I also can't get it to hold for anything other than 1 hour.
    Am I doing something wrong, or does the script not able to do these thing?
    Thanks.

    ReplyDelete
    Replies
    1. Hi.

      You're right! I made a mistake of having the -h argument be used for both help and heat. I have fixed the help to be -help instead so the heat setting should work now. The code has been updated in the Github link.

      As for the time, it is set to only work with integers. So setting it to 2 hours, or 3 hours, should work. Based on the way it is set to calculate the time the way Honeywell wants it, anything smaller (like 1.5 hours) is not possible with the code.

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. I get this:
    Run at 2015-10-05 14:11:22.770361
    Mon Oct 5 14:11:23 2015 ErrorNever got redirect on initial login status=200 OK
    Anybody know why??

    ReplyDelete
    Replies
    1. Yeah, I just got the same thing, in my case it was a bad password.

      Delete
  4. did you get this to be able to use IFTT and amazon echo, i want this so Bad! as I have the Same Thermostat, and I quickly bought it thinking i would be able to control it Via IFTT and Amazon Echo..to no avail, you said in the future you would show it, it is now November and Cold here in WI.!! lol let me know...Thanks

    ReplyDelete
  5. I decided to go in a different direction. I used the Phython code as a guide to write equivalent PHP code (I'm more comfortable with PHP). I then created a Google Calendar specifically for my thermostat, and created entries when I want it to make changes (with the specific settings in the "Description" field of the event). I set it to send me an e-mail notification at the time the event starts, and I set up a rule in my Gmail to forward those to an address on my web host. That address redirects to my PHP script, which parses the notification, pulls out the commands, and sends them to my thermostat. I still have more work to do - I haven't added in fan or mode control yet, and I should add some error-checking - but it seems to work so far.

    ReplyDelete
    Replies
    1. Can you please share? I more familiar with PHP myself!

      Delete
  6. This is great. Thanks for all the work and input.
    Android: It was the password.
    Now.. does anybody know how to get status on 'emiheat'?
    I thought status return '0,1,2' would reflect 'no heat,heat,emiheat' but it does not.

    ReplyDelete
  7. Hey

    On the request to /portal/Device/CheckDataSession/DEVICE_ID I get a 500 server error. I've retried the URL in chrome and I get the same result.. I have the same unit as you link to above. I'm in the US if that makes any difference

    ReplyDelete
  8. Thanks so much for your work on this, I am so close but hitting just a couple errors. Alexa reads me the proper temp from thermostat. And when I ask her to change temp she says shes doing it but it never reflects a change on totalcomfort, the hold time reflects a change but not the temp. She even says the temp is set to *new* degrees if I ask her for settings, but it does not actually change on the device. And when I run this script from command I always receive:
    print "Indoor Temperature:",j['latestData']['uiData']["DispTemperature"]
    syntax error

    seems weird, any ideas? thank you again!

    ReplyDelete
    Replies
    1. Strange that you are getting a syntax error when running the script directly.

      Did you copy and paste the code to a file or download it directly? I would go back to github, click the raw button on the top right and then do a File > Save from your web browser.

      Delete
    2. Replace the double quotes with single quotes around DispTemperature.

      Delete
    3. Replace the double quotes with single quotes around DispTemperature.

      Delete
  9. This may help others with the same problem: If you get print statement syntax errors the issue most likely is the version of Python. The latest Python version is 3.5.1 but this script is written for an earlier version. I switched to Python 2.7 which is the last version of the Python 2.x series and this script runs perfectly!!!

    ReplyDelete
  10. This may help others with the same problem: If you get print statement syntax errors the issue most likely is the version of Python. The latest Python version is 3.5.1 but this script is written for an earlier version. I switched to Python 2.7 which is the last version of the Python 2.x series and this script runs perfectly!!!

    ReplyDelete
  11. Well, I'm new to Python, but have everything installed, fixed an indentation error (last line), and the "help" command works... but when I try to run it "for real," I get this error:

    Error Didn't get 200 status on R4 status=500 Internal Server Error

    Uhm... what do? Thanks in advance!

    ReplyDelete
  12. Something about heavy to semi-heavy technological jargon really sooths me. I hope you have more posts like this. It feels to me like a completely different world. Luckily my husband actually understood it (I'm so embarrassed) and was absolutely delighted. I'll let you know how things go (looking forward to your next instructional piece).

    Ambrose @ Brown & Reaves Services, Inc.

    ReplyDelete
  13. Nice script, Dan, worked first time. I was looking for a way to monitor my house temperature from my Home Security script, and this fits the bill. I also wanted to track my house temperature as it cools down in the evenings after I go to bed. I added a print for the time/date into your status function, and scheduled it using cron, and I was able to get an hourly temperature - and as I suspected it takes a LONG time for the house to cool. I've now set the night temperature an hour earlier, and I'm saving many dollars in heating costs - thanks!

    ReplyDelete
  14. I successfully used this script to poll my Honeywell wifi thermostat purchased from Home Depot. The back has two model numbers - TH6320WF02 and RTH6580WF1001. I'll go with the latter on since this post refers to one that starts with the same prefix. My unit was about $100 which is a deal compared to NEST at $249. My only problem was I had to get the DEVICE ID from a different place than the URL as suggested above. If you use that device ID, you'll get a SERVER ERROR when the python script runs. The trick here is to go to Honeywell's website and log in to your account. Navigate until you have the graphic of your thermostat loaded on your screen then view the PAGE SOURCE in your browser. There is an XML tag for DEVICE ID which will be different than the number used in the URL for that page. That's the one you need to use.

    ReplyDelete
  15. So awesome! Worked right away. I worry with these proprietary frameworks, but fortunately they're not that sophisticated. Without doing too much research, I had leaned towards some open framework/rasperrypi thing, but you allow me to run my own optimizations. Thanks

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
  17. is there a way to ignore the thermostat temperature reading, or set it to a fixed value?

    ReplyDelete
  18. When I run the script I get this output:

    Error Didn't get 200 status on R4 status=500 Internal Server Error

    Any idea on how to fix this?

    ReplyDelete
    Replies
    1. I am able to get status, start/stop fan, set cool just fine but when I try to set heat, I get the same error message. I just scoured the code and did not find anything that stood out.

      Delete
  19. urls are different for international users (i'm in the uk), getting the 200 status.
    url from webpage is https://international.mytotalconnectcomfort.com/Locations/View/123456

    ReplyDelete
  20. Hi,
    I am wondering if you had a chance to see if control of the thermostat is possible using LAN communication (i.e without going to the outside world, myTotalConnectionComfort.com...) ?

    Thanks

    ReplyDelete
  21. Hi Dan,

    Are you aware of any rate limiting/throttling on accessing the page every 5 mins or so? I only wanted to get the stats of the system and when I set the cron job to run on a frequency less than 10 minutes it starts to log redirect errors. Thoughts?

    Thanks!

    ReplyDelete
  22. These kind of article are fairly good for a programmers. Thanks for putting the source code here. Heating and Cooling Hamilton

    ReplyDelete
  23. Thanks for sharing the post.. parents are worlds best person in each lives of individual..they need or must succeed to sustain needs of the family.
    WiFi Hacking Apps For android mobile

    ReplyDelete
  24. for those of you wanting to run this on Python 3.x, there is a 2to3.py script that will convert Python 2 scripts. It's in [Python folder]\Tools\Scripts. I just used it on a rather large Python 2.6 project (lots of scripts and sub folders) and it worked like a champ. I am currently using Python 3.7.

    ReplyDelete
  25. I know this is one of the most meaningful information for me. And I'm animated reading your article. But should remark on some general things, the website style is perfect; the articles are great. Thanks for the ton of tangible and attainable help. IP Address

    ReplyDelete
  26. Tragically this demonstrated practically outlandish by and by. The present AI will in general center around quite certain issues and information zones. artificial intelligence course

    ReplyDelete


  27. 192.168.0.1

    192.168.1.1

    router login
    Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now,

    ReplyDelete
  28. 192.168.1.254

    192.168.l.254

    192.168.1.1

    192.168.o.1

    192.168.l0.1

    192.168.l.l

    192.168.o.1

    is a Private IP address and most powerful universal IP addresses, this is used in the Linksys router.

    ReplyDelete
  29. Thanks for the valuable information and insights you have so provided here.

    192.168.l.l
    192.168 l 254
    192.168.0.1

    ReplyDelete
  30. I thought I was strong with my ideas on this, but with your writing expertise you have managed to convert my beliefs your new ideas. Mallorca is fun
    Best Data Science training in Mumbai

    Data Science training in Mumbai

    ReplyDelete
  31. It also gives some tips on training your own self. So, we feel by virtue of this article, you, the readers are able to develop some basic ideas related to the whole concept. artificial intelligence certification

    ReplyDelete
  32. The development of artificial intelligence (AI) has propelled more programming architects, information scientists, and different experts to investigate the plausibility of a vocation in machine learning. Notwithstanding, a few newcomers will in general spotlight a lot on hypothesis and insufficient on commonsense application. machine learning projects for final year In case you will succeed, you have to begin building machine learning projects in the near future.

    Projects assist you with improving your applied ML skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include projects into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Final Year Project Centers in Chennai even arrange a more significant compensation.


    Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account.

    ReplyDelete

  33. 192.168.1.1 is one of the most common IP addresses a router network.

    ReplyDelete
  34. I also purchased Honeywell WiFi Thermostat (RTH9580WF) last week. Gonna try your python script so I can finally enjoy the features of this Thermostat. I recommend this furniture stores where you can choose from different style and size of furniture online. dress up unique characters, play mini games, and gacha in gacha life!

    ReplyDelete

  35. Routers are the most important devices that are required to get the internet connectivity. There are many brands and router models around the globe. Most people use multiple brand routers, they don't know how to configure them for the perfect usage. Here at router-networks.com we have all the manuals for configuring the router login pages.

    ReplyDelete
  36. Thank you very much for this. Still working! Super annoying that Honeywell didn't allow for local control, so this is as good of a solution as can exist.

    ReplyDelete
  37. Ocay, I no this is a bit over 5 years old, but I just downloaded therm.py, ran it through 2to3, and it works great on python 3.9.2! I'd like to use it to get and set the mode too, off/heat/cool. Can you tell me if there is an updated script, or where I can find the api to see about adding it? Google seems to be uneducated in the ways of the thermo-jedi.

    I like the script because I can't see, and this gives me more info and more control than she who must not be named, Amazon's assistant. Yah, Alexa, but she who must not be named seems much cooler.

    Thanks for reading.

    ReplyDelete

  38. This configuration can also be used for devices like Router, Modem etc. and they are all having the initial IP address


    192.168.10.1
    https://www.enewsmango.com/192-168-0-1/

    ReplyDelete
  39. That is a very good tip especially to those new to the blogosphere.
    Short but very accurate info… Appreciate your sharing this one. A must read post.

    My web site - 휴게텔

    ReplyDelete
  40. I'm genuinely getting a charge out of scrutinizing your richly formed articles. Apparently you consume a huge load of energy and time on your blog. I have bookmarked it and I am expecting scrutinizing new articles. Continue to do amazing.data science course in ghaziabad

    ReplyDelete
  41. I'm genuinely getting a charge out of scrutinizing your richly formed articles. Apparently you consume a huge load of energy and time on your blog. I have bookmarked it and I am expecting scrutinizing new articles. Continue to do amazing.business analytics course in ghaziabad

    ReplyDelete
  42. Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing.data science course in bhubaneswar

    ReplyDelete
  43. It is perfect chance to make a couple of game plans for the future and the opportunity has arrived to be sprightly. I've scrutinized this post and if I may I have the option to need to suggest you some interesting things or recommendations. Perhaps you could create next articles insinuating this article. I have to examine more things about it! https://360digitmg.com/course/project-management-professional-pmp

    ReplyDelete
  44. 360DigiTMG, the top-rated organisation among the most prestigious industries around the world, is an educational destination for those looking to pursue their dreams around the globe. The company is changing careers of many people through constant improvement, 360DigiTMG provides an outstanding learning experience and distinguishes itself from the pack. 360DigiTMG is a prominent global presence by offering world-class training. Its main office is in India and subsidiaries across Malaysia, USA, East Asia, Australia, Uk, Netherlands, and the Middle East.

    ReplyDelete
  45. I like your post. I appreciate your blogs because they are really good. Please go to this website for Data Science course in Bangalore. These courses are wonderful for professionals.

    ReplyDelete
  46. Thanks for sharing this great article we appreciate it, we provide instagram reels download freely and unlimited.

    ReplyDelete
  47. It's late finding this act. At least, it's a thing to be familiar with that there are such events exist.
    I agree with your Blog and I will be back to inspect it more in the future so please keep up your act.
    360DigiTMG data science course

    ReplyDelete