I made a crappy Nest Thermostat integration that will work as a stopgap until alternatives come out

I didn’t have a problem with recaptcha. I’ll think on it some more.

Interesting… I’ve just done a restart and now I’m getting the same error. It feels like a change on the Nest side.

Hi,

First of all Wow what a nice job! I had already gave up after buying me nest doorbell and a moth to late to create a dev account. I just want to give your integration a go from the netherlands (EU) connecting my doorbell. But i don’t see any errors nor seeing andere entities in developer tools /states. Where can i find issue logging ?

These are my HA log warning/error entries:

2020-01-03 00:21:02 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /home/homeassistant/.homeassistant/configuration.yaml contains duplicate key “primary-color”. Check lines 155 and 160.
2020-01-03 00:21:02 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /home/homeassistant/.homeassistant/configuration.yaml contains duplicate key “text-primary-color”. Check lines 157 and 170.
2020-01-03 00:21:02 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /home/homeassistant/.homeassistant/configuration.yaml contains duplicate key “primary-background-color”. Check lines 164 and 180.
2020-01-03 00:21:02 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /home/homeassistant/.homeassistant/configuration.yaml contains duplicate key “primary-text-color”. Check lines 168 and 186.
2020-01-03 00:21:02 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /home/homeassistant/.homeassistant/configuration.yaml contains duplicate key “light-primary-color”. Check lines 163 and 188.
2020-01-03 00:21:02 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /home/homeassistant/.homeassistant/configuration.yaml contains duplicate key “secondary-text-color”. Check lines 169 and 189.
2020-01-03 00:21:02 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /home/homeassistant/.homeassistant/configuration.yaml contains duplicate key “disabled-text-color”. Check lines 171 and 190.
2020-01-03 00:21:02 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /home/homeassistant/.homeassistant/configuration.yaml contains duplicate key “secondary-background-color”. Check lines 165 and 192.
2020-01-03 00:21:02 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /home/homeassistant/.homeassistant/configuration.yaml contains duplicate key “automation.ikwilwater”. Check lines 289 and 291.
2020-01-03 00:21:02 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /home/homeassistant/.homeassistant/configuration.yaml contains duplicate key “automation.telegram”. Check lines 281 and 297.
2020-01-03 00:21:03 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for badnest which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2020-01-03 00:21:04 ERROR (SyncWorker_18) [xiaomi_gateway] The device with sid 158d00044bd814 isn’t supported of the used gateway firmware. Please update the gateway firmware if possible! This is the only way the issue can be solved.
2020-01-03 00:21:04 ERROR (SyncWorker_18) [xiaomi_gateway] The device with sid 158d0003f45479 isn’t supported of the used gateway firmware. Please update the gateway firmware if possible! This is the only way the issue can be solved.
2020-01-03 00:21:04 WARNING (MainThread) [homeassistant.components.mqtt] Data in your config entry is going to override your configuration.yaml: {‘broker’: ‘192.168.13.13’, ‘discovery’: True, ‘password’: ‘xxxxxxxxxxx’, ‘port’: 1883}
2020-01-03 00:21:04 ERROR (Thread-2) [homeassistant.components.mqtt] Unable to connect to the MQTT broker: Connection Refused: not authorised.
2020-01-03 00:21:05 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for xiaomi_gateway_alarm which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2020-01-03 00:21:09 WARNING (MainThread) [homeassistant.components.template.sensor] Could not render template Power Plug Power Consumption, the state is unknown.

This is my config:

badnest:
  issue_token: "https://accounts.google.com/o/oauth2/iframerpc?action=issueToken&response_type=token%20id_token&login_hint=AJDLj6LQu-SMCQLMxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxt&ss_domain=https%3A%2F%2Fhome.nest.com"
  cookie: "OCAK=D1-Xm6rdfxxxxxxxxxxxe0wAjQ9sxxYujCxxm0; SMSV=ADHTe-AcEUl564fkTotJ_pxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxvDMVjZld1DHitVKnyS"
  region: eu #(also tried nl)

i scrambled the cookie and token of course with “x” hope i did not destroyed to much to troubleshoot. (or kept to much)

(recently moved to google auth with 2fa, home.nest.com workst.)

Again Many thanks!

I have a very similar project… @ninjaballs - did you ever figure out why one of your thermostats is missing?

Since I have no “Works with Nest” products of value, I’ve converted over as well. I can also verify using Google login (OAuth2), badnest is now back functional.

Everything was working fine until today’s reboot, now I’m now getting this. Anything I can do?

Error during setup of component badnest
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/setup.py”, line 176, in _async_setup_component
component.setup, hass, processed_config # type: ignore
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/badnest/init.py”, line 49, in setup
region,
File “/config/custom_components/badnest/api.py”, line 54, in init
self.login()
File “/config/custom_components/badnest/api.py”, line 74, in login
self._login_nest(self._email, self._password)
File “/config/custom_components/badnest/api.py”, line 81, in _login_nest
self._user_id = r.json()[“userid”]
KeyError: ‘userid’

1 Like

Same here, this just popped up on mine.

Yup, I’m going to say it definitely does appear to be a Nest change. I’m fixed, but I did have to convert to Google auth.

Note: since eventually Google is going to find some-way to force people to merge accounts. It might be better to do it sooner rather than later if you don’t have any dependent “Works with Nest” service.

Hello! Just moved to google auth because of the error from above (userid not found) and now I have this error. Any idea how to fix it ?

Fri Jan 03 2020 10:38:04 GMT+0200 (Eastern European Standard Time)
Error during setup of component badnest
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 176, in _async_setup_component
    component.setup, hass, processed_config  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/badnest/__init__.py", line 49, in setup
    region,
  File "/config/custom_components/badnest/api.py", line 54, in __init__
    self.login()
  File "/config/custom_components/badnest/api.py", line 72, in login
    self._login_google(self._issue_token, self._cookie)
  File "/config/custom_components/badnest/api.py", line 92, in _login_google
    r = self._session.get(url=issue_token, headers=headers)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 313, in prepare
    self.prepare_url(url, params)
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 387, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL '': No schema supplied. Perhaps you meant http://?

Just verified Issue and cookie variables, everything seems ok in the config setup.

My thermostat and protects work great for me but my cameras have never shown up. Anyone know which country code I should be using for Canada? I’ve tried us and ca, but nothing.

It looks like the issue_token url is incorrect. The url itself needs to be in double quotes.

Hello,

Just trying to set this up and I’m getting the same login errors as reported above:

2020-01-03 11:16:42 ERROR (MainThread) [homeassistant.setup] Error during setup of component badnest
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 176, in _async_setup_component
    component.setup, hass, processed_config  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/badnest/__init__.py", line 49, in setup
    region,
  File "/config/custom_components/badnest/api.py", line 54, in __init__
    self.login()
  File "/config/custom_components/badnest/api.py", line 74, in login
    self._login_nest(self._email, self._password)
  File "/config/custom_components/badnest/api.py", line 81, in _login_nest
    self._user_id = r.json()["userid"]
KeyError: 'userid'

Here is my configuration.yaml:

# Nest Integration
badnest:
  email: [email protected]
  password:  !secret nest_password
  region: ca

climate:
  - platform: badnest
    scan_interval: 10

sensor:
  - platform: badnest

Any help is much appreciated!

It seems like if you try to follow these instructions, you can get your region shortcut: (check the badnest api.py and compare the stream link from nest.com…)

1 Like

Says right there in your last line:

requests.exceptions.MissingSchema: Invalid URL '': No schema supplied. Perhaps you meant http://?

issue_token URL appears to be invalid. Take a look there. Verify it’s fully quoted and contains initial URL protocol.

It appears Google (Nest) made a change to their login method (to block bots?). It’s breaking all automation scripts due to a new recaptcha variable for authentication.

I, and a few others here, got back working by finally merging our Google account and using the Google auth method.

so it sounds like the preferred method is to use the Google Auth?

Well, it’s been known for some time Google’s going to completely remove Nest auth at some point. So, unless you have dependent “Works with Nest” connections, you’re better off just going to Google Auth, esp. since badnest now works with it.

Previously holding onto Nest Auth was a method of getting HA to work with Nest. Now that’s no longer an issue.

same, and i have a shiny new Hub Max sitting on my counter waiting for me to move to Google Auth.

So do i need to migrate first?

For badnest to work. Yes. For your Nest Hub? No. HA can connect to Chromecast devices on your network without authentication. badnest is only for Nest original products, in short products you access through home.nest.com and the Nest app.

For anyone hitting the KeyError: 'userid' issue when using the Nest login method, it seems that Google/Nest made some changes to the login API to enforce recaptcha validation.

Discussion/background and a hacky workaround can be found here: https://github.com/USA-RedDragon/badnest/issues/65