Sorry everyone, Google has broken this and added a reCaptcha to the login page that means that automation of logging in is now well and truly broken. It was great while it lasted but I don’t think it will be fixable.
Malcolm has come up with an android workaround thats worth a read dated.
I have also found another way that I will post once I have a more robust script. It uses headless chrome, python and selenium.
For anyone that has a Nest thermostat and an Amazon Alexa, they will know there is one feature distinctly lacking. Voice boosting of the hot water. After further investigation, this is not only missing from he Alexa app but is missing from the actual API. I think that this is probably due to the function being UK only.
Initially I took to the community pages to get more information. The first post dates back to Oct ’16 and the official line was “Thanks for letting us know that this is an important feature. Duly noted! We have communicated the extremely strong interest to our development team. The request is in the queue for consideration and will be seriously considered. We value your input, and we do not discuss future schedules or internal planning in this community.” This was mid August some time. Request #1 got closed for comments and so did all other threads. #2, #3 and finally #4. As a result of this I decided to make my own.
If you want to do this, you will need the following:
– Amazon Alexa
– UK Nest Thermostat (and online account)
– IFTTT account
– Webspace to host some php files
The basics of how this works are as follows:
1. Ask Alexa to trigger an IFTTT applet. By saying “Alexa trigger …..” Alexa knows that the following commands will be passed to IFTTT. My phrase was “Alexa trigger hot water boost” Thats the IFT part.
2. Configure the applet to use webhooks that will open a php file on a server. That’s the TT part.
3. The php file calls the class and boosts the hot water for a defined time. My aim was to make this as easy to follow as possible.
The drawback of this in its current state is that there is no feedback from Alexa if it has work or even if you have said the correct thing. Any time you say “Alexa trigger ….” she responds with “sending request to IFTTT” and doesn’t even know if there is an applet that matches you request.
As a bit of a disclaimer, I have only tested on a single UK Nest on my account so cannot guarantee that it will work with any others. Provided as is with no warranty etc. Feedback would be greatly appreciated either in the comments or on GitHub.
I have everything I need, how do I do it?
Step 1: Download the files (or fork) from Github. -> https://github.com/rdiver/nest-php-api-hot-water
Step 2: Edit the example files, setting a random key and enter your nest username and password. Then upload them with the class to your webspace and make a note of the url. The key variable is purely for security reasons, so that even if someone knows the url, they cannot do anything without the key, which can be any random character set. (within reason, I would stick to A-Z a-z 0-1)
Step 3: Link Alexa and IFTTT. -> https://www.amazon.com/gp/help/customer/display.html?nodeId=201790640
Step 4: Create the applet. Its pretty easy, screen 6 outlines the options to pass the key to your web page. The example code does output all of the calls to the web pages to a file called test.txt to make it easier to debug.
(1) (2) (3)
(4) (5) (6)
Step 5: Ask Alexa to “trigger hot water boost”!
Technical Information (incase anyone wants to port to different language)
If you ended up here you probably came through the Nest Community pages where you were searching regarding the lack of Hot Water API exposure. I know that not everyone will want to use PHP so I’m going to try and break down the basics of the reverse engineering so that you can port the code to another language / platform. This is only my understanding and could totally be wrong!
As highlighted in red, I need several things to boost the hot water. Firstly I need the request url, which is also referred to as the transport url. This was already covered in the library I forked but it can be found when you log in.
Secondly I need to create the payload that can be seen above.
session: From reading this post I worked out that the session variable was not required.
op: MERGE – this is fixed.
hot_water_boost_time_to_end: This is the epooch time that you would like the boost to end.
base_object_revision & object_key: object_key is the id of your nest thermostat, and my understanding is that the website creates a snapshot of the device settings used by the website called base_object_revision. After searching through the requests (for a long time) I found one that looked promising. The website makes the following call which returns the information I need.
From the code you will see that I only request the device bucket meaning I only get the information that I need.
I tried to make the code as simple as possible, so it will be easy to use or replicate/port. Any questions please ask.