Google Nest Device Access Console now available

Thanks for the reply @dschoepel!
I am aware of the traits. But I noticed there was no activity zone trait. So I’m wondering if the person/motion detection sends a notification for any motion or if it sends it when motion is detected in an activity zone. Thx.

Did a little more digging and looking at the trait info I can’t find any indication that a zone is identified. For example what is returned (message in pubsub subscription) from the motion event below only includes the event CameraMotion.Motion and associated event ID. Perhaps they have one for CameraMotion.Zone but I don’t see it called out in the documentation…

    {
      "eventId" : "0120ecc7-3b57-4eb4-9941-91609f189fb4",
      "timestamp" : "2019-01-01T00:00:01Z",
      "resourceUpdate" : {
          "name" : "enterprises/project-id/devices/device-id",
          "events" : {
          "sdm.devices.events.CameraMotion.Motion" : {
             "eventSessionId" : "CjY5Y3VKaTZwR3o4Y19YbTVfMF...",
             "eventId" : "FWWVQVUdGNUlTU2V4MGV2aTNXV...",
            }
          }
        },
        "userId": "AVPHwEuBfnPOnTqzVFT4IONX2Qqhu9EJ4ubO-bNnQ-yi"
     }

I have 5 cameras connected to the API but so far I cant seem to get them to send messages to the pub/sub subscription. Still scratching my head on what I missed in setting all this up…

Hi All and happy new year. Hope you all had a great break. Many I please ask if there is an update on the Windows add-on?

Many thanks.

Yes, my project is in sandbox and probably will remain that way. i.e. No plan to move to a commercial project. You can instead create your own project and own all messages in/out of the project. By the way, you can leverage the pubsub configuration to avoid the API calls per minute. This would be recommended for any project that has many Nest devices. Hope that helps.

Correct. There are no zones in the JSON messaging from Google… The “Doorbell” class does work for displays and cameras as well. In the case of notifications, it will deliver notifications for person detected motion, doorbell ring (For doorbells), motion detection and sound detection. However, no zoning. That is, if you had a zone detect motion, it would trigger the motion and reference the link to the video but would not tell you what zone it is in from the JSON… You can look in the Google project pubsub and verify the JSON for the information… Thanks for trying to help others in the channel. Greatly appreciate it…

The doorbell class should be working with the cameras… Hit me up on a PM and we can review… I have 2 cameras working currently but want to verify there isn’t a coherency issue when you scale up the number of cameras… Example: Google’s API requires the message to be reviewed within 30s. If it isn’t, it discards the ability to retrieve video/image related data. If a coherency issue applies where the pubsub reader isn’t getting to the message in time, it may point to a need to optimize the pubsub reading capability… :slight_smile:

Hi all,

Firstly thank you all very much for the developing and testing contributions for SDM API!

I’ve been keeping a close eye on this thread as I’ve been wanting to utilize it too. Now for the questions :smiley: Is there a roadmap for this binding when it will officially be available for OH3 and its associated documentation? The reason why I ask, for me its not very clear the process that is required to be completed to fully integrate the API and OH3. Furthermore, not sure from this thread what is still applicable or not…

Thanks very much all and apologies if there are any stupid questions above!

1 Like

Hello! The SDM support will be available in openHAB when this pull request is merged. I’m working on making the code ready for review. Once the channel names/types are stable (and still work after my changes) I’ll publish an updated JAR. :slight_smile: I haven’t published any updated JARs, as it can be frustrating and waste a lot of everyone’s time when names and types keep changing.

4 Likes

Just to remind you if possible to fix “internet outage” issue before you publish the jar. Of course if you’ve not already done it

Thankyou again for your precious job

I will try to simulate Internet outages by restarting my router a few times. I remember the Nest Binding WWN code also initially had some difficulties with recovering from that. :smiley: Do you use only the periodic refresh polling or do you also use a Pub/Sub subscription?

That is amazing thank you so much for the response!

I look forward to the official release, thank you!

I’m using Pub/Sub, you could try also with oh restart, it won’t work until you remove thermostat thing from paper ui and add it back. Same behaviour as internet outage. OH 2.5.x here

I’ve got the same error:

openhab> config:list "(service.pid=org.openhab.nestdeviceaccess)"
----------------------------------------------------------------
Pid:            org.openhab.nestdeviceaccess
BundleLocation: null
Properties:
   clientId = xxxx
   clientSecret = xxxx
   felix.fileinstall.filename = file:/openhab/userdata/etc/org.openhab.nestdeviceaccess.cfg
   projectId = xxxx
   refreshToken = xxxx
   service.pid = org.openhab.nestdeviceaccess

Stacktrace:

2021-02-07 22:19:04.733 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while calling thing handler factory 'org.openhab.binding.nestdeviceaccess.internal.nestdeviceaccessHandlerFactory@3d7b5314': null
java.lang.NullPointerException: null
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:878) ~[?:?]
        at com.google.api.client.util.Preconditions.checkNotNull(Preconditions.java:125) ~[?:?]
        at com.google.api.client.auth.oauth2.RefreshTokenRequest.setRefreshToken(RefreshTokenRequest.java:142) ~[?:?]
        at com.google.api.client.googleapis.auth.oauth2.GoogleRefreshTokenRequest.setRefreshToken(GoogleRefreshTokenRequest.java:120) ~[?:?]
        at com.google.api.client.googleapis.auth.oauth2.GoogleRefreshTokenRequest.setRefreshToken(GoogleRefreshTokenRequest.java:75) ~[?:?]
        at com.google.api.client.auth.oauth2.RefreshTokenRequest.<init>(RefreshTokenRequest.java:95) ~[?:?]
        at com.google.api.client.googleapis.auth.oauth2.GoogleRefreshTokenRequest.<init>(GoogleRefreshTokenRequest.java:86) ~[?:?]
        at org.openhab.binding.nestdeviceaccess.internal.nesthelper.NestUtility.refreshAccessToken(NestUtility.java:197) ~[?:?]
        at org.openhab.binding.nestdeviceaccess.internal.nesthelper.NestUtility.<init>(NestUtility.java:71) ~[?:?]
        at org.openhab.binding.nestdeviceaccess.internal.thermostat.NestThermostatHandler.<init>(NestThermostatHandler.java:67) ~[?:?]
        at org.openhab.binding.nestdeviceaccess.internal.nestdeviceaccessHandlerFactory.createHandler(nestdeviceaccessHandlerFactory.java:79) ~[?:?]

Have I missed something here?

After a good long while and many trips through this thread, I was able to get the binding working in my OH setup (2.5.12 via the official Docker image running on Debian host). Is there a way to add Things (thermostats) and Items through the text config files, or are we limited to adding them through PaperUI? The documentation doesn’t seem to give any options at least for adding the Things. I tried creating a nestdeviceaccess:nest-device-thermostat Thing using the deviceId was grabbed from PaperUI plus the refreshToken, projectId, clientId, and clientSecret from the config file, but that didn’t work (“UNINITIALIZED - HANDLER_REGISTERING_ERROR”).

Update: I seem to be able to add Items in the config files, but adding Things would be great as well. I’m happy to update the documentation if someone points me in the right direction to getting it working.

OH seems to be receiving information from Nest just fine, but posting information is spotty. Posting HVAC mode or Eco mode seems to work, but posting temperature setpoints does not. I’ve tried posting both min temp setting and target temp, and neither seem to actually make it through to the thermostat (the OH value just resets to the thermostat value on the next update). Is this a known bug or am I doing something wrong?

I have not had a chance to try to set up PubSub yet, if that has anything to do with it.

Replying to myself again to give an update. I think I got pub/sub set up. I went through the instructions here Subscribe to Events  |  Device Access  |  Google Developers . I created my own subscriptionId for use in the cfg file in one of the steps of those instructions. I took the pubsubProjectId from the Project ID field for my project on the Google Cloud Platform dashboard (https://console.cloud.google.com/home/dashboard). And I downloaded the json file for my OAuth credentials (https://console.developers.google.com/apis/credentials) to a folder accessible to my docker container and added the file path to the serviceAccountPath in my cfg file. I am getting no errors, but I really don’t know how I would tell if the binding is using pub/sub or whatever the non-pub/sub alternative is. (Again, I only have thermostats, so my understanding is that pub/sub is not strictly necessary.)

Anyway, I’m having the same problem as the previous post where I’m getting good two-way connection between my thermostats and my OH installation for Eco mode and HVAC mode (i.e., I can control those modes from either OH or the thermostat and they will update in both places), but I still am only getting one-way connection on the temperatures (i.e., I can update the temperatures on the thermostat and they will be updated on OH, but not the other way around). Not sure what I’m doing.

Good questions so I took a look at the documentation. Based on the excerpt below from Nest Device Access - Subscribe to Events:

For example, if the ambient temperature near your Google Nest Thermostat changes,
an event for the Temperature trait will automatically be sent with a new 
ambientTemperatureCelsius value.

To manually generate one, either:

Physically change the state of your device, such as changing the mode of your Nest
Thermostat.
 
Trigger an event, such as motion, person, or sound on a Google Nest Cam.
Execute a device command using the SDM API.

My interpretation is that the subscription does publish events associated with nest devices - for both thermostats (e.g. ambient temperature changes) and cameras (e.g. sound, motion, and people being detected). I am definitely seeing messages being queued from my cameras, but have not seen them from my thermostats though I have not been looking for them.

Also, reading through some of the traits around thermostats there are a lot of “notes” highlighting the fact that when the thermostat is in ECO mode, changing certain settings will not be accepted. This may go for publishing events as well. To be sure changes are accepted from OH, you will need to make sure they are valid for whichever mode your thermostat is in. Not sure that logic can be included in the binding or if it should happen outside of it…

You can view the messages that are in the queue on the subscription on the google site where you set up your subscription. This link should get you to that area: Google Cloud - PubSub Topic List.

@BHigg (primary developer) is probably the best person to comment on this binding, my experience is that there are still some funky things going on that may need some troubleshooting to resolve - especially when it comes to the cameras.

Hope that helps…

Hi @kovacsi2899, did you ever find a solution to this issue? I am having the same problem. I was able to follow the instructions here https://developers.google.com/nest/device-access/authorize#get_an_access_token up to the step titled “Get an access token”… but when I attempt to use the generated curl expression with my oauth2-client-id, oauth2-client-secret and authorization-code, I get the same error in Windows PowerShell as you saw (I have also attempted at the Windows 10 command prompt and in the Google Cloud shell console, with different errors there):

Invoke-WebRequest : A parameter cannot be found that matches parameter name 'L'.
At line:1 char:6
+ curl -L -X POST 'https://www.googleapis.com/oauth2/v4/token?
+      ~~
+ CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

I’m a little in above my head here but hoping someone might be able to make a suggestion as to what I am missing?

Not much of an expert on using curl on windows and especially Powershell. So I can only suggest what you might try. And good if you included the command your executing, hard to tell based on the error message if you have a properly formatted request.

Windows Powershell converts the curl command to Invoke-Webrequest - by knowing that you would need to understand how to specify the parameters using the Invoke-Webrequest (typically they are loaded into variables and then variable are used on the command). The message your getting is telling you that it does not know what the -L means and what to do with it. Most likely you need to use the Invoke-Restmethod since your trying to do a POST, so you may want to research that approach if you really need to do this in Powershell.

The basic format for Invoke-Restmethod:
    
Invoke-Restmethod -Method Post -Uri "enter your URL here between double quotes"

I would first try this in a windows command prompt rather than Powershell. If you do that, you will need to enclose the URI in double quotes (") rather than single quotes (') because this curl URL is using HTTPS. If that works, great, but if not then, I would try to find a linux based system to do the curl command from…

You can also try to google a forum searching for convert curl to Invoke-Restmethod, or convert curl to Invoke-Webrequest. Try asking the forum how to convert the curl command and see if they can give you the answer that way.

One other thought, if you don’t mind installing some software on your windows machine, the git bash client will give you a linux environment that you can run the curl command from and it works without issues, just tried it on my Windows 10 PC…

Instructions here: Git-Guides: Install Git

Good luck, hope this helps…

Thanks so much, I will give this stuff a try. You are right - I made it hard on you by not including the command which is as follows (as specified in the instructions here https://developers.google.com/nest/device-access/authorize#get_an_access_token):

curl -L -X POST 'https://www.googleapis.com/oauth2/v4/token?
client_id=oauth2-client-id&
client_secret=oauth2-client-secret&
code=authorization-code&
grant_type=authorization_code&
redirect_uri=https://www.google.com'

I don’t need to do this in powershell, I am just in over my head and don’t know any better :slight_smile:
I will give this a try at the command prompt and at the console on my RaspberryPi. Thanks again for the help :+1:

1 Like