Open brendandebeasi opened 5 years ago
got the same problem
Looks like Nest implemented recaptcha on the login page, effectively breaking automation. Not sure what else we can do. Tracking here as well: https://github.com/gboudreau/nest-api/issues/98
Solution from the above-linked repo:
I was able to get it working again by setting the USER_AGENT to 'Nest/5.0.0.23 (iOScom.nestlabs.jasper.release) os=11.0' and LOGIN_URL to 'https://home.nest.com/session'
Thank you @brendandebeasi, it works:
Index: nest.py
===================================================================
--- nest.py (revision 383)
+++ nest.py (working copy)
@@ -42,7 +42,7 @@
self.units = units
self.index = index
self.debug = debug
- self.headers={"user-agent":"Nest/1.1.0.10 CFNetwork/548.0.4",
+ self.headers={"user-agent":"Nest/5.0.0.23 (iOScom.nestlabs.jasper.release) os=11.0",
"X-nl-protocol-version": "1"}
def loads(self, res):
@@ -89,7 +89,7 @@
def login(self):
data = urllib.urlencode({"username": self.username, "password": self.password})
- req = urllib2.Request("https://home.nest.com/user/login",
+ req = urllib2.Request("https://home.nest.com/session",
data, self.headers)
res = urllib2.urlopen(req).read()
The above fix was working great in November ... I'm now trying to migrate my script to a new platform and discovering it's no longer working, not on the new platform, and not on the old platform were it was working when I first implemented it.
I'm now getting a "Bad Request for url: https://home.nest.com/session" - guessing it's not just me? Did they get wise to us and lock us out again? They REALLY want me to buy an Ecobee eh?
This explains why when I was walking past the thermostat earlier and noticed the temperature, I thought it was off (external) program!
Edit: New thread over on that other project where we found the last fix too - https://github.com/gboudreau/nest-api/issues/110 ... just reading it now
Edit2: I can't really figure out how to use the session data they talk about producing on there, and I have no temperature or fan controls right now, so I'm just going to use IFTTT, Webhooks and cURL for now! :-/ Google has been doing a REALLY good job of pushing me away for the last year ... this just puts me one step closer to switching to Echos and Eccobee and whomever else I need to invite into my life to get Google tf out. So sick of this crap.
Edit3: Everything up and running again with IFTTT, Webhooks and cURL - unfortunately that won't be a solution for everyone - from what I read, if you've switched to a Google account it won't work, and if your Nest account isn't already linked to your IFTTT account, you can not link it now, it's just sorta 'legacy support' they've got going for now. If you do already have IFTTT linked to your Nest account though, you can just create a recipe connected to Webhooks that takes a value for temperature, and then sets your temperature to that, and I created another without a value to fire the fan up for 15 minutes (which is the only action option there is for the fan), then I replaced all the calls to nest.py in my crontab and scripts with cURL calls to the correct Webhooks address with my key and all that.
Fan control doesn't work via IFTTT, literally the only thing you can do is change the temperature. We're not getting the new API until "late 2020" yet they've absolutely destroyed what we were using and are still actively dismantling it as is illustrated by us having had an issue in November, solving it, and now problems coming up again in early January.
I for one am done with Google's not giving a crap about their users. Between rebates from my provincial government and my hydro company, I can get an Ecobee3 Lite for about $100. I'll be picking it up tomorrow. I'm also thinking of selling all my Google Home units and replacing them with Amazon Echos.
Thank you @smbaker for the awesome library that has served me well for many years! Best of luck to everyone who sticks with Nest ... hopefully the situation gets better soon.
Thanks for the info, hyacin75 and gboudreau, including the original author @smbaker of this great library! I agree that Google could have handled this transition much better with all the current 3rd party integrations breaking, including IFTTT.
Based on this great info, below is my workaround/fix for this. I manually copy the contents of https://home.nest.com/session to a local file named 'nestcache' each month, and the updated login code below will read this file. Username and password are no longer relevant.
--- nest.py
+++ nest.py
@@ -6,6 +6,12 @@
# Usage:
# 'nest.py help' will tell you what to do and how to do it
#
+# GOOGLE WORKAROUND:
+# Every 30 days, copy the contents of https://home.nest.com/session to
+# a local file named 'nestcache'
+#
+# This only works if you have a Nest login and did not convert to a Google account
+#
# Licensing:
# This is distributed unider the Creative Commons 3.0 Non-commecrial,
# Attribution, Share-Alike license. You can use the code for noncommercial
@@ -48,14 +54,9 @@
return res
def login(self):
- data = urllib.urlencode({"username": self.username, "password": self.password})
-
- req = urllib2.Request("https://home.nest.com/user/login",
- data,
- {"user-agent":"Nest/1.1.0.10 CFNetwork/548.0.4"})
-
- res = urllib2.urlopen(req).read()
+ nestcache = open('nestcache','r')
+ res = nestcache.read()
res = self.loads(res)
self.transport_url = res["urls"]["transport_url"]
@@ -64,7 +65,7 @@
def get_status(self):
req = urllib2.Request(self.transport_url + "/v2/mobile/user." + self.userid,
- headers={"user-agent":"Nest/1.1.0.10 CFNetwork/548.0.4",
+ headers={"user-agent":"Nest/5.0.0.23 (iOScom.nestlabs.jasper.release) os=11.0",
"Authorization":"Basic " + self.access_token,
"X-nl-user-id": self.userid,
"X-nl-protocol-version": "1"})
We just started having an issue with our Nest Automation yesterday afternoon. It looks like the login endpoint is now returning a 406 error.
Reproduce:
Response: