Follow the Get Started QuickStart from Google. Steps are outlined below, along with modifications specific to integrating with Hubitat.
On the Apps Code page, press the New App button
Paste the code for sdm-api-app.groovy
and press the Save button (or type Ctrl-S)
Press the OAuth button, then press Enable OAuth in App, then press the Update button.
On the Devices Code page, press the New Driver button
Paste the code for sdm-api-thermostat.groovy
and save
Repeat this process for each of the device handlers you want to install.
On the Apps page press the Add User App button then click on Google SDM API in the list of available apps.
Copy and paste your Google Device Access project ID (step 13 in Google Pre-requisites above) into the Google Device Access - Project ID
input field for the Google SDM API app. As noted above, this value should be a UUID -- hexadecimal (0-9/a-f) characters in the format 12345678-abcd-1234-abcd-1234567890ab
Copy and paste the contents of your Oauth2 credentials.json file downloaded from GCP (step 7 in Google Pre-requisites above) into the Google credentials.json
input field. This should be valid JSON resembling the following data:
{
"web": {
"client_id": "aaa",
"project_id": "bbb",
"auth_uri": "ccc",
"token_uri": "ddd",
"auth_provider_x509_cert_url": "eee",
"client_secret": "fff",
"redirect_uris": [
"ggg"
]
}
}
NOTE: Don't forget to press the Done button to make sure the app sticks around!
NOTE 2: If you want to use Google Drive to store still images from Nest devices, please refer to the additional steps below in the Google Drive section.
On the Apps page, click the link to Google SDM API
Now that the previous steps are complete, you should now see a section: Auth Link - Click this link to authorize with your Google Device Access Project.
Click on this link, and walk through the steps to authorize with Google. When complete, you will be redirected back to a basic page provided by this HE app.
Click the specified link to return to the App configuration page. It will now display a Discover button
Press the Discover button on the Google SDM API app page to discover your authorized Nest devices.
Many previous device attributes are migrated into the device state variables in order to reduce event noise. It is recommended that you run a fresh "Discover" after applying the new code to Hubitat for the App/Drivers. This will take care of setting the relevant state map for the device so that it can be referenced later. If this is not done, you may see some transient errors, when the code attempts to retrieve data from state -- when the desired data is not found, the device will automatically refresh in order to populate the state map.
The latest still image is downloaded when a device event is received (Doorbell, Camera, Display). This can be displayed in a HE dashboard
using the attribute
tile. Simply select the device, and the attribute to use is image
.
Most of Google's 2021 models -- battery cam (indoor/outdoor), indoor hardwired cam, and floodlight cam -- do not support any image capture via the API, even on device events.
Google's 2021 battery doorbell supports a 10-frame mp4 clip preview -- this is handled using the same attributes as prior still image captures
New feature in App version 0.6.0, and corresponding Camera/Display/Doorbell driver versions 0.4.0, which allows the user to use Google Drive as storage for the still images downloaded from Nest events. This feature enables the latest image to be displayed in both Local and Cloud dashboards. Before enabling this feature, the user needs to enable the Drive API:
Select a Project
drop-down. Select the existing Project for your SDM API/Nest integration+ ENABLE APIS and SERVICES
at the topDrive
in the search bar, then select the Google Drive API
ENABLE
on the next screenAfter enabling this feature using the preferences toggle, the user is required to re-authorize with Google in order to obtain the updated auth scopes. An additional input will be displayed to set the number of days for retention of images (default 7) -- a cleanup job is scheduled to run at 11pm every night, which will clean up any files the App has uploaded that are older than this setting.
A "Motion" event from Google will trigger a motion Active event in HE. Since the current API does not send another event when motion is no longer detected, a preferences entry is defined for each device, which determines the amount of time before the motion is deemed Inactive. If another motion event is received before this timer expires, the Inactive transition is deferred for the specified interval.
A "Person" event from Google will trigger a presence Present event in HE. A preferences entry determining the length of "presence" is defined as for motion above.
A "Sound" event from Google will trigger a sound detected event in HE. A preferences entry determining the length of sound "detection" is defined as for motion above.
The doorbell chime will generate a pushed event on button 1
for the device.
Any of these HE events can be used for Rule Machine or Notification triggers.
NOTE: only Google-branded devices appear to support zone tracking in the API -- legacy Nest devices are excluded.
For a Camera, Display, or Doorbell device, a preferences toggle is available to enable tracking of events for defined zones via child devices. A command is available on the primary device to pre-generate the zone children -- the name must exactly match the zone name defined in Google Home.
This button will log your current Google access-token, so that you can use it to manually make calls to google for testing
This button will trigger the App to refresh your Google access-token.
This button will attempt to create the event subscription with Google pub/sub -- useful if this initially failed for any reason.
If a matching subscription already exists, it will log a 409 warning. If this occurs and you are not receiving events, it's possible
that the existing subscription does not match the local state.accessToken which is being used by HE to authorize the incoming POST.
This button will delete the current Google pub/sub event subscription. If you need to use this button, immediately follow up with the above Subscribe to Events button to re-create your event stream.
This button will delete all child devices from HE, which represent your physical Nest devices. Useful if you need/want to clean up and start over, without needing to re-authorize with Google. You can follow this up with the Discover button on the main App page to re-discover your devices.
The App checks that all required prerequisites are present before revealing this button. This includes the following:
You can validate these entries by going to the App page in HE, then click on the settings gear icon in the top-right corner.