Google-Nest Offical Device Access Console Finally Released!

No, you’re awesome, thanks for the screenshot so I could see what’s going on. I was starting to worry there were other things I might be missing, so this is great.

Ironically, about two hours after making everything with the words ‘nest’ or ‘google’ into a log in configuration at debug level, it–randomly started working? No reason. And I still can’t find the script that retrieves and passes hvac_action.

Thanks again for your help.

This is the code that access the google nest api.

Called from ha nest component.

Id like to re-add my thermostat back into HA, but i dont have a creditcard to pay the $5,- fee. Does anyone know if that payment can be done with a Mastercard giftcard or something similar?

I don’t recall what the payment options were but I expect they’d be the same as for a Cast Developer which has a link to valid Google Payments payment method.

Hi,

I have been trying to add the Nest Integration, and following the official documentation. I am unable to have a successful integration done, and have been trying to debug this since the past 2 days.

Things I’ve done:

Setup external URL (duckdns).
Access HA using my external URL.
For redirect URI I use https://blah.duckdns.org:8123/auth/external/callback

I setup my Oath client ID + secret. I also setup the Pub-Sub correctly. The part that fails for me is this, I click on integration and then go through the OAuth consent flow. I eventually get to the point where it should redirect me back to HA external URI. After I click the final “Allow” the tab closes, and I land back to the original tab in HA which keeps saying that this integration needs external config. How should I debug this? I looked into my HA core logs, but I don’t see anything there.

My guess is that the OAuth flow is somehow unable to complete. However, I followed the instructions in the https://developers.google.com/nest/device-access/authorize which should link my account. This part already works. Any clues here would be really helpful, thanks a lot for working on this integration!

After https://developers.google.com/nest/device-access/authorize were you able to complete https://developers.google.com/nest/device-access/use-the-api?

I was able to call the devices endpoint to get a list of devices (which included my thermostat) as the return structure.

and the final step? https://developers.google.com/nest/device-access/subscribe-to-events?

I was able to run the following:

  1. Initiate events. ( returns a structure, no error)
  2. I am able to see messages here: https://console.cloud.google.com/cloudpubsub/subscription/detail/nest-home?project=nest-project

Can’t hurt to try a router reboot…

Another suggestion:

  • Double check error logs
  • Try using “Developer Tools” and try to capture the request flow. It might show an error somewhere, that doesn’t show up in home assistant logs.

Where should I be checking the logs? I usually check Config -> Logs, or ha core logs on console.

I was able to put a breakpoint on window.close() for the OAuth flow, and it seems the final call is to my external uri. i.e https://blah.duckdns.org:8123/auth/external/callback?state=foocode=bar&scope=https://www.googleapis.com/auth/pubsub%20https://www.googleapis.com/auth/sdm.service

The return status code says 200 OK, and the tab closes automatically ( I guess its expected) .However, I don’t see any logs for this call in ha core logs. So I’m not even sure if HA is processing this request (and how come it return 200 OK)?

I also restarted my router, doesn’t seem to help.

FWIW I’m on 2020.12.7 HA version

I will for sure test this when it is merged into the release version. I am not on dev builds as I have too many systems depending on my HA installation. :slight_smile: Will revert as soon as I get it installed. Do you know if it will be part of 2021.1.2?

Referring to this PR: https://github.com/home-assistant/core/pull/44638

Did you enable debug logging?

    google.cloud.pubsub_v1: debug
    google.cloud.pubsub_v1.subscriber._protocol.leaser: debug
    google_nest_sdm: debug
    google_nest_sdm.device: debug
    google_nest_sdm.device_manager: debug
    google_nest_sdm.google_nest_subscriber: debug
    google_nest_sdm.event: debug
    google.cloud.pubsub_v1.subscriber._protocol.streaming_pull_manager: debug
    homeassistant.components.nest: debug
    homeassistant.components.nest.sensor_sdm: debug

Should be part of the 2021.2 releases

1 Like

I keep having to reset my auth every 7 days. It seems there is something expiring.

2021-01-14 15:09:22 ERROR (Thread-66) [grpc._plugin_wrapping] AuthMetadataPluginCallback "<google.auth.transport.grpc.AuthMetadataPlugin object at 0x7f86154bd310>" raised exception!
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/grpc/_plugin_wrapping.py", line 77, in __call__
    self._metadata_plugin(
  File "/usr/local/lib/python3.8/site-packages/google/auth/transport/grpc.py", line 86, in __call__
    callback(self._get_authorization_headers(context), None)
  File "/usr/local/lib/python3.8/site-packages/google/auth/transport/grpc.py", line 72, in _get_authorization_headers
    self._credentials.before_request(
  File "/usr/local/lib/python3.8/site-packages/google/auth/credentials.py", line 133, in before_request
    self.refresh(request)
  File "/usr/local/lib/python3.8/site-packages/google/oauth2/credentials.py", line 200, in refresh
    access_token, refresh_token, expiry, grant_response = _client.refresh_grant(
  File "/usr/local/lib/python3.8/site-packages/google/oauth2/_client.py", line 248, in refresh_grant
    response_data = _token_endpoint_request(request, token_uri, body)
  File "/usr/local/lib/python3.8/site-packages/google/oauth2/_client.py", line 124, in _token_endpoint_request
    _handle_error_response(response_body)
  File "/usr/local/lib/python3.8/site-packages/google/oauth2/_client.py", line 60, in _handle_error_response
    raise exceptions.RefreshError(error_details, response_body)
google.auth.exceptions.RefreshError: ('invalid_grant: Token has been expired or revoked.', '{\n  "error": "invalid_grant",\n  "error_description": "Token has been expired or revoked."\n}')

To do this I have to go into APIs and Services, select OAuth 2.0 Client IDs, navigate to the name of my next integration, click “reset secret” and then update my configuration.yaml with the new value. Once that is complete I remove and re-add the integration. This seems really kludgy but maybe I’m doing something wrong?

1 Like

Yes. But I don’t see any logs in the ha core logs. I am going to try creating a new app and redo all the steps. Let me see if that helps. Is there a way to add more breakpoints, logs etc in the integration py file? I want to see if certain code paths are even being hit.

With those debug log levels I’d expect a crapload of entries…

https://pastebin.com/xgjfU4y6 This is how my config.yaml looks like. Do I have to enable something else? I don’t see any logs related to oath or nest SDM in ha core logs. The final step does call back to my external URI callback. Any other places I should look for logs?

Would anyone be able to assist with my issue. I had both my thermostats working properly and then about a week or so, my Nest E disappeared. I go into the cloud console to check what devices are in there and it only lists my living room nest.

When I run the URL authorization command, it shows both devices with me granting access to both. I tried restarting the Nest E but no luck.

Thanks

1 Like