Sorry Michiel, I only have nest thermostats… and to my dismay, after a full week of essentially flawless performance, I seem to have broken something, and now the thermostats consistently to lose their connection to OH exactly one hour after re-establishing the link (by re-discovering devices, then disabling & re-enabling the thermostat thing in the UI).
Stupidly, I think I may be responsible for this, as the change seemed to coincide with implementing two factor authentication on the google account associated with the Nests while setting up a different binding (you know, linking to a phone so that you can’t sign in without typing the code in a text message or whatever). I am a little surprised that doing that would have such an effect, but I am unable to identify any other possible culprit to explain the transition from that first week of flawless function to now only being able to maintain the connection for an hour. Curious if anyone else has had similar issues? I am no programmer, but I did a little digging, and I suspect that maybe this has something to do with the “expires_in”: 3599 property associated with the access_token provided by google… if I am correct in assuming that this number is in seconds, then that corresponds to one hour - which is the same period of time that I am able to maintain the link after losing the connection. So it seems that perhaps the refresh token is not successfully able to facilitate the generation of a new access token after the old one expires? The thing is, I have attempted to re-establish the connection using only the refresh token in the .cfg file (to prove that the refresh token is valid), and it works fine. So I am definitely confused. And also devastated, because having the nests integrated into all my other coming home/leaving home/going to bed/waking up routines was so amazing. Too good to be true maybe. Hopefully not. Any ideas would be very much appreciated! In case this clue is helpful - after the hour is up, in the OH log, I can see that the binding continues to attempt to update the thermostats every 5 minutes (which is my arbitrary refresh interval), but the actual values for current temperature and such fail to get updated. There is never any error/warning - superficially everything appears to be working fine, it is just that after that hour long period OH can no longer update values at the refresh interval, or send commands. I am running OH3.0.1 (with openHABian) on a RPi 4.
Also - in case this helps anyone else out (especially you @kovacsi2899) I found the solution to the problem I was experiencing in my last post above, when following the instructions here Get Started | Device Access | Google Developers. Specifically, at step #1 under “Get an access token” - when attempting to use the code within the google cloud shell terminal:
curl -L -X POST
'https://www.googleapis.com/oauth2/v4/token?
client_id=oauth2-client-id&
client_secret=oauth2-client-secret&
code=authorization-code&
grant_type=authorization_code&
redirect_uri=https://www.google.com'
I was receiving this error:
A parameter cannot be found that matches parameter name 'L'.
At line:1 char:6
+ curl -L -X POST 'https://www.googleapis.com/oauth2/v4/token?
+ ~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId :
NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
It turns out that the error was related to paragraph formatters within the text copied/pasted from the instructions at the above linked site - after removing those in notepad, the code ran perfectly. The code that ended up working was just one really long text string - like this:
curl -L -X POST 'https://www.googleapis.com/oauth2/v4/token?client_id=oauth2-client-id&client_secret=oauth2-client-secret&code=authorization-code&grant_type=authorization_code&redirect_uri=https://www.google.com'
One last thing in case it helps anyone - after succeeding with this step, I frustratingly got stuck again, at the very last step entitled “make a device list call” after attempting the code below in google cloud shell terminal:
curl -X GET 'https://smartdevicemanagement.googleapis.com/v1/enterprises/project-id/devices' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer access-token'
I got the error something to the effect of, invalid request or invalid code or some such. I have no idea why this worked, but all I had to do was repeat the preceding steps in the instructions to generate a new authorization code, access token and refresh token - and it miraculously worked like a charm.
Thanks so much to @BHigg, @wborn, and everyone else who I am not informed enough to mention specifically for all your hard work on this binding! I am so excited about it and very appreciative to you guys and everyone else in here helping each other out