iMicknl / ha-nest-protect

Nest Protect integration for Home Assistant. This will allow you to integrate your smoke, heat, co and occupancy status real-time in HA.
MIT License
331 stars 60 forks source link

Add Security Devices #61

Open ErikSGross opened 2 years ago

ErikSGross commented 2 years ago

Description

When running the version of nest-protect that enables all buckets (https://github.com/iMicknl/ha-nest-protect/archive/refs/heads/enhancement/add_more_info.zip), there are security devices in my account, which I suspect are the Yale x Nest door locks.

In the diagnostics output, the bucket names look like this:

        {
          "object_key": "buckets.xxxxxxx",
          "object_revision": -xxxx,
          "object_timestamp": xxxxxxxxxxxxxxx,
          "value": {
            "buckets": [
              "wwn_security.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            ]
          }
        },

I don't see any entries in the object_key section for these devices, but maybe that's because they need to be enabled in the integration?

Device (optional)

No response

Additional information

No response

iMicknl commented 2 years ago

I recall that Yale x Nest locks are not supported in the API I use, but will require a grpc/protobuf endpoint.

If I request the wwn_security bucket through the current REST endpoint, I receive the following error:

{'error': 'input_error', 'error_description': 'Non-allowed known bucket types: Set(wwn_security)', 'instance_id': 'd21fd146-20c3-45bd-89fc-dc1e0fd27474', 'errors': [{'label': '', 'format': 'Non-allowed known bucket types: Set(wwn_security)', 'params': []}]}

So it seems that this one will be harder to implement, however I will keep this issue open to track progress.

ErikSGross commented 2 years ago

Not sure if this in the same category as the door locks, but I can also see door (open/closed) sensors via home.nest.com. I don't see a bucket for them in the current diagnostic output, though. Any thoughts on how to figure out whether they can be accessed via the API you're using for the protect and temp sensors?

iMicknl commented 2 years ago

You could probably check this via https://support.deskpro.com/en/kb/articles/how-to-inspect-ajax-requests-with-chrome-tools.

ErikSGross commented 2 years ago

I tried a few different things with the Nest Home Web App and it seems they've limited the security-related capabilities of the web app. I found some details here: https://support.google.com/googlenest/answer/9241220?hl=en&app=true&country=US&locale=en_US#zippy=%2Cnest-web-app-features

I can definitely see the state of the doors, door locks, and alarm from the web app, but I'm not seeing any way to change anything via the web app. I'm not sure where the app is getting the data on device status from, but even that would be useful in Home Assistant if the devices can't be controlled via this API.

The XHR subscribe entries show the object keys in the payload section, but there is no response information, so I'm not sure where to find how the door/lock/alarm status is coming from.

ErikSGross commented 2 years ago

I wanted to see what functiuonality homebridge currently exposes, so I spun up an instance and added the homebridge-nest plugin. I then could access and control all of:

The authentication method appears to be the same as what ha-nest-protect is using - namely log into home.nest.com with your Google account and get a refresh token.

So even though the google support docs mention a difference between the home.nest.com web app and the mobile apps (namely that security devices can't be controlled via home.nest.com), it appears that homebridge has figured out a way to make this happen. I can definitely both see the status of my door locks AND lock/unlock them. I'm not sure if that's because homebridge is emulating the iOS app or if they're doing something else.

iMicknl commented 2 years ago

They use the GRPC / protobuf API, however this works in another way and is hard to test and debug for me since I don't own any of these devices. When I have some more time in the future, I will perhaps give it another try, but for now this won't be implemented soon.