Google Nest Device Access Console now available

I bought a nest thermostat without realizing that they cancelled works with nest. Will this work the same as works with nest so we could set it up now?

Watching this thread :slight_smile:

Looks like they are making some progress over at the Home Assistant Community:

+1 For this.

I’ve had a small play with the api, I would be happy to help develop this binding (I don’t have much free time) if there’s a shortage.

1 Like

@McFly appears to have gotten it working.

I’m posting here in the hopes of consolidating discussion in this relatively new thread instead of the year-old “Deprecating on…” thread. :wink:

3 Likes

Thanks to “linked” me to this discussion, had no time today to work on it hope to find free time next days, if someone more skilled in programming than me want to contribute here I can share my tests

1 Like

A little update for who are unable to wait :rofl:

Making the poll request the system returns:

{
  "devices": [
    {
      "name": "enterprises/RESERVED INFO",
      "type": "sdm.devices.types.THERMOSTAT",
      "assignee": "enterprisesRESERVED INFO",
      "traits": {
        "sdm.devices.traits.Info": {
          "customName": ""
        },
        "sdm.devices.traits.Humidity": {
          "ambientHumidityPercent": 63
        },
        "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": 15.4444,
          "coolCelsius": 24.44443
        },
        "sdm.devices.traits.ThermostatHvac": {
          "status": "OFF"
        },
        "sdm.devices.traits.Settings": {
          "temperatureScale": "CELSIUS"
        },
        "sdm.devices.traits.ThermostatTemperatureSetpoint": {
          "heatCelsius": 17.02672
        },
        "sdm.devices.traits.Temperature": {
          "ambientTemperatureCelsius": 21.45999
        }
      },
      "parentRelations": [
        {
          "parent": "enterprises/RESERVED INFO",
          "displayName": "NEST NAME"
        }
      ]
    }
  ]
}

It lacks of the away/at home info as per previous method with cookie…
Need to investigate, any help is appreciated.

This is the rule I implemented to renew the acces token, by default it expires in 60minutes, so I’m updating it every 30minutes

rule "NestTokenRenew"
when
	System started or
	Time cron "0 0/30 * * * ?"		// 3600 seconds for token to expire
then
    val String NestNewToken = executeCommandLine("C:/Curl/curl.exe -s -L -X POST \"https://www.googleapis.com/oauth2/v4/token?client_id=RESERVED INFO&client_secret=RESERVED INFO&refresh_token=RESERVED INFO&grant_type=refresh_token\"", 120*1000)
	//logInfo("Nest", "Nest New Token reply to request : {}", NestNewToken)
	NestNewToken = transform("JSONPATH", "$.access_token", NestNewToken)
	//logInfo("Nest", "Nest New Token : {}", NestNewToken)
	NestToken.postUpdate(NestNewToken)
	NestToken.persist
end

Seems to work from yesterday without issues

Is anybody already working on a binding? If nobody is I might also put some effort into it.

I’m still using the old API with the binding but it’s probably just a matter of time before Google will add the old API to their graveyard now that they have their replacement. :dizzy_face:

13 Likes

It doesn’t seems so. So it would be great if you could start working on a binding. I am so looking forward to it…

I’d be happy to test with my nest doorbell.

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.