Google-Nest Offical Device Access Console Finally Released!

I didn’t end up adding that, I did some port forwarding, and finished my setup from my phone off the wifi. Seems to have worked out!
Hope you’re well.

Those lines aren’t necessary if you’ve specified the URL’s via the Configuration, General panel, which is where I have mine. My homeassistant: section in configuration.yaml looks like this:

####################################################################
# Configure a default setup of Home Assistant (frontend, api, etc) #
####################################################################
default_config:

homeassistant:
  customize: !include customize.yaml
  customize_domain:
    switch:
#      assumed_state: off
      icon: hass:toggle-switch-off

  packages: !include_dir_named packages/

  allowlist_external_dirs:
  - /config/www

  auth_providers:
    - type: trusted_networks
      trusted_networks:
#        - 10.0.0.0/8
        - 172.16.0.0/12
        - 192.168.0.0/16
        - 127.0.0.1
      allow_bypass_login: true
    - type: homeassistant
  
  customize_glob:
    "binary_sensor.*":
      state_card_mode: badges
      templates:
        theme: >
          if (state === 'on') return 'green_badge'; else return 'red_badge';

    "device_tracker.*":
      state_card_mode: badges
      templates:
        theme: >
          if (state === 'home') return 'green_badge'; else return 'red_badge';
http:
  use_x_forwarded_for: true     # To ensure HA understands that client requests come via reverse proxy
  trusted_proxies:
    - 172.30.32.0/23            # In Hass.io we need to add the Docker subnet
    - 127.0.0.1                 # Add the localhost IPv4 address
    - ::1                       # Add the localhost IPv6 address
  # Comment or remove the SSL certificate lines:
  # ssl_certificate: /ssl/fullchaim.pem
  # ssl_key: /ssl/privkey.pem

Refer to https://www.home-assistant.io/docs/configuration/basic/

Worked perfectly! Thank you for your help. I should’ve read the troubleshooting guide before asking. Thanks for all of your work on this integration. It’s fantastic.

Hey Allen,

I turned off testing last week but i lost my token today. It stopped working. I had closed the port from the outside with the domain name too. Home Assistant notified me that something needed reconfigured, tried to go through that, failed at Error 400: invalid_request.

What do you suggest?

Thanks

Hi, See the nest integration troubleshooting page if you ha e not already. I’ll need a bit more detail about the 400 errors you are seeing otherwise. Happy to help.

.

Thanks to @allenporter for working this. I can only imagine the work that has gone into this. Google has made this integration a nightmare. It took me many hours of work to get it working only to get the integration with no devices. Re-starting my Nest device worked for me after doing things like redoing the subscriber, removing the integration, restarting HA multiple times. Hope it works for you.

Nest had been working fine for months, not sure if it’s related but I took the OS upgrade to 5.12 today and when I restarted Nest times out. I get several “Waiting on integrations to complete setup: nest”
over a period of time and then the final time out error.

Any ideas?

2021-02-24 14:19:28 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: nest
2021-02-24 14:19:47 ERROR (SyncWorker_23) [pynanoleaf.pynanoleaf] 192.168.1.20 is not available
2021-02-24 14:19:48 ERROR (SyncWorker_23) [pynanoleaf.pynanoleaf] 192.168.1.20 is not available
2021-02-24 14:19:48 ERROR (SyncWorker_23) [homeassistant.components.nanoleaf.light] Could not update status for Nanoleaf (192.168.1.20 is not available)
2021-02-24 14:20:09 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Configuration.yaml for nest
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 239, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/nest/__init__.py", line 190, in async_setup_entry
    await subscriber.async_get_device_manager()
  File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/google_nest_subscriber.py", line 207, in async_get_device_manager
    return await self._device_manager_task
  File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/google_nest_subscriber.py", line 212, in _async_create_device_manager
    structures = await self._api.async_get_structures()
  File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/google_nest_api.py", line 27, in async_get_structures
    resp = await self._auth.get(self._structures_url)
  File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/auth.py", line 56, in get
    resp = await self.request("get", url, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/auth.py", line 44, in request
    access_token = await self.async_get_access_token()
  File "/usr/src/homeassistant/homeassistant/components/nest/api.py", line 35, in async_get_access_token
    await self._oauth_session.async_ensure_token_valid()
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 473, in async_ensure_token_valid
    new_token = await self.implementation.async_refresh_token(self.token)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 84, in async_refresh_token
    new_token = await self._async_refresh_token(token)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 175, in _async_refresh_token
    new_token = await self._token_request(
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 193, in _token_request
    resp = await session.post(self.token_url, data=data)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 619, in _request
    break
  File "/usr/local/lib/python3.8/site-packages/aiohttp/helpers.py", line 656, in __exit__
    raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError

This is in the common home assistant library for refreshing the auth token by talking to Google. This likely means something is wrong with the network?

Does the error go away when reverting to a precious version?

I ended up removing and re-installing the Nest integration and the install would hang after select “Allow”. I am running PiHole which I had disabled. Ended up changing the DNS setting on the Router to OPENDNS and this allowed me to re-install. After the install I switched it back and the integration is still working.

Does the auth refresh happen often? Just wondering if I am only seeing this problem periodically because the auth refresh happens infrequently.

Yes, this token refresh happens often. Working dns is a requirement for this integration.

I’m not sure this is a HA thing. I’m absolutely certain I was set to ‘production’ and not ‘testing’ in Google. Today I found it had switched itself back to testing by itself. I just redid everything and it works. I think it is possible Google will just switch it back to testing and the authorisation will only last a week again.I needed to change nothing with HA to get it working again.

ps. I have two factor authentication on. I don’t know if it is relevant but it might be why HA can’t reauthenticate on it’s own.

pps. Because my user account was no longer authorised I had to add it again in my developer project.

ppps. The two factor authentication on Google I set is with the Google Authenticator App on my phone. No way HA could access the number.

I am seeing this in the Google API console, is https required for the callback?

image

I was able to authorized about a week ago but today I was just checking the settings on the API console and noticed this

Ah interesting. Maybe it was allowed when the status was testing, then later If status was changed to production it became not allowed.

Using ssl here would be ideal since the flow is passing around your authentication token to access your devices.

Hi @allenporter that’s exactly what happened. Ive now setup up a let’s encrypt cert and now have secure access.

Thx

I’ve been having another issue and not not sure if others are experiencing the same thing.

It seems that if I change the temperature in home assistant it will reflect that on the nest thermostat itself and on the nest app however if I make a change in the nest app or directly in the thermostat home assistant is always updates. So far I’ve observed this mostly when the thermostat is updated via its schedule.

The issue is temporary fixed if I restart home assistant or reload the nest integration.

Anyone else experienced this?

To clarify: Are you saying that updates from the nest app don’t arrive to Home Assistant?
Have a look at the troubleshooting tips at
https://www.home-assistant.io/integrations/nest/#troubleshooting – including making sure you are running the latest home assistant version, and checking for errors in the error log that might indicate a subscriber error.

Hi @allenporter yes it seems that way and it does not always happen. (/sigh)

I did enable the debug logging per suggestion.

I am curious if its related to precision settings. In HA I am using the custom:simple-thermostat’ card with the following settings in lovelace

type: 'custom:simple-thermostat'
entity: climate.upstairs
step_size: 1.0
control:
  hvac:
    auto: true
    heat: true
    cool: true
    off: true
  icon:
    heat: mdi:fire
      cool: mdi:snowflake
      eco: mdi:leaf
      off: mdi:power
      auto: mdi:autorenew
      idle: mdi:power
      away: mdi:leaf

My temperature adjusts in units of 1, so it goes up from 68 to 69 and does down 69 to 68. When I look at the debug logs from HA I see.

image

Notice the heatCelsius: 19.9444 setting, its has a much higher precision and I am wondering if this could be an issue? By the way my Nest and HA is setup for Fahrenheit goes there is always a conversion happening.

Still going …

Great @narsaw I am glad updates are being received. I don’t think there is much additional I can provide, as the integration is passing numbers between the SDM API and home assistant. Maybe others have thoughts.

(Aside: In my home, temperature fluctuations and inaccuracies of 1 degree happen as I just walk from one side of the room to the other so I don’t sweat it, so to speak!)

I’m a non-coder, moderately tenacious, google wielding ‘recipe follower’ trying to get a Nest Thermostat set up. I’ve managed to get pretty far, but am stuck trying to get this command to work…

curl -X GET 'https://smartdevicemanagement.googleapis.com/v1/enterprises/project-id/devices' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer access-token'

Googling I’ve managed to hack my way through to some extent trying to adjust this instruction so that it actually works (managed to get through previous steps with that method, but am running out of steam :smiley: ) … got as far as replacing single quotes with doubles and deleting backslashes as they’re apparently meant to indicate a connection between lines… but I’m still getting errors in response to the command in my console…

{
  "error": {
    "code": 401,
    "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}

figure there’s something obvious to coders that I just don’t get… should there be a space after the double quotes before the -H?