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

I didn’t have that but threw it in there. Still nothing. The only thing related to badnest are these warnings/errors that are for the thermostats. They’re not always there though and the thermostats do work, so I think they retry and recover:

2020-07-11 01:43:22 WARNING (MainThread) [homeassistant.components.climate] Updating badnest climate took longer than the scheduled update interval 0:00:10
2020-07-11 01:45:11 ERROR (MainThread) [homeassistant.helpers.entity] Update for climate.attic_thermostat fails Traceback (most recent call last):

Nothing with badnest for camera though. It’s as if it’s not even aware of the camera. My aarlo cameras work fine.

Is your region set ok in the badnest config e.g.:

badnest:
  issue_token: !secret nest_token
  cookie: !secret nest_cookie
  region: eu

I only really have two ideas then. First would be to try splitting your camera set up in the yaml file. so it is something more like:

camera aarlo:
  - platform: aarlo
    ffmpeg_arguments: '-pred 1 -q:v 2'

camera badnest:
  - platform: badnest

I’m not convinced that should make any difference though.
And the other is that I vaguely remember I had to pull in one/some of the Pull Requests to the code I was using for Badnest - unfortunately it looks like the original author isn’t doing anything to keep things up to date / may be not using it any more. I think I pulled in the following - I ended up creating a fork as I wanted to do a bit of development to add in some other things which aren’t in the original repository:


I believe that there was a fork on the code that fixed the camera. If you search above you can find it. I’ll if I have a link and if I find it I will edit this message.

Check out

"My thermostats have always worked so I am not sure about the problem with those. I have added the changes to the Nest Camera API but I am not sure when they might be merged. If you want to get it working meanwhile my changes are here

https://github.com/vinodmishra/badnest ](https://github.com/vinodmishra/badnest)

That was it! Thank you both!!! I started with https://github.com/vinodmishra/badnest since it had a bunch of other new commits. I uninstalled the old repo, installed the new one, rebooted, and it worked the first time. My Nest Hello camera was now available. No other changes needed.

We should see if a mod could update the first post and mention this.

Regardless thank you both again!!!

Just a heads up this uses about 1.0-1.5gb a day from what I noticed. Took a while to find what port was using so much data a day in my HA.

Works great but really can get you in trouble if you have cap limits.

1 Like

Hello everyone,
this is my 3rd attempt to setup BadNest without luck :confused: … Hopefully somebody can help me out.

this is the error i am getting / seeing in the logs:

2020-07-19 08:52:35 INFO (MainThread) [homeassistant.setup] Setting up badnest
2020-07-19 08:52:35 ERROR (MainThread) [homeassistant.setup] Error during setup of component badnest
  File "/config/custom_components/badnest/__init__.py", line 48, in setup
  File "/config/custom_components/badnest/api.py", line 52, in __init__
  File "/config/custom_components/badnest/api.py", line 70, in login
  File "/config/custom_components/badnest/api.py", line 82, in _login_google
2020-07-19 08:52:35 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform badnest.climate: Unable to set up component.

i enabled HACS and copied hacs folder, please see below:

hacs $ pwd
/config/custom_components/hacs

here is my config file:

badnest:
  issue_token: "https://accounts.google.com/o/oauth2/iframerpc?action=issueToken&response_type=token%20id_token&login_hint=AJDLj6LQu-SMCQLMJfOUep6S7tCe9HDZfW4ZkcePwoZW1chHRwrOzv-ewTGVl_s0pYQAId6abq1rUgG1kE2Hqbw0Agkbmuq4HA&client_id=733249279899-44tchle2kaa9afr5v9ov7jbuojfr9lrq.apps.googleusercontent.com&origin=https%3A%2F%2Fhome.nest.com&scope=openid%20profile%20email%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fnest-account&ss_domain=https%3A%2F%2Fhome.nest.com"
  cookie: "SID=zQc2hD0p8ZDLTX7MOoxcBkYhtJfa7DG-DGOf0rw_FmalvY6HYCQCqGbtZtMr3_1dvZ2p4w.; __Secure-HSID=ArfbiQvfldJmHdGLI; __Secure-SSID=Aw4DojbbxJCaB6dC2; __Secure-APISID=78KPWpkQzCL6yHs_/AZW6Ew0T7tpQAfoHV; __Secure-3PAPISID=3IIumvBdWMwwEbj_/AVyccar64wUfx7YXK; NID=204=fmdmqcne3ttwal4ZbBaWkEorLEvP4hYccUcDkM_qwhZiNG7b-5YZvdo8wDT7lJ_o4x0PDNET8aO8-Ef9JtUUjEieofybaRh69xS7pTw9x8UvYywJlVoWLMBmB5FcVTUDa-wg_mbmkgNW0E_2Ekr90dikmEAt8wONKpPfldbXstEnkxo6TqPkTnDPAtO88gwd3oOT5N40RXD8jnAXGfdHsDGE5rQ; __Host-3PLSID=s.youtube:zQc2hB4AmLkkRCr8VWm6wI2anetp6f4qVHJa5Gg1K8G3eDkVpYYqaAu4ZUp8DK_PhOTgxw"
  region: us

climate:
  - platform: badnest
    scan_interval: 10

does anybody have any idea what i am doing wrong?

from error logs it seems its an issue with authentication:

2020-07-19 14:09:45 INFO (MainThread) [homeassistant.setup] Setting up badnest
2020-07-19 14:09:46 ERROR (MainThread) [homeassistant.setup] Error during setup of component badnest
  File "/config/custom_components/badnest/__init__.py", line 48, in setup
  File "/config/custom_components/badnest/api.py", line 52, in __init__
  File "/config/custom_components/badnest/api.py", line 70, in login
  File "/config/custom_components/badnest/api.py", line 82, in _login_google
2020-07-19 14:09:46 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform badnest.climate: Unable to set up component.
2020-07-19 14:09:47 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform badnest.sensor: Unable to set up component.

It seems i was able to fix it. I just saw this in the logs:

2020-07-19 20:04:32 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new climate.badnest entity: climate.family_room_thermostat
2020-07-19 20:04:32 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new climate.badnest entity: climate.hallway_thermostat
2020-07-19 20:04:32 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.badnest entity: sensor.family_room_thermostat
2020-07-19 20:04:32 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.badnest entity: sensor.hallway_thermostat

It seems Badnest code does not like Yubikey. I removed my Yubikey from my google account and it seems its working now. I do still have 2FA enabled.
I hope this can help out somebody with yubikey & hopefully they dont have to start pulling heir hair out like i did.

Ouch, I was planning to switch from my old Nest account soon but I have a yubikey on my Google account and can’t remove it for this.

TL;DR - If your climate device is not detected but other devices within your Nest account are, try doing a WWN RESET on your thermostat

First of all, thank you USA-RedDragon and everyone on this topic for all the work you’ve put in to this. I feel like I’ve read this thread up and down and backwards twice already and as a newbie to HA you guys have been awesome in your responses.

I am running HA 0.112.4 in Synology installed from the SynoCommunity Hass.io package. I feel like I have tried every which way to get Badnest working properly.

I am using 2FA auth, here is my config.yaml

badnest:
  issue_token: "accounts.../o/oauth2/...home.nest..."
  cookie: "SMSV=...."
  region: us

climate:
  - platform: badnest
    scan_interval: 10

camera:
  - platform: badnest

camera badnest:
  - platform: badnest

sensor:
  - platform: badnest

I tried both

/USA-RedDragon/badnest
and
/vinodmishra/badnest

I have a Gen3 US version of the Nest Thermostat, I also have the external sensors. I also have a Nest Hello Doorbell.

The three sensors show up just fine in HA, I am getting video from the Nest Hello even! The one thing that NEVER CREATES is the Climate entity. I feel like I am doing something wrong as in the forum here the problem usually ends up being someone is going from an old Nest account to a Google account or they have to refresh their token. I have already refreshed my token (as of today) and I am authenticating as I am getting data from my camera and other sensors, it is just the camera entity that is not working.

I have uninstalled [restarted] reinstalled [restarted] the two above repositories a few times and I don’t get an errors in the logs (or I am looking in the wrong logs? right now I go to Supervisor -> System -> Core Provider) and I see the sensors come up with IDs…

2020-07-20 18:56:46 INFO (MainThread) [custom_components.badnest.sensor] Adding nest temp sensor uuid: somecoolid1
2020-07-20 18:56:46 INFO (MainThread) [custom_components.badnest.sensor] Adding nest temp sensor uuid: somecoolid2
2020-07-20 18:56:46 INFO (MainThread) [custom_components.badnest.sensor] Adding nest temp sensor uuid: somecoolid3

But this is all I get back for the climate entity

2020-07-20 18:56:46 INFO (MainThread) [homeassistant.components.climate] Setting up climate.badnest
2020-07-20 18:56:46 INFO (MainThread) [custom_components.badnest.climate] Adding thermostats

Is there something else I can try? Or even look at to help me find the smoking gun to help my google-fu?

Thanks again!

EDIT: I updated the climate.py to see what was goin on…

async def async_setup_platform(hass,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Set up the Nest climate device."""
    api = hass.data[DOMAIN]['api']
    _LOGGER.info(f"API returned : {api}")
    _LOGGER.info(vars(api))

    thermostats = []
    _LOGGER.info("Adding thermostats")
    for thermostat in api['thermostats']:
        _LOGGER.info(f"Adding nest thermostat uuid: {thermostat}")
        thermostats.append(NestClimate(thermostat, api))

    async_add_entities(thermostats)

When i added “_LOGGER.info(vars(api))” to Climate.py here is what I got in the logs:

 'device_data': {
       'yyyyyyyyyyyyyyyyyy': {
            'name': 'Living Room Temperature',
            'temperature': 21.299988,
            'battery_level': 100
        },
        'zzzzzzzzzzzzzzzz': {
            'name': 'Basement Temperature',
            'temperature': 18.0,
            'battery_level': 100
        },
        'xxxxxxxxxxxxxxxx': {
            'name': "Some Room Temperature",
            'temperature': 21.899994,
            'battery_level': 100
        },
        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: {
            'camera_url': 'nexusapi-us1.camera.home.nest.com',
            'name': 'Front Door',
            'is_online': True,
            'is_streaming': True,
            'battery_voltage': 0,
            'ac_voltage': 0,
            'location': None,
            'data_tier': 120
        }
    },

Also…

 '_czfe_url': 'https://abc1234-wxyzabc-whatever01.whatsup.home.nest.com',
    'cameras': ['wwwwwwwwwwwwwwwwwwwww'],
    'thermostats': set(),
    'temperature_sensors': {
        'xxxxxxxxxxxxxxxxxxx',
        'yyyyyyyyyyyyyyyyyyy',
        'zzzzzzzzzzzzzzzzzzz'
    },
    'protects': set()

I reset my nest thermostat and re-added it to my account, and pulled the cookie again (issue_token was the same). Can someone that has this working confirm or deny if they can see this in the payload?

EDIT 2: I got this working! In case someone else has a similar problem…
My situation was that I bought a house that had this Nest already installed. I believe it was setup long before the Works With Nest went out the window.

As I was going through the menu on the thermostat I had already factory reset it and set it back up with my HVAC to no avail but I saw WWN RESET

When I gave this a shot, it decoupled my thermostat again from the app and I saw a very different entry code when I was re-pairing it.

Low and behold, now it appears!

3 Likes

This worked for me to! After MONTHS of not having Nest in my Home Assistant, Its now back. CHEERS!

I keep getting the follow in my logs all the time:

Log Details (WARNING)

Logger: homeassistant.components.climate
Source: components/climate/__init__.py:553
Integration: Climate ([documentation](https://www.home-assistant.io/integrations/climate), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+climate%22))
First occurred: 1:32:03 PM (1 occurrences)
Last logged: 1:32:03 PM

ClimateDevice is deprecated, modify NestClimate to extend ClimateEntity

Is it related to this integration? If so, please fix it… I’ve been getting this error for several versions of HA.

Well, it’s due to change in HA v0.110 and badnest received the last update 6 months ago… :thinking:

Try to use somebody else’s fork.

Ok, thanks… another fork such as…?

You could just copy the code from this diff into your current code and it’ll fix it

1 Like

I ran in to this too and ended up using

This also gave me support for my Nest Hello

Question - I want to add an automation to set target humidity in the winter months to control my humidifier (hard wired to my nest thermostat). Is there a way I can write to for this humidity setting?

& Thanks @g1usepp3! - doing the WWN RESET fixed my connection issue too.

1 Like

I’m wondering how many of you guys are getting Updating badnest ********* took longer than the scheduled update interval ...? Not sure since when, i saw this error multiple times in a past but now it produces hundreds/thousands of these in my log. My Nest Thermostats work perfectly fine, but Nest Protects basically stopped reporting their states.

I don’t know whether it’s due to exspiring cookies but i renewed it several times and i didn’t notice any positive impact. Tested original badnest as well as mattsch’s and vinidmash’s forks

When you said that it gave you support for NH, what exactly do you mean? Can you get an event when the bell button is activated? Or do you mean you get the camera video stream only? Thanks

Camera stream only for me. The notifications for ‘someone familiar at the door’ and all that I do NOT have in Home Assistant.

It’d be cool to have it! But I am afraid I am dependent on those much smarter than I for that (luckily that list is quite large)

Thanks. I don’t think that’s possible anyway, you can only get the camera stream, it has always been that way as far as I’m aware. Maybe I’m wrong…