UniFi Protect

Is anyone aware of any work on UniFi Protect? I know there is some UniFi NVR work, but the Protect line is newish, so not yet supported.

2 Likes

@kevinelliott the odd thing is that @balloob is working with UniFi now. I figured that he would have this integrated as soon as UniFi Protect was out in the wild.

Definitely want this added as well! Just switched all my cameras to protect and now canā€™t have them in hass.

1 Like

UniFi Protect isnā€™t fully feature complete with the Unifi Video line yet, theyā€™ve said that they will continue to iterate on it attempting to reach parity. That also means it doesnā€™t have an API like the Unifi Video does, which is kinda the issue at the moment.

However you can set it up in HA per camera using the RTSP stream. Not as simple to configure but does work.

Iā€™m keeping an eye on the protect for now, Iā€™ll make the jump once they add a few more features and an API.

1 Like

I jumped the gun and moved over to Unifi Protect, currently integrating with ffmpeg and RTSP streams which is not ideal. I might open a Third Party Integration post to discuss actually implementing a component. Iā€™ve worked up some notes on it and some preliminary info but would probably need some assistance to get it really going.

The cameras basically work in the same manor that they did with the Unifi NVR but how the component authenticates and pulls a list of cameras is what changed. So I believe that a good portion of the Unifi NVR component can be re-used, just need to re-tool how it gets the camera list or figure out how to just pass back a list of cameras manually to start with.

Iā€™d be happy to help!

By the way, we can also enable the ā€œAnonymous Snapshotā€ feature on the Unifi G3 cameras which let us hit the cameras directly for a single image. Regularly refreshing this would work well. No need to ffmpeg convert the RTSP streams if all we want is a single snapshot at a time.

Hitting this directly:

I believe the existing unifi NVR component is just grabbing snapshots.

I linked to a new thread I started in 3rd party integrations, but laid out what Iā€™ve found so far on the protect end, not much but a start. I believe itā€™s only the NVR part of the existing component that needs to be re-worked, in fact you can still use that component in conjunction with protect as all it does it log into the Unifi NVR to get a list of the cameras and logins, then connects direct. So a lightweight docker container running the Unifi NVR alongside protect is my current stop gap. Iā€™d like to for and re-write that front piece to the current component and make it a native protect component.

Nice, Iā€™m with you. What do you want the rewrite to do differently?

What I mean be re-write is creating from or modifying the existing NVR component as a foundation. I havenā€™t had a lot of time to work further on how to login to Protect and get a list of the cameras.

Get Camera Password:

root@ck-plus:~# psql -U unifi-protect
psql (9.6.10)
Type "help" for help.

unifi-protect=> SELECT "devicePassword" FROM nvrs;
 devicePassword

Undocumented API:

Get basic information about the system (e.g. firmware version):

GET /api/ump/info

To authenticate, send username and password (json encoded) to

POST /api/auth

You will get a JWT Bearer style authentication header back, that you need to include in later requests (in addition to a number of other items about the user.

Next you need to request an access key. this key is required to get images later:

POST /api/auth/access-key

(no data, just the Authorization header from above)

Get a list of events:

GET /api/events?end=[unix timestamp]&start=[unix timestamp] &type=motion

Example:
[{"type":"motion","start":1547086305207,"end":1547086314307,"camera":"5c30d50f03008f03e7000799","score":39,"thumbnail":"5c36a9e803611d03e700046c","heatmap":"5c36a9e9006a1d03e700046d","id":"5c36a9e3010c1d03e7000469"}....]

Retrieve a thumbnail image for the event use the ā€œthumbnailā€ parameter and request:

GET /api/thumbnails/[hex thumbnail id]?accessKey=[key returned from 'access-key' request above]

Reboot a camera:

POST /api/camera/[hex cameraid]/reboot

Am about to buy a Unifi protect, has there been any developments in this area?

Any idea if we can remotely issue a SSH command to turn on motion alerts? I currently use SecuritySpy and can do this via HA at the moment.

1 Like

Iā€™m facing the same thing. So far Iā€™m not able to add the cameras when using Protect, only through my old NVR.
Would be nice to have the possibility to add motion alerts from the cameras directly into HA!

I donā€™t need the ability to add motion alerts from within HA, just want to turn on and off the motion alerting in Unifi Protect from a script running on HA.

Anyone know if this is possible/

1 Like

I would also love to have support for unifi protect

2 Likes

Add me to the list, Iā€™d love the new Unifi Protects to be visible ā€˜ controllable via Home Assistantā€¦

Iā€™m in the process of doing this, just a bit differently.

I have motion sensors along side my cameras anyway, so my logic is: ā€œif home unoccupied and motion detected, send a telegram message with an image from the camera attachedā€

Next step is to throw the image up to AWS Rekonition first, and only alert/send if the image contains a person. Based loosely on this implementation - Object detection with Amazon Rekognition

Looking out for more integration with Protect in the future.

Quick and dirty idea in the meantime. Protect provides a web interface, could you just iFrame it into Lovelace? Never used iFrames so no idea how auth works or anything, but if you wanted to get their nice timelapse feature into HA that feels like maybe the easiest way to do it?

Just a thought.

1 Like

Why use iFrames when you can use the Browser Mod Integration as a part of an Action:

{
  "card": {
    "camera_view": "live",
    "entity": "camera.front_door",
    "type": "picture-entity"
  },
  "command": "popup",
  "deviceID": [
    "desktop_chrome",
  ],
  "large": "true",
  "title": "Front Door Camera"
}

image

I am getting screen pops on all devices, I just want to get access to the motion sensors in the cameras!!

UNIFI PROTECT IS AVAILABLE IN HACS!! Just happened to be looking at new integrations in HACS. Iā€™ve installed and done all the configs. Everything is working great. Camera platform, Binary Sensors for motion and Sensor of recording state. https://github.com/briis/unifiprotect

1 Like