Nest Developer access now live

So, is this an Oauth from Hubitat? Or is it the one you get later from Google?

Assuming it is from Hubitat, use the one from Maker API?

I set this up using the values from Google Cloud Platform (credentials.json), and ended up with some manual steps to get the authorization_code from google and copy to the HE app. Still playing with how to make that more seamless, though.

Maker API is not the answer (thanks @ogiewon for the pointers away from that to the app OAuth configuration)

5 Likes

I got it. Was going the totally wrong direction. I got both of my Doorbells showing up now. Awesome (They were discovered as "null" which was throwing me off - Will have to figure out how to determine which is which)

Currently the name/label in HE uses the "customName" received in the API response. This appears to map to the "Label" in the Nest device settings, under "Location". Will look at having a fallback to "room" name if "customName" is empty.

2 Likes

Ahhhhh, It's been so long, I thought I had named them. But, it was just the locations. Deleted them in the app on HE after giving them a label in NEST and reran the discovery. Perfect.

I've implemented thermostat commands. I noticed in my testing that changes to the fan state don't appear to generate events -- so a manual refresh is currently required to reflect those changes.

4 Likes

In the Dashboard, it appears that the "lastUpdated" (attribute) tile (along with the thermostat tiles) are only displaying the initial states when they were imported via the API. Is there an easy way to manually refresh? Reloading the dashboard doesn't seem to be refreshing the data. That being said, I can go to the device and hit refresh and that does seem to work.

@jonathan.lorber have you added the latest code from master (merged ~24 minutes ago)? This had several robustness fixes in translating the events from Google to the HE device attributes, and also supports the refresh command on the device, to query the latest state from the API

1 Like

Yes. I updated the code about 15 mins ago. I went ahead and delete and re-discovered within the Google SDM API app. I did notice the following error in the logs when trying to change the cooling setpoint on one of the thermostats.

Easy fix - you just need to replace these two functions (specifically the line in the else case). When Hubitat calls out a heat/cool setpoint in the rule machine, it does each separately. If you make the changes below, it will retrieve the heat or cool value that you aren't changing.

def setCoolingSetpoint(temp) {
def mode = device.currentValue('thermostatMode')
if (mode == 'cool') {
parent.deviceSetTemperatureSetpoint(device, null, temp)
} else {
parent.deviceSetTemperatureSetpoint(device, device.currentValue('heatingSetpoint'), temp)
}
}

def setHeatingSetpoint(temp) {
def mode = device.currentValue('thermostatMode')
if (mode == 'heat') {
parent.deviceSetTemperatureSetpoint(device, temp, null)
} else {
parent.deviceSetTemperatureSetpoint(device, temp, device.currentValue('coolingSetpoint'))
}
}

@dkilgore90 Awesome work BTW! I was trying to get my thermostats to change with conditions for a while, and the best I could do was with GAR, but Google Assistant is buggered in auto mode and messes up the dead band between the setpoints.

4 Likes

great feedback! As a first pass, I enforced the same rules that google does -- but as you pointed out, if we only want to modify the coolingSetpoint while in HEATCOOL/auto mode, we can simply "re-set" the the existing heatingSetpoint alongside it

5 Likes

Brilliant!! Set Point working very nicely and smoothly here :slight_smile:

Could I ask a really massive favour here?
We in the UK can also control hot water here if you have the Nest 3rd.

Its a simple case of flicking a switch, Nest will then turn on for 30 mins, then turn off on its own, unless you send params for a duration. I have this working in Homebridge, but the downside is with Homebridge, I keep losing connection (no idea why). As yet, no one has looked at this as most users are in the US or don't have a UK "S" system.

I didn't see any API for this on Google, but it must exist as homebridge-nest is able to use it. Any help in this direction would be massively appreciated. Of course I know you have a lot to do, just putting this out there for consideration :smiley: :+1:

1 Like

It's great to be able to check again.. 'if window is open and heat is on'! Thank you.

Can't wait to be able to trigger on motionPerson from my front doorbell and back door camera's. Been messing around with it a bit and it works pretty good. Excited to see what you do with this.

4 Likes

@dkilgore90 a big thank you for putting this together... installed and working. Looking forward to seeing how you expand out the features. Also would like to see some sort of support for control over hot water (Nest 3rd gen here, from the UK).

To anyone following these instructions, please note that access to the Google SDM API doesn't work if the email address you use is from Google's G-Suite (I moved my domain over years ago). It appears to only want to work with a personal email account. I had to register a new account and pay again! :money_mouth_face:

3 Likes

@Royski @nutcracker I'll look into the hot water control -- from a cursory google search, seems like this may be a back door (for now), I don't see anything in the SDM API docs...

3 Likes

Yeah agree, after I wrote the above, I gathered the info from my API and Postman and saw nothing related although Homebridge is managing it somehow. I'll try and take a look how its being done there :+1:

Update
Looks like its being achieved here

        if (this.device.has_hot_water_control && !this.platform.optionSet('Thermostat.HotWater.Disable', this.device.serial_number, this.device.device_id)) {
        const hotWaterService = this.addService(Service.Switch, 'Hot Water', 'hot_water.' + this.device.serial_number);
        this.bindCharacteristic(hotWaterService, Characteristic.On, 'Hot Water', this.getHotWaterState, this.setHotWaterState);
    }
1 Like

Heads up -- when I added thermostat actions, I broke the event subscription -- so if you initially installed between then and now, your devices probably are not updating outside of a manual refresh. I have pushed a fix for this -- if your events are not working, install the latest code, then use the Subscribe to Events debug button at the bottom of the app page to generate the event subscription.

Big thanks to @jonathan.lorber for notifying me of the problem, and working with me to troubleshoot until we discovered the bug!

3 Likes

Just updated, and push the button but got an error

app:94042020-10-03 18:29:10.429 debugGoogle SDM API updating
app:94042020-10-03 18:29:08.592 errorjava.lang.Exception: No response data exists for async request on line 414 (putResponse)
app:94042020-10-03 18:29:08.580 debug403

@dkilgore90 would be great if you could start versioning the app/driver code... (to keep track of updates) or better still, make available in HPM? :grin:

2 Likes

403 on event subscription... Either your token is missing a scope for pubsub -- this was part of the original manual OAuth setup -- or perhaps the pubsub API is not properly enabled on your project? DM me if you need help confirming the right settings