Google Nest Device Access Console now available

I can also be a tester with the Nest IQ Outdoor camera and Nest Doorbell. Thank-you!

I was able to get the token and renew it. How do I use it now to get i.e. temperature from a thermostat?
Do I need to manually create a thing for the thermostate?

Hi,
to retrieve data youā€™ve to call a GET in a rule like below:

    val string NestCommand = "C:/Curl/curl.exe -s -X GET \"https://smartdevicemanagement.googleapis.com/v1/enterprises/RESERVED INFO/devices\" -H \"Content-Type: application/json\" -H \"Authorization: Bearer "+NestToken.state+"\""
	logInfo("Nest", "Nest Command {}", NestCommand)	
	val String NestStatus = executeCommandLine(NestCommand, 120*1000)
	logInfo("Nest", "Nest status {}", NestStatus)	

Youā€™ll see the response in openhab log

Itā€™s a primitive way to do but itā€™s working, remember Iā€™m not a programmer :wink:

@wborn

It would very appreciated if you time to work on a binding, as you see Iā€™m just testing the new Google approach but my programming skills are limited so any help from a software guy is welcome

I have a couple of nest protects and can help with testing for those devices.

Interested to work on the binding, Iā€™m getting my Nest thermostat next week, and looking to hook it up with openHAB. If thereā€™s a Slack channel set up or something, let me know, otherwise Iā€™ll start working on one next week :slight_smile:

2 Likes

Iā€™ve started working on a basic Java Wrapper for the google nest here: https://github.com/Lovett1991/Google-Nest-Java-API/tree/init/src/main/java/com/alexlovett/nestapi, was going to finish some models first and then work on either a PR, or possibly a new Binding as to leave the old nest one alone (I donā€™t know what the preference of the community is).

Iā€™ve managed to hit the api, although getting the oauth token was a bit of bother. Example response below:

{
"devices": [
    {
        "name": "enterprises/50c23437-496d-4346-8ab5-025ad314f588/devices/AVPHwEugs3UXY24WnpmWAHPGCxWvWibmfuIsGkNtqwtNxfgukru42yGkOqE7mvPM7pJPzrNPprSX3QNt2RtVMWscbxmIJg",
        "type": "sdm.devices.types.THERMOSTAT",
        "assignee": "enterprises/50c23437-496d-4346-8ab5-025ad314f588/structures/AVPHwEtcHnbHeXrGt5OzvtHSB4UfL6Nc0f1ZW4jx7l3LIIyoL3ZgzXlsMt29dgX-tRV905UBtZ7bGTPRspMp9-s44U27AQ/rooms/AVPHwEtRuiPChXZytLkGbuZ84PN1ehtCpjMRMMUguULj6dmlkmG44N_sF6hWYeu2aM2_WoAC6V7OQyjHEOgZnhIPIxWBR11flQihzgOWiFm6NaZaaqDnpYjctLcWu7tssom6WrN-wsKmayI",
        "traits": {
            "sdm.devices.traits.Info": {
                "customName": ""
            },
            "sdm.devices.traits.Humidity": {
                "ambientHumidityPercent": 70
            },
            "sdm.devices.traits.Connectivity": {
                "status": "ONLINE"
            },
            "sdm.devices.traits.Fan": {},
            "sdm.devices.traits.ThermostatMode": {
                "mode": "HEAT",
                "availableModes": [
                    "HEAT",
                    "OFF"
                ]
            },
            "sdm.devices.traits.ThermostatEco": {
                "availableModes": [
                    "OFF",
                    "MANUAL_ECO"
                ],
                "mode": "OFF",
                "heatCelsius": 10,
                "coolCelsius": 24.44443
            },
            "sdm.devices.traits.ThermostatHvac": {
                "status": "OFF"
            },
            "sdm.devices.traits.Settings": {
                "temperatureScale": "CELSIUS"
            },
            "sdm.devices.traits.ThermostatTemperatureSetpoint": {
                "heatCelsius": 15.36406
            },
            "sdm.devices.traits.Temperature": {
                "ambientTemperatureCelsius": 20.73999
            }
        },
        "parentRelations": [
            {
                "parent": "enterprises/50c23437-496d-4346-8ab5-025ad314f588/structures/AVPHwEtcHnbHeXrGt5OzvtHSB4UfL6Nc0f1ZW4jx7l3LIIyoL3ZgzXlsMt29dgX-tRV905UBtZ7bGTPRspMp9-s44U27AQ/rooms/AVPHwEtRuiPChXZytLkGbuZ84PN1ehtCpjMRMMUguULj6dmlkmG44N_sF6hWYeu2aM2_WoAC6V7OQyjHEOgZnhIPIxWBR11flQihzgOWiFm6NaZaaqDnpYjctLcWu7tssom6WrN-wsKmayI",
                "displayName": "Living room"
            }
        ]
    }
]
}

From what I read, you shouldnā€™t need to do this. The refresh token is valid indefinitely. We can just keep polling the api until we receive a 401, and then grab a new token on that event. OkHttp has functionality to do this for us.

@McFly I have to reply here Iā€™m afraid, the comment limit is 3 for new usersā€¦

Yup, there are 2 tokens, one is for accessing the data which expires after an hour (as you stated), the other is the refresh token (as youā€™ve stated), when I looked it up, it seems that the refresh token doesnā€™t expire, but it can obviously be revoked by the user.

For what I understood we have 2 tokens

One to be renewd every hour. This should be the one used for normal poll.

The second is for requests the renewal of the first one. I donā€™t know if and when this expires.

Iā€™ll probably add it to the existing binding and then remove the old implementation when the API is dropped so users can migrate whenever they want.

Itā€™s also a lot easier to implement everything in the existing binding using libraries that are already part of the openHAB target platform, instead of implementing it in a third party library with non standard or incompatible openHAB dependencies. That reduces overhead and makes it easier to fix bugs or add new features in the binding.

6 Likes

Iā€™ve created an issue for this :slight_smile:

Does migrating your old Nest Account to a Google Account break a current setup? I do only have a lot Nest Protect but I want to try Googleā€™s own Home & Away Routines.

I canā€™t answer your question, but I also only have a Nest Protect and I noticed that itā€™s not included in the Device Access Console. I canā€™t think of any reason other than ā€œbecause Googleā€.

1 Like

Because google acquires the separate devices and tech from different companies and builds a product family. It takes a while to re-engineer the back ends of these devices to all talk on the same API. The process has to be done carefully as to not break what is already working. Some devices are so radically different they will never be fully added, new version will be manufactured and they have to end of life others. Itā€™s a slow process.

I took on the dubious task of learning the SDM API and using device access along with binding development (Especially after my Nest integrations broke when I migrated way from ā€œWorks with Nestā€ )

Here is what I got thus far:
setup non-commerical GCP project for SDM API - check
setup pub/sub in the project - check
authorized my Google/Nest account with GCP project -check
coded an Openhab binding that works with thermostat base functions (getDevices, getStructures, etcā€¦) - check
coded an Openhab discovery service that enrolls things from the project device listing -check

Iā€™m now going through adding handlerCommand actions for the thermostat channels (I donā€™t have cameras or other devices to test.) Since I have most data from the Devices listing, the informational items like ambient temperature, current modes and settings will be very easy to add. Then Iā€™ll move on to changes like setpoint updates in temperature setting, mode changes etcā€¦ Lastly, finishing with a pub/sub topic integration to feed events into the handler.

I went down this route because:

1 - Learning Google oAuth and SDM programming is fun and wanted to do my first project with it
2 - I migrated away from ā€œWorks with Nestā€ and found that I havenā€™t had nest integration with my thermostats until this binding development :wink:

Iā€™ll probably complete this binding for my need since there isnā€™t an ā€œofficialā€ binding out there that I can use.

I suppose my question is whether there is an ā€œofficialā€ binding in the works or if what Iā€™m working on sums up to more than a pet project? Iā€™m happy to share code or the binding if there is an interest. If there is an official binding in the works, then this was a great experience either way :smiley:

3 Likes

That would make sense if the Protect wasnā€™t already part of the same family as the other Nest products, and if it hadnā€™t taken them well over a year to go from shuttering Works with Nest to releasing the Device Access Console. However, as far as Iā€™m aware (and please correct me if Iā€™m wrong), the Nest thermostats, cameras, and Protects were designed by the same people from the start. This isnā€™t like TP-Link buying the Tapo IP and running it alongsideā€“but separately fromā€“their existing Kasa devices.

Donā€™t get me wrongā€“Iā€™m generally cool with Google and have defended the company a fair amount in this forum, but itā€™s impossible to ignore their practice of abandoning products by quietly dropping support in the hope that no one will notice. Thereā€™s a decent chance that the Nest Protect will suddenly appear in the DAC one day, but itā€™s also entirely possible that Google is no longer interested in supporting smoke/CO detectors or putting more development time into the ones theyā€™ve sold.

Personally, Iā€™ll be fine with the Nest Protect so long as the app continues to work. Integration aside, itā€™s a great smoke/CO detector. Itā€™s just disappointing that it hasnā€™t met its potential.

Yes Iā€™m working on getting the new SDM API supported in the official binding while keeping the WWN API support also working (see also #8664). The new SDM API doesnā€™t support all features that WWN does, so for instance users with Nest Protects would lose their complete Nest integration.

Please do because I hate reinventing wheels! :slight_smile: :+1: Perhaps you can push it to a GitHub branch so I can have a look at it?

Now that we have a pretty stable OH 3.0.0.M1 (which was my main priority) I will shift my priorities to getting the Nest SDM integration added to 3.0.0. It wouldnā€™t make much sense to use the updated Nest Binding when OH3 itself is unstable. :wink:

5 Likes

You might be right. Iā€™m irritated now because I canā€™t use my google suite account wit their new API, and app. And now my nest products are Dead until I create a NEW gmail account that is not gsuite. Which irritates me. I PAY extra for a google account I canā€™t use with GOOGLEā€™s product.

Sorry for the delayed response. I took sometime to refactor the binding to allow for individual device classes (i.e. Thermostat, doorbell and camera.) The Thermostat class if pretty much fully functional with Nest Thermostats SDM APIs. Also, since there is a way to set Eco it could replace the AWAY function in that you set an away switch and it triggers ECO mode. There are definitely some items missing from the WWN implementation and integrations with other products that is a bummer. For folks like me that migrated and canā€™t go back to WWN, the binding does the trick.

Iā€™m going to do some testing tomorrow/this weekend and then I can post the code for folks to review. Iā€™m sure there are items/fixes to make that others will see :wink:

Also, right now Iā€™m operating off a non-commercial project with the SDM APIs enabled. Is someone going to create a commercial project?

The way the binding is written is you update the projectId, clientId, clientSecret, initial authorizationToken and it will go get the refreshToken. From there it performs a discovery against devices that you authorized on the project and are accessible by your accessToken. Then you can begin working in OH with the things.

Theoretically you can fill those fields out and tie the binding to any SDM enabled project. Iā€™m just using a sandbox for now to get the binding up/tested :smiley:

To do:
Get pub/sub up and running (Leveraging refreshScheduler at 30s intervals for now.)
Get camera class written
get doorbell class written.

Congrats on the OH 3.0.0.M1 stabilityā€¦

3 Likes

Great to read that!!!
Waiting for your news :wink:

When youā€™re ready Iā€™m here for testing

Thanks for your time