Git Product home page Git Product logo

google-sdm-api's People

Contributors

codahq avatar codyrandall avatar dkilgore90 avatar gassgs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-sdm-api's Issues

Discover Button not showing

I have went through the great implementation walk-thru and approved the two Nest Thermostat devices from the Google API approval process. When it redirects me back to the hubitat page I never see the "Discover Button" or any of the devices that I approved via the Google process.

Can we get motion information from the Device Access Console?

Thanks for you documentation

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.

Dose this mean that we can capture a motion active event from google smart device?

Failed due to "client_secret" missing

Hi there,
Got through most of the guide, but failed at the last step as I'm told that the client_secret is missing. I tried putting it into the credentials.json, but no joy. Any thoughts?
Thanks...
2022-03-16 10_13_56-Hubitat Elevation - Google SDM API

StreamURL Empty

I can not get the streamURL to populate for any legacy camera, doorbell or display device streams. I have initialized them and made sure the video stream is enabled. Any combination of settings and reconnecting doesn't seem to change anything. Motion/images/other pub/sub events work fine.

I can manually fetch a token and refresh the token successfully through the regular external api - https://developers.google.com/nest/device-access/api/camera

Am I missing something in the setup?

Add hot water support to thermostat

Here in the UK, some models of the Nest Thermostat can control the hot water as well as the heating.

I can't currently see a way in the Google SDM API docs to control this, however I'm logging this as a place-holder so it can be added to Hubitat once it's available in the upstream API.

Can set thermostat modes, but can't read them

Thermostat modes and setpoints are not updating for the device. I can set modes & setpoints fine, but Hubitat will not read the current state, even if I set it from the device itself.

Remove lastEventTime from events

I think the lastEventTime event is not needed, each event already has a time stamp. I would suggest moving it to a device state.
Suggestion:
driver - remove
attribute 'lastEventTime', 'string'
driver - append
def lastEventTime(String eventTime) {
state.lastEventTime = eventTime
}
sdm app replace sendEvent(device, [name: 'lastEventTime', value: utcTimestamp.format("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", location.timeZone)])
with:
device.lastEventTime(utcTimestamp.format("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"))

def postEvents() time compare needs to be >=, not >

This line needs to be changed to:
if ( timeCompare >= 0 || lastEvent == null ) {

I'm noticing that when a heat & cool temp is set concurrently, two events are received at the same time, which forces a out of sync warning on the lines below.

Null Pointer Exception

Making adjustment to temperature in Nest app or on thermostat itself does not update in Hubitat. Getting following error in logs:

errorjava.lang.NullPointerException: null (postEvents)

Initial install can't set heatpoint

I just walked through the installation guide for thermostats. Upon trying to set the heatpoint I get the following exception:

java.lang.NullPointerException: Cannot invoke method toFloat() on null object on line 147 (setHeatingSetpoint)

The issue is here

def tempMovement = heat.toFloat() - cool.toFloat() + deadband
If a cooling\heating setpoint isn't set yet your get an NPE. You should initialize them to sane values or handle the null pointer properly.

As you can see I don't have a cooling setpoint yet.

image

Great work !!! Ability to write (execute) any of the traits yet?

Hi dkilgore90, wow this is great progress - been waiting for it a long time and fantastic to see how fare you already are.

When I check out the drivers, seems you already wrote code to execute against the traits (example Thermostat, set fan timer, etc.).
Can these already be executed out of Hubitat?

Thanks!

Internal error setting Nest E thermostat fan mode

This error is not impacting behavior. It occurs on all three of my Nest E thermostats every time the rule runs. If I'm reading the log right, an invalid fan mode is being sent -- either in addition to or instead of the fan mode my rule sends. An example of the error:

app:74 2022-03-28 01:35:58.020 pm debug { "eventId": "91a69b70-a79c-497d-9709-7e216f17c195", "timestamp": "2022-03-28T18:35:55.729906Z", "resourceUpdate": { "name": "enterprises/9eded18e-cb87-47f4-8dfc-ac82195b04ac/devices/AVPHwEuMdIH5b7bDtgulsnMwDW0-eVmcOHa8mzLSC5ZKDOfYuaXQp-Kkg2o-xmGynKhDwu6I7pc25eHk-dgJsvtMo5YhMg", "traits": { "sdm.devices.traits.Fan": { "timerMode": "OFF" } } }, "userId": "AVPHwEv0wgfaKUEPQ1h1JbnY8-S266PR0ImLc4EL7AT8", "resourceGroup": ["enterprises/9eded18e-cb87-47f4-8dfc-ac82195b04ac/devices/AVPHwEuMdIH5b7bDtgulsnMwDW0-eVmcOHa8mzLSC5ZKDOfYuaXQp-Kkg2o-xmGynKhDwu6I7pc25eHk-dgJsvtMo5YhMg"]}
app:74 2022-03-28 01:35:58.013 pm debug Event received from Google pub/sub
app:74 2022-03-28 01:35:57.094 pm debug { "eventId": "1e85cf39-dc7e-4322-8a1d-d8015754dad2", "timestamp": "2022-03-28T18:35:55.712291Z", "resourceUpdate": { "name": "enterprises/9eded18e-cb87-47f4-8dfc-ac82195b04ac/devices/AVPHwEuMdIH5b7bDtgulsnMwDW0-eVmcOHa8mzLSC5ZKDOfYuaXQp-Kkg2o-xmGynKhDwu6I7pc25eHk-dgJsvtMo5YhMg", "traits": { "sdm.devices.traits.ThermostatMode": { "mode": "HEAT", "availableModes": ["HEAT", "COOL", "HEATCOOL", "OFF"] }, "sdm.devices.traits.ThermostatEco": { "availableModes": ["OFF", "MANUAL_ECO"], "mode": "OFF", "heatCelsius": 17.5, "coolCelsius": 24.5 }, "sdm.devices.traits.ThermostatTemperatureSetpoint": { "heatCelsius": 22.777779 } } }, "userId": "AVPHwEv0wgfaKUEPQ1h1JbnY8-S266PR0ImLc4EL7AT8", "resourceGroup": ["enterprises/9eded18e-cb87-47f4-8dfc-ac82195b04ac/devices/AVPHwEuMdIH5b7bDtgulsnMwDW0-eVmcOHa8mzLSC5ZKDOfYuaXQp-Kkg2o-xmGynKhDwu6I7pc25eHk-dgJsvtMo5YhMg"]}
app:74 2022-03-28 01:35:57.086 pm debug Event received from Google pub/sub
app:74 2022-03-28 01:35:56.444 pm error executeCommand sdm.devices.commands.ThermostatMode.SetMode response code: 500, body: { "error": { "code": 500, "message": "Internal error encountered.", "status": "INTERNAL" }}
app:74 2022-03-28 01:35:55.812 pm info Sending sdm.devices.commands.Fan.SetTimer to nest den with params: [timerMode:OFF]
app:74 2022-03-28 01:35:55.795 pm info Sending sdm.devices.commands.ThermostatTemperatureSetpoint.SetHeat to nest den with params: [heatCelsius:22.7777777778]
app:74 2022-03-28 01:35:55.776 pm info Sending sdm.devices.commands.ThermostatMode.SetMode to nest den with params: [mode:HEAT]

Commands are sent to the Nest E via this Hubitat RM rule:
image

mark failure on event subscription and retry later, if needed

On occasion during the initial authorization, the event subscription fails. Sometimes this appears to be a transient issue, which can be fixed simply by retrying. A debug button already exists for this, but UX would be enhanced by marking this failure and retrying automatically.

Outdoor Temperature

Not sure if it's possible, but it would be nice if we could also get the Outdoor Temp that Nest reports. Being able to use this to automate eco mode in Rule Machine would be extremely nice.

Authorization Error

When authorization for the app is happening after I have checked what I want to allow google nest permission’s. I get an error saying

access blocked:authorization error

This app is not yet configured to make OAuth requests. To do that, set up the app’s OAuth consent screen in the Google Cloud Console https://console.developers.google.com/apis/credentials/consent?project=${your_project_number}

If you are a developer of this app, see error details.

Error 403: restricted_client

If I click on see details-

Error 403: restricted_client
Request details: access_type=offline login_hint=[email protected] response_type=code redirect_uri=https://cloud.hubitat.com/oauth/stateredirect state=adddf626-a106-4333-9d84-6882797cc2c7/apps/20/handleAuth?access_token=bbd0abfe-dc9c-46b5-8dd8-e46a81a3ef8b prompt=consent client_id=320488993527-8r15mpsmv3s47lm7v7ovqcmlevin5vub.apps.googleusercontent.com scope=https://www.googleapis.com/auth/sdm.service https://www.googleapis.com/auth/pubsub

Authorization Link

i've tried this 3 times and for the life of me, I cannot figure out what I'm missing. The Authorization link never shows up and the log shows the same thing over and over.

app:18 2024-01-29 03:29:36.704 PM info Google SDM API updating
app:18 2024-01-29 03:29:08.084 PM info Google SDM API updating
app:18 2024-01-29 03:19:10.520 PM info Google SDM API updating
app:18 2024-01-29 03:17:19.509 PM debug Access Token: null
app:18 2024-01-29 03:17:13.172 PM error Login refresh failed -- status code: 400, reason phrase: Bad Request: error:invalid_request, error_description:Missing required parameter: refresh_token
app:18 2024-01-29 03:17:12.952 PM info Refreshing access_token from Google

timeCompare has a Java exception in toDateTime so thermostats are always reporting time out of date

In post events, this line can have the toDateTime removed, and it now functions fine: timeCompare = (dataJson.timestamp).compareTo(lastEvent)

def postEvents() {
logDebug('event received')
def dataString = new String(request.JSON?.message.data.decodeBase64())
logDebug(dataString)
def dataJson = new JsonSlurper().parseText(dataString)
def deviceId = dataJson.resourceUpdate.name.tokenize('/')[-1]
def device = getChildDevice(deviceId)
if (device != null) {
def lastEvent = device.currentValue('lastEventTime')
def timeCompare
try {
timeCompare = (dataJson.timestamp).compareTo(lastEvent)
} catch (java.text.ParseException ignored) {
//should only fail on first event -- e.g. lastEvent == null
}
if ( timeCompare > 0 || lastEvent == null ) {
sendEvent(device, [name: 'lastEventTime', value: dataJson.timestamp])
processTraits(device, dataJson.resourceUpdate)
} else {
log.warn("Received event out of order, refreshing device ${device}")
getDeviceData(device)
}
}
}

Handle linked event threads for different event types

Reported from Hubitat forum

The presence/person event state never cleared, because the ENDED event from Google only referenced motion.

2022-07-06 00:22:29	Mud Room	{ "eventId": "f60beea0-adb4-4c23-8d01-8a81d48c1d0d", "timestamp": "2022-07-06T04:22:06.872Z", "resourceUpdate": { "name": "enterprises/9883dbf4-bc06-451a-ba28-874afe641383/devices/AVPHwEs227k4g-UQCUgIEbxaHnT0tdDYEJEC3T-ms6qsLLU65bkfBz_yjw7OVQW7dZMs_aktxnJzBaHDSZ_9WCp89p078A", "events": { "sdm.devices.events.CameraMotion.Motion": { "eventSessionId": "1638056321", "eventId": "401079826", "zones": [""] } } }, "userId": "AVPHwEukOR65xe1nGj1X2_J96lpb_qu2gH1vHEP4ictp", "eventThreadId": "dc54477c-cfda-4760-9ce6-606c43f62a9d", "resourceGroup": ["enterprises/9883dbf4-bc06-451a-ba28-874afe641383/devices/AVPHwEs227k4g-UQCUgIEbxaHnT0tdDYEJEC3T-ms6qsLLU65bkfBz_yjw7OVQW7dZMs_aktxnJzBaHDSZ_9WCp89p078A"], "eventThreadState": "ENDED"}
2022-07-06 00:22:09	Mud Room	{ "eventId": "f60beea0-adb4-4c23-8d01-8a81d48c1d0d", "timestamp": "2022-07-06T04:22:06.872Z", "resourceUpdate": { "name": "enterprises/9883dbf4-bc06-451a-ba28-874afe641383/devices/AVPHwEs227k4g-UQCUgIEbxaHnT0tdDYEJEC3T-ms6qsLLU65bkfBz_yjw7OVQW7dZMs_aktxnJzBaHDSZ_9WCp89p078A", "events": { "sdm.devices.events.CameraMotion.Motion": { "eventSessionId": "1638056321", "eventId": "401079826", "zones": [""] } } }, "userId": "AVPHwEukOR65xe1nGj1X2_J96lpb_qu2gH1vHEP4ictp", "eventThreadId": "dc54477c-cfda-4760-9ce6-606c43f62a9d", "resourceGroup": ["enterprises/9883dbf4-bc06-451a-ba28-874afe641383/devices/AVPHwEs227k4g-UQCUgIEbxaHnT0tdDYEJEC3T-ms6qsLLU65bkfBz_yjw7OVQW7dZMs_aktxnJzBaHDSZ_9WCp89p078A"], "eventThreadState": "STARTED"}
2022-07-06 00:22:08	Mud Room	{ "eventId": "3a38fed2-0a85-49b5-99f1-179151c9b6fb", "timestamp": "2022-07-06T04:22:06.872Z", "resourceUpdate": { "name": "enterprises/9883dbf4-bc06-451a-ba28-874afe641383/devices/AVPHwEs227k4g-UQCUgIEbxaHnT0tdDYEJEC3T-ms6qsLLU65bkfBz_yjw7OVQW7dZMs_aktxnJzBaHDSZ_9WCp89p078A", "events": { "sdm.devices.events.CameraPerson.Person": { "eventSessionId": "1638056321", "eventId": "991316265", "zones": [""] } } }, "userId": "AVPHwEukOR65xe1nGj1X2_J96lpb_qu2gH1vHEP4ictp", "eventThreadId": "dc54477c-cfda-4760-9ce6-606c43f62a9d", "resourceGroup": ["enterprises/9883dbf4-bc06-451a-ba28-874afe641383/devices/AVPHwEs227k4g-UQCUgIEbxaHnT0tdDYEJEC3T-ms6qsLLU65bkfBz_yjw7OVQW7dZMs_aktxnJzBaHDSZ_9WCp89p078A"], "eventThreadState": "UPDATED"}

Must correlate by eventThreadId in order to guarantee that the state is properly cleared.

Add support for camera zones

It would be nice if there was support for zones in each camera.

I thought there could be two ways to surface this -- either as an attribute on each camera, or implement a separate virtual camera device per zone. The latter is much easier to integrate into other workflows.

For example, I have a camera on the entire front yard and street. It picks up people as presence. I only want to trigger a motion event for people walking in the front yard, rather than the whole street.

For this I implemented a small change to the main app api so that it creates a second camera named "-zone 1" with a companion device-id with -zone1 appended.

From there, all hubitat rules etc can be applied and triggered on only zone1, so that you can do things like turn on lights etc.

Discovered devices are listed below:

[Entryway](https://10.0.2.40/device/edit/3066)
[Entryway-Zone1](https://10.0.2.40/device/edit/4033)
[Street](https://10.0.2.40/device/edit/3070)
[Street-Zone1](https://10.0.2.40/device/edit/4041)
[Max Room](https://10.0.2.40/device/edit/3071)
[Max Room-Zone1](https://10.0.2.40/device/edit/4043)
[Street High camera](https://10.0.2.40/device/edit/3140)
[Street High camera - Zone1](https://10.0.2.40/device/edit/4035)
[Driveway HD](https://10.0.2.40/device/edit/3069)
[Driveway HD-Zone1](https://10.0.2.40/device/edit/4039)

```

Update Documentation for GCP setup

GCP Enabling of OAuth requires to pick the type of application and to alleviate these setup steps confusions, it is best to specify that user must pick 'Web Server' as option before they enter the Authorized redirect URIs

Another NPE

When I turn on event subscriptions, after a minute or so my logs start getting spammed with this. These messages repeat every second or so until I turn off subscription again.

app:4832020-10-08 06:55:54.721 errorjava.lang.NullPointerException: null (postEvents)
app:4832020-10-08 06:55:54.715 debug{
"eventId": "c119376b-a5b6-4a10-b782-23853f608ffc",
"timestamp": "2020-10-08T05:55:25.693Z",
"resourceUpdate": {
"name": "enterprises/94b4ad03-484f-44bd-99a3-6753dd42e6d7/devices/AVPHwEu8XSnGXYxAuOBVDOnonXUSWMJt38mKr0UanQMlFRPl4KfDhk1L6ekcXjd4WHSpVdP_dArucIvemC6jmSWjnJHqKw",
"events": {
"sdm.devices.events.CameraMotion.Motion": {
"eventSessionId": "AVPHwEs6ZCsb5cRDfbhTV6RNA6kwXgIdDIJ9VokQXKP6Fk8z10YX3zX7fRK95BZGmSl5s7JRMl7vX4Sr6dfA9Or_daYjGg",
"eventId": "CiQA2vuxr_LPPBrxKT7FjS3R5ai_0-50liEZRdxIT15hkHGyd_sSwAEATD4XpwaE_g2SAfT4EQBb1tQ-0QXg8d2Ee3uEB6kMcI4LayOnHC1QsWxi3cf5gbNl6S5V1qLGLiUQ5HOg61f7jYmgsRKPxNDrvnQA0zeKlTNIchrnGriyZCoobUipo9Omrrn2vUBFBuB8xoqZExlV7XpH_OUPHNu5yYTfX7cd7Er-Vz5NaBzddY07ZCIEsbPtg-Rovd-Yt0B9TSSOWX7wG-Tn4yH7s-IOb-9YzXUOUVQYR1e8kEl9z6u-M77HJzU"
}
}
},
"userId": "AVPHwEvAiumrZc4lv01fEczozd2gPCwcU_A3XKqjaNw4"
}
app:4832020-10-08 06:55:54.707 debugevent received

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.