Google Nest Device Access Console now available

While I am at about the same skill level as you on troubleshooting this stuff, I may have a few things for you to consider.

If the binding is working - checking your logs, you should see some messages related to the channel refresh for the thermostats. They would be in the openhab.log and the events.log. The openhab.log would have INFO entries similar to this:

==> /var/log/openhab2/openhab.log <==
2021-02-28 19:24:55.066 [INFO ] [nal.thermostat.NestThermostatHandler] - refreshChannels process a timer for Updating thing Channels for:nestdeviceaccess:nest-device-thermostat:AVPHwEs0OlH-kM0VcvCbIAJP_BhqtJqhoHfsdQoZrm3Jgz5P1sM1CUa732N5uP69SCddtXA_Oiu3CHzFrynPqgS9GjnKQQ
2021-02-28 19:24:55.640 [INFO ] [nal.thermostat.NestThermostatHandler] - refreshChannels process a timer for Updating thing Channels for:nestdeviceaccess:nest-device-thermostat:AVPHwEtiwOaLlO-WxC0CsAs7ecHUT0RdXAQSWzkWXa2v1v5wM67K4sPVc4osEWUHNXtOL5N8ugyuLm4SonccnCJI_55Lxw

And the event.log would have entry(s) around same time frame that look like this:

==> /var/log/openhab2/events.log <==
2021-02-28 19:24:56.092 [vent.ItemStateChangedEvent] - nestdeviceaccess_nest_device_thermostat_AVPHwEtiwOaLlO_WxC0CsAs7ecHUT0RdXAQSWzkWXa2v1v5wM67K4sPVc4osEWUHNXtOL5N8ugyuLm4SonccnCJI_55Lxw_thermostatHumidityPercent changed from 50.0 in to 48.0 in

Since the subscription is set up as a “pull”, the binding needs to request the messages from the queue. There seems to be a set time frame configured in the binding to do that pull - hence the process timer log entries.

As for the token expiration, it is true that it lasts one hour, but if the binding gets an error using the token, it should be doing a token request with the refresh-token. I assume that the refresh token does not expire and is the way you get a new token much like you did when you got an authorization token and made the initial request for your tokens during setup. Hope that makes sense.

I have had times when the thermostat stops getting updated, and hard to say what caused it but as in your case I was fiddling around on the Google side trying to understand this stuff a little better and probably messed it up. I have found that stopping and starting the binding seems to clear up those issues 99% of the time. You can do that from the openhab-cli console. In an extreme way you can also stop and start openHAB - that way your positive everything is starting fresh.

The binding is still under development which means you can expect to have issues. Hopefully Brian is still active here and can help.

Lately I have noticed (two thermostats and 5 cameras) - some handler Missing errors when I try to update the Thing definition for my nest devices (i.e. assign a location or refresh interval) using the Paper UI. This always messes up the device and the binding stops updating the device. That’s when I resort to restarting the binding…

Today, I completed documenting the setup process for the Device Access Console; not being a programmer, this was the best I could do to help others understand the steps behind getting the Google SDM API set up on Googles cloud platform. I will post a link to the Wiki after this reply. Perhaps there are some other clues in there to help you as well…

1 Like

Since setting up Device Access using Google’s new Smart Device Management (SDM) API isn’t the easiest process to follow, I went ahead and documented, as best I could, the steps to set this up and collect the information needed to configure the Nest Device Access Binding that @BHigg developed for the community.

Here’s a link to that guide on a GitHub Wiki I created:

Nest On OpenHAB - Step By Step Guide

My intent is to improve/keep this information up to-date. Constructive feedback is always welcome and can be provided here on openHab’s Community forum for this Topic.

5 Likes

Thank you Dave, this is very helpful!

I noticed a lot of commits by @wborn on github against the Nest binding. I am still on the “Works with Nest” API with my devices so holding off to convert to SDM for my OH3 setup. Looking forward however to convert once this is integrated in OH. Meanwhile hoping no family member “upgrades” the account…

1 Like

Hello, I have found out these hints by myself also, but it was working neither with Windows CMD nor with Windows Power Shell. Does not matter wich version I used. This was the magic word what helped me: Google Cloud shell console. I Looked for that and in a Chrome browser it started to work. Thanks! But as I migrated to OH3 in a meantime I can’t use it, till OH3 version will be ready.

1 Like

Thank you so much for the reply and for the amazing documentation!! You did a really good job with this, it is going to make this process much more straightforward anyone setting this up in the future.

In case this tidbit helps anyone… the solution to the problem i described above regarding the connection between OH3 and Nest expiring after one hour despite having a valid access token and refresh token was extremely simple… all I had to do was delete the nest thermostat thing from the UI and then add it again. After doing that, the refresh token has successfully maintained the connection for going on 10 days now. Somehow, restarting the binding and clearing the cache were not sufficient. I don’t know what caused the problem but as I said it seems to have vanished, so I am happy :+1:

Also @kovacsi2899, happy to hear that the Google Cloud shell console hint helped. Just to be clear though, I am also on OH3, and it is working for me - so I think you should be able to get the binding working with OH3 in its current state!

Thanks @Marcusfacius for the feedback.

As an FYI, I found that if you have camera devices, the credentials (.json) file needs to include parameters for a service account if you want to reliably retrieve the camera info. I was having hit or miss luck on this till I made this change. I have 5 nest cameras (Dropcam, Nestcam, Outdoor cam), while all showed on-line, only one or two of these would actually be updated when an event occurred. After this change, all 5 cameras are updating as expected.

I have an open issue on my doc to update it, so will get to that soon - you can find more info about that by reading the issue Update instructions for Credentials file to include service type.

Hi @Marcusfacius, how did you get the binding working in OH3? My building just installed Nests, and I’d like to give it a try!

Hi @dschoepel,

Thank you for the detailed step-by-step guide. I am running into trouble getting my access token. In short, I cannot seem to get beyond Step 3, I click all buttons, then I am re-directed to http://nestservices.google.com. I am not getting a screen to “choose an account”. So, I am not getting an access token. My nestservices.google.com screen just shows a box to change the amazon alexa settings. Any help would be appreciated.

~John

Hi @jsable (John),

Happy to try and help. Can you give me a little more detail on which sub-step of 3 your having a problem with. You may have already created your OAuth client - you can check using this link GPC Credentials Page. I mention this in the last paragraph on step 3.

Thanks @dschoepel (Dave), yes, you are correct, I have already created the OAuth client. I think I was unclear, I am in Step 5, sub-step 3, getting the access token. The trouble I have is between sub-step 3 and 4. When I click “next” in sub-step 3, I do not get the choose an account, I can see that my google account is already logged in, so it appears to connect to this account. I don’t get a “confirm your choices” dailog box either. I just get forwarded to the nest services page. I don’t get re-directed to the google page with the authorization code.

~John

John @jsable, can you tell me a little bit about the devices your trying to connect to? Are they thermostats, doorbell, cameras? I assume your on the step called 5.1 link your account, correct? And your getting the the Google Partner Connections screen where you can toggle access to your devices on or off? Once you click next on that screen, you are not being asked to select an account?

Hey Dave (@dschoepel), ok so I have two nest thermostat devices. The issue is that it seems like my account is already linked, it seems like I cannot select an account and it just goes on to the Google Partner Connections screen. When I click “next” this is what I see:

John (@jsable) When you click on the arrow “>” that you see on the right side of the box in your image, what happens? It should open up and show you the details for the devices. The other thing I noticed is that the box in your image shows Amazon Alexa - It should show the name of the Device Access Project you set up in Step 4? That could be another reason why this isn’t working for you.

Hello,

At step 5.1 (after “2-3. Choose Account/Nest permissions” ) I am receiving this message:

No partner connections found
New partner connections will show up here. If you’re trying to link other services, you can add them from the Home view in the Google Home app.

I have deleted everything and restarted from scratch, but without any success.
Anyone with more experience can guide me? BTW, I am new into this world (openhab).

Thank you,
Catalin

Hi Catalin (@ccs),

Based on the details you provided, it seems your using the guide I put together - correct? If so, then a couple questions -

  1. Are your Nest devices migrated to a Google account and you are signed in with that account when you execute these steps?
  2. Can you confirm you created your OAuth credential first, then created your Device Access project? The sequence is important to ensure the OAuth credential gets associated with the project. (FYI: Found this issue and possible explanation here: Can’t link to partner connection)
  3. When you build your command to call the Google Partner Connections screen for the first time, you copied your project Id and OAuth id from the project detail on the Nest device access screen:

URL code block:

    https://nestservices.google.com/partnerconnections/YOUR_DEVICE ACCESS _PROJECT_ID_HERE/auth?
    redirect_uri=https://www.google.com&
    access_type=offline&
    prompt=consent&
    client_id=YOUR_OAUTH_ID_HERE&
    response_type=code&
    scope=https://www.googleapis.com/auth/sdm.service
  1. When you paste the URL into your browser, you are getting the message you displayed above? If so, the Google doc explains this here. Partner Connections Manager Error Reference - which would indicate your logged in to a Google account but that this error occurs when the user has not connected any partners for Device Access. I would interpret that as meaning no OAuth account associated with the project.

Hope this helps a bit to get you on the right track to solving what’s causing your issue…

1 Like

Hi Dave,
Yes, the device is migrated to google account.
I am trying to upload some screenshots during the process.

https://drive.google.com/drive/folders/1ad8j8nPi69iHOzfX9eDdT4o3Lb4qnUN6?usp=sharing

Please tell me that I am doing something wrong and I am not again into an impossible situation.

Thank you,
Catalin

Hi Catalin,

Looks like you have done everything you needed to do. What browser are you using (I have tried this in Edge, Firefox, and Chrome)? Since you have an OAuth id, you should be able to use the [Google Credentials Page] (https://console.developers.google.com/apis/credentials) to view it. When you go there, you should be able to see that your project name (Openhab) listed in the upper left banner for the web page. That would confirm your OAuth Id is associated with your project.

Then, you could try accessing the PCM directly using this link: Partner Connections Manager and see if it works that way. It may not, if you have not made it through the process at least once but may be worth trying.

The only thing I see that looks different on the screenshot you have for the PCM is that there is typically a round circle in the upper right corner of the web page with your account icon to indicate that your signed in. Hence: The reason I was asking about what browser you were using…

Other than that I am running out of ideas…

1 Like

Hi Dave,

I got it figured out, apparently, it kept picking the OAuth from the Alexa skill and not the one I created. I have it resolved and working my way through the rest of the steps!

Thanks again,

~John

1 Like

Hi Dave,
I have used Safari browser and after I changed it to Google Chrome, I have successfully completed that step.
Unfortunately, I am blocked at then next step (5.2) “1. Request access and refresh tokens.”.

My URL was : Google
But when I am trying to get the refresh token I am receiving this error:

curl -L -X POST ‘https://www.googleapis.com/oauth2/v4/token?client_id=4xxxxxxxx272-lkul9kahipg4app4smrku2ritr8c16tl.apps.googleusercontent.com&client_secret=lxxxxxxxxew_uFP-gau60SU8&code=4/0AY0e-xxxxx-TxxxxxxxxyhegmMhaBNR4BER7KAbsxB4kuYRfyUNXVlAqIwiXOyysEC1Zw&grant_type=authorization_code&redirect_uri=https://www.google.com

{
“error”: “invalid_grant”,
“error_description”: “Bad Request”

Thank you very much for your support.Really appreciate.

–update:

This error occurs when the authorisation code expired. Generate the new code and it will work.

Hi Catalin,

Which terminal are you using to run the Curl command? Is this on a linux client, windows, mac.

The most foolproof way to do this is to use the Google Cloud Platform dashboard terminal for your cloud project. When you hit the link I provided here, the dashboard will be displayed for your project. You should look for a terminal icon in the upper right of the page Banner bar and click on that to start a terminal session. Hint: I referred to this in Step 6.1.3 if you want to see a screen shot of what I am referring to. It may take a few seconds for the terminal to open at the bottom of the screen. Try executing your curl commands in this terminal and see if that works better…

If your still getting an error back, doublecheck the curl command for correct format and possibly a carriage return where it should not be…

1 Like