[RELEASE] Google SDM API - Nest integration

You can use the attribute tile and select image, which will display the most recent event image (this only works for local dashboards, it seems like the cloud service blocked the response based on size when I tried coding that option).

The logs are essentially indicating that several events occurred for a device in a short period of time (generally less than a second}, and Google sent the later event first (each event has a timestamp) -- the api doesn't guarantee event ordering. Since we don't want to overwrite newer data, and might have missed something, we discard the "out of order" event and refresh the current state.

The only way around this is to maintain a sorted buffer to process the events -- but such an implementation adds complexity, and more importantly, a latency delay before anything gets processed, to make sure we don't get something else that should have been processed before.

1 Like

I get the length thing as soon as I add the device too the dashboard so it seems it also a issue on local.

Great I'll play around and see if I can get it working.

the length 1024 warning from the Dashboard app refers to the rawImg attribute -- which stores the base64-encoded string for the image served to the dashboard. The image attribute is actually a short string of html to render it via an api served by the App -- kind of goes in circles, but it's the only way I could store and render the image without the HE software giving custom Apps/Drivers access to the "Local Files"

I installed via Hubitat Package Manager and attempted to follow all of the instructions for setup. The good news is that I can see my devices. Unfortunately, I don't see any events for them. When I look at the logs it appears there is a 403 error from the event subscription. I've tried using the Debug functions to delete and resubscribe to events, but get the same 403 error.

Any thoughts or advice on what I may be missing?

[app:66](https://10.0.8.2/logs/past#app66)2020-11-03 01:12:46.574 pm [error](https://10.0.8.2/installedapp/configure/66)createEventSubscription returned status code 403 --

[app:66](https://10.0.8.2/logs/past#app66)2020-11-03 01:12:46.250 pm [info](https://10.0.8.2/installedapp/configure/66)Creating Google pub/sub event subscription

[app:66](https://10.0.8.2/logs/past#app66)2020-11-03 01:12:46.225 pm [debug](https://10.0.8.2/installedapp/configure/66)Authorized scopes: https://www.googleapis.com/auth/sdm.service https://www.googleapis.com/auth/pubsub

[app:66](https://10.0.8.2/logs/past#app66)2020-11-03 01:12:45.881 pm [info](https://10.0.8.2/installedapp/configure/66)Getting access_token from Google

[app:66](https://10.0.8.2/logs/past#app66)2020-11-03 01:12:45.867 pm [info](https://10.0.8.2/installedapp/configure/66)successful redirect from google

[app:66](https://10.0.8.2/logs/past#app66)2020-11-03 01:11:31.585 pm [info](https://10.0.8.2/installedapp/configure/66)Google SDM API installed

Thanks!

Auth scopes are set within the App code, and look ok in your logs -- my other immediate thought for a 403 error is this:

Thanks. That was one of the first things I checked and it's enabled. You got me thinking that maybe the subscription wasn't setup correctly, so I went back and reperformed the pull subscription creation and initiation steps. I manually tested it and it appeared to be working. I Deleted the event subscription and Subscribed to Events from the debug. This seems to have solved it.

Thanks for the help/suggestion!

I'm hitting the following error this morning:

java.lang.NullPointerException: Cannot invoke method toFloat() on null object on line 147 (setHeatingSetpoint)

Any idea?

I just turned on 'debug' in the App itself to see if I get more details when this happens, but this error is coming from the Nest Theromostate Driver (The only nest device I have connected).

Everything seems to work fine, just not sure what (if anything) this error blocked or is preventing from happening.

You're hitting bug #46 -- please pick up the latest thermostat driver, which contains a fix.

2 Likes

Thank you. Shame on me for not checking HPM first if there was an update before posting.
Thank you!!

Why in the world did they not include the API for the yale/nest lock? Would so love to get that thing talking to hubitat.

1 Like

Those are the ones with the replaceable module? Just stick the Zigbee module in and be done with it.

1 Like

Hi,

I'm trying to turn the front door light on when there is a person detected by the google nest doorbell but it's not working. Is this correct? Thanks

That depends. Is "Front Door Person" the name of your camera? Or is it a virtual motion sensor that is tied to the "arrival" event of your camera.

Person detected by the camera is the "arrival" event and is a simulated presence sensor.

I have a rule that makes a virtual motion sensor active whenever my Front Doorbell arrives. I can then use that motion sensor like you are above if I want.

Camera Person to Motion

If that is just the name of your camera, then it will cause the light to come on whenever there is any motion detected by your camera (Not just a person)

(PS... the screenshot is just the first part of the rule. I have other actions that are not relevant. The motion will time out on the virtual motion sensor at whatever time you have it set for. Mine is 2 minutes)

So I'm having a heck of a time getting this app to auth. I'm gone through the setup, and I'm receiving the following error after setting the project ID and credentials.json:

Login refresh failed -- Bad Request: [error:invalid_request, error_description:Missing required parameter: refresh_token]

I've noticed others with the same error, but did not see any resolution. I created a new google app and set the redirect URI to the hubitat URL.

Any help is appreciated!

So I dug through the app code a bit, and realized that the app is only trying to fetch an auth code when the app is installed, not updated. So after deleting/re-adding the HE app it appears to at least have gotten past the first step.

Now, when I click on the "Auth Link" button, I'm receiving the "Something Went Wrong" message. I've creating an entirely new google project, and am still experiencing the issue.

Any insight? Thanks!

Hi @dkilgore90,

Thanks for you awesome work! Do you know for how long a Person -> presence stays on? Do I need to create a virtual presence device to use this?

Is this a Google message or a Hubitat message? I know several folks have reported this, but I'm lacking clarity on exactly where/how it is displayed -- this will help narrow down "what went wrong?"

The default is 15 seconds -- but this is configurable on each Device page via the Presence timeout (s) preference.

1 Like

Here is a screen shot. It's the result of clicking the Auth Link button in the HE app config screen:

The URL is:

https://nestservices.google.com/partnerconnections/hubitat-sdm-xxxxxx/auth?redirect_uri=https://cloud.hubitat.com/oauth/stateredirect&state=238f0af8-5fc9-4d26-8cf4-2ca95a50ec52/apps/516/handleAuth?access_token=xxxxxxxxxxxxxxxxxxx&access_type=offline&prompt=consent&client_id=xxxxxxxxxxxxxxxxxxxxx&response_type=code&scope=https://www.googleapis.com/auth/sdm.service%20https://www.googleapis.com/auth/pubsub

(I've obviously redacted a few bits of information in the URL)

Thanks for the quick response!

Try replacing the %20 towards the end of the URL with an actual space, or %2B (+) -- seems there are varying rules for how the "space" gets encoded in the URL -- might be tied to the browser used, or (less likely, I think) the HE version...

I'll play with this some more and see if I can force it to be more reliable

I had an issue with the word wrap in the path. It seems that I had to go and backspace at the beginning of each line break so that it was one long string as opposed to multiple lines with line breaks (wasn't visible until I maximized it in notepad that I noticed the line breaks/extra spaces)

The only other issue I had was that I had not put hubitat in the redirect: