[RELEASE] Google SDM API - Nest integration

I spent a few hours on this just now. I already had events enabled in Google Home for the new camera. I walked through all the setup steps for authorization. I can delete the Camera device in Hubitat, and the SDM app will find it again and recreate it, but after that there's no activity.

All permission line up with my other two (older) cameras. I'm stumped. I was hoping to use this app to detect motion events to trigger another rule. :frowning:

Hmm... difficult to diagnose without some concrete data to review (settings, permissions).

Debug logs might be useful to double-check if some events are being received but not processed properly. Otherwise, you could try the debug buttons to delete and re-create the event subscription, maybe something is cached on Google's side that hasn't tied in the new device?

I've tried the debug delete/re-create route. I'm not going to ask you to help with any additional troubleshooting right now. I have an instance of Home Assistant that I spooled up a few weeks ago so I'm going to try and get it going there.

Thanks for the assist!

I’m a newbie and have been trying to link my Nest Thermostat.

I used this App Code: Hubitat Elevation - Google SDM API

I used this Driver's Code: https://raw.githubusercontent.com/dkilgore90/google-sdm-api/master/sdm-api-thermostat.groovy

In the App Code, I changed the UUID code and JSON code to what what given to me by Google.

I go to the Apps Page and click on the link Google SDM API but no Auth Link is provided.

I'm not sure what I'm doing wrong. Aaargh

Suspect you've missed the oauth enable in Apps Code, refer this post:

Has anyone else experienced an issue with a google nest doorbell battery (but attached to a power supply) not setting its Presence state correctly?

My doorbell triggers "Presence" at the right moment but it pays no attention to the Presence Timeout setting and just continues to stay Present until I click the refresh button which fixes it.

Other than creating a rule which says if the Presence is remaining for x time then refresh I have no clue how I would fix this.

I also have a Google Security Camera/Floodlight through this integration and this works perfectly each time.

Can you confirm the versions of the doorbell driver and the app? There were fixes in version 1.0.2 of each for thread handling and correlation. For the newer Google-branded devices, the timeout is no longer used, since the device itself provides an ENDED event.

If you have 1.0.2 or newer installed for the app and driver, then I'd be interested to see debug logs from the app and driver, to see if an event is missed or some error in processing it.

Hi there, thanks for your note and help.

I've just checked, it's v1. 0.8

I'm about to head off on holiday but have enabled debug logging and will try to get some logs.

Steve

Hey just recently my thermostat stopped accepting commands. I try it directly from the device and nothing changes. For example if I try to set the cooling point or the cooling and heating point it doesn’t do anything. I do get some Deadband errors in the device logs, but no errors in the app logs. Any idea what’s going on?

(BTW it had worked for months just fine.)

You can ignore the deadband...I realized I was putting the data in wrong....however, I did see this in the device logs:

app:29852023-06-09 05:39:19.567 PMinfoRefresh device details for Nest Hallway Thermostat

app:29852023-06-09 05:39:19.565 PMwarnReceived event out of order -- timestamp: 2023-06-09T22:39:14.637Z, lastEventTime: 2023-06-09T17:39:14.919-05:00 -- refreshing device Nest Hallway Thermostat

The "event out of order" is a (probably unnecessary) safeguard, since Google does not guarantee that events are delivered in the order they were generated. Since theoretically the same attribute could change in a pair of events, processing them out of order would result in an incorrect state in Hubitat. So the App persists the timestamp of the last processed event for a thermostat device, and if it detects out of order, it runs a full refresh. In hindsight, this is probably a rare case, but I never went back to remove this function.

Thanks! That makes sense. However, I’m have the issue that stuck the Hubitat device is not sending changes of temp to the Nest device. The logs look clean and like I said it has been working for a few months without issue. I did force a token refresh, remove and re-add subscriptions. Any other ideas?

Are the debug logs above filtered? I'd expect to also see the raw json received...

Regarding commands not sent, we should be able to see app info logs when the command is triggered:

Sending ${command} to ${device} with params: ${cmdParams}

If sent successfully, we'd also expect to see a corresponding event shortly after, confirming the attribute change.

Can you provide some examples of commands invoked, what params were passed, and corresponding logs generated?

Sure thing...Thanks for any help you can give.

I just run the set Heat and Cooling Point from the device. I took a screenshot below. I also run a refresh. Also, everything that shows up in the logs for the device and App.

dev:21772023-06-10 01:59:26.803 PMdebugNest Hallway Thermostat: updating state -- room: Hallway
app:29852023-06-10 01:59:26.783 PMdebugProcessing data for Nest Hallway Thermostat: [name:enterprises/ef1d/devices/AVPHwEs*************vRTjzHQ, type:sdm.devices.types.THERMOSTAT, assignee:enterprises/efe41d/structures/AVPHwEs-ha3OU*****Afg/rooms/AVPHwE*************b5cbOM, traits:[sdm.devices.traits.Info:[customName:], sdm.devices.traits.Humidity:[ambientHumidityPercent:62], sdm.devices.traits.Connectivity:[status:ONLINE], sdm.devices.traits.Fan:[timerMode:OFF], sdm.devices.traits.ThermostatMode:[mode:HEATCOOL, availableModes:[HEAT, COOL, HEATCOOL, OFF]], sdm.devices.traits.ThermostatEco:[availableModes:[OFF, MANUAL_ECO], mode:OFF, heatCelsius:18.23781, coolCelsius:28.88898], sdm.devices.traits.ThermostatHvac:[status:COOLING], sdm.devices.traits.Settings:[temperatureScale:FAHRENHEIT], sdm.devices.traits.ThermostatTemperatureSetpoint:[heatCelsius:18.333334, coolCelsius:22.777779], sdm.devices.traits.Temperature:[ambientTemperatureCelsius:22.86]], parentRelations:[[parent:enterprises/efe5-------------------/structures/A----------------/***********************************OM, displayName:Hallway]]]
app:29852023-06-10 01:59:25.619 PMinfoRefresh device details for Nest Hallway Thermostat
dev:21772023-06-10 01:59:19.211 PMdebugNest Hallway Thermostat: updating state -- lastEventTime: 2023-06-10T13:59:17.056-05:00
dev:21772023-06-10 01:59:19.168 PMdebugNest Hallway Thermostat: updating state -- lastEventTime: 2023-06-10T13:59:17.056-05:00
app:29852023-06-10 01:59:16.112 PMinfoSending sdm.devices.commands.ThermostatTemperatureSetpoint.SetRange to Nest Hallway Thermostat with params: [coolCelsius:23.8888888889, heatCelsius:15.5555555556]

Google API APP:

app:29852023-06-10 01:59:19.178 PMdebugEvent received from Google pub/sub
app:29852023-06-10 01:59:19.140 PMdebugEvent received from Google pub/sub

Hmm, seems to be missing some of the expected logging. Just after "event received" it should log the whole event JSON sent by Google. But it does update the lastEventTime for the device... As if some lines of App code are missing.

The repo shows 1341 lines in the latest code - maybe double-check, and/or replace whatever is there with the latest code? Hubitat Elevation - Google SDM API

I did do an update via HPM, but I think that was a few weeks ago. I checked the line count and it was at 1341. I went ahead and re-imported it via the github link just in case. I also did the same with with the device driver as well. Then I reran the Heating and Cooling command, Again I got the same results. (Also, I'm on the latest platform version: 2.3.5.146 on a C-7.) Here are the latest logs:

device logs:
dev:21772023-06-10 04:24:46.930 PMdebugNest Hallway Thermostat: updating state -- lastEventTime: 2023-06-10T16:24:44.326-05:00
dev:21772023-06-10 04:24:45.597 PMdebugNest Hallway Thermostat: updating state -- lastEventTime: 2023-06-10T16:24:44.326-05:00
app:29852023-06-10 04:24:43.480 PMinfoSending sdm.devices.commands.ThermostatTemperatureSetpoint.SetRange to Nest Hallway Thermostat with params: [coolCelsius:23.8888888889, heatCelsius:15.5555555556]
dev:21772023-06-10 04:23:28.719 PMdebugNest Hallway Thermostat: updating state -- room: Hallway
app:29852023-06-10 04:23:28.700 PMdebugProcessing data for Nest Hallway Thermostat: [name:enterprises/1d/devices/AQ, type:sdm.devices.types.THERMOSTAT, assignee:enterprises/ef***********/structures/Afg/rooms/*************, traits:[sdm.devices.traits.Info:[customName:], sdm.devices.traits.Humidity:[ambientHumidityPercent:57], sdm.devices.traits.Connectivity:[status:ONLINE], sdm.devices.traits.Fan:[timerMode:OFF], sdm.devices.traits.ThermostatMode:[mode:HEATCOOL, availableModes:[HEAT, COOL, HEATCOOL, OFF]], sdm.devices.traits.ThermostatEco:[availableModes:[OFF, MANUAL_ECO], mode:OFF, heatCelsius:18.23781, coolCelsius:28.88898], sdm.devices.traits.ThermostatHvac:[status:OFF], sdm.devices.traits.Settings:[temperatureScale:FAHRENHEIT], sdm.devices.traits.ThermostatTemperatureSetpoint:[heatCelsius:18.333334, coolCelsius:22.777779], sdm.devices.traits.Temperature:[ambientTemperatureCelsius:22.53]], parentRelations:[[parent:enterprises/---------1d/structures/*************************Afg/rooms/*******************M, displayName:Hallway]]]
app:29852023-06-10 04:23:27.618 PMinfoRefresh device details for Nest Hallway Thermostat
app:29852023-06-10 04:23:27.617 PMwarnReceived event out of order -- timestamp: 2023-06-10T21:23:20.784Z, lastEventTime: 2023-06-10T16:23:21.241-05:00 -- refreshing device Nest Hallway Thermostat
dev:21772023-06-10 04:23:23.512 PMdebugNest Hallway Thermostat: updating state -- lastEventTime: 2023-06-10T16:23:21.241-05:00
dev:21772023-06-10 04:23:23.464 PMdebugNest Hallway Thermostat: updating state -- lastEventTime: 2023-06-10T16:23:21.230-05:00
dev:21772023-06-10 04:19:55.964 PMdebugNest Hallway Thermostat: updating state -- room: Hallway

Google API Logs:
app:29852023-06-10 04:24:46.905 PMdebugEvent received from Google pub/sub
app:29852023-06-10 04:24:45.571 PMdebugEvent received from Google pub/sub
app:29852023-06-10 04:23:27.600 PMdebugEvent received from Google pub/sub
app:29852023-06-10 04:23:23.485 PMdebugEvent received from Google pub/sub
app:29852023-06-10 04:23:23.441 PMdebugEvent received from Google pub/sub
app:29852023-06-10 04:19:43.097 PMdebugEvent received from Google pub/sub

@dkilgore90

Further to my note about the Doorbell not releasing the Presence Status. Here are some logs below.

Looking in the Google Home app at the recorded event the Hubitat missed a trick because there was another person at the door at 5.17pm but it was still showing as presence from the one 5 minutes before.

I'm looking at the status now and its still showing as Present with no sign of automatically timing out.

I guess I could add a rule to reset it myself but that feels a bit unsophiticated and I would rather make it work as it should.

The separate Google Camera I have is still working as expected.

Steve

@user4286 - I'll look into this, I agree it seems certain threads (maybe all) are getting stuck because we're not getting or processing the event to end it.

Do you have corresponding debug logs from the App? This would be helpful to review if we even received the event...

Google redesigned the event flow for the newer Google-branded cameras, so the code expects to get an ENDED event to signify that the state should be cleared - the timeout is not used in such cases. If Hubitat is not reliably receiving such an event for a given device, then I could see a use case to use the timeout as a fallback.

Regarding the 5:17 event, from the posted logs even the STARTED event was not received at this time - regardless of the prior thread not being cleared. The code can handle multiple active threads at a time.

@aarony some logs are still missing :frowning: - I wonder if some processing or function (or even logging) is getting hung up and shows up out of sequence, later.

From the refresh, though - it seems this is not only an events issue, but even the command does not make it through, as the values on refresh do not match what was sent? Yet the refresh successfully gets a response...

Any timeout in the logs, perhaps up to 5 minutes later, after the command is sent?

Can never get this bit to run correctly