Unifi Protect Integration

Unifi Protect is Ubiquiti Networks next generation Camera NVR.

The previous iteration, Unifi NVR, home assistant integration. I believe that some of that can be re-used to create a new native Unifi Protect component. Unfortunately Unifi Protect does not have an API yet, nor does it look like one will be made available anytime soon.

I’ve done some preliminary research and come across a few things.

The Camera itself seems to operate in the same manor that it did on Unifi NVR. So I believe the primary piece to re-work is how the component authenticates and pulls a list of cameras from the Protect NVR. Once that portion is complete I think that the camera portions can be used. The way the current component works for Unifi NVR is it pulls a list of cameras, connects, then does everything directly with the camera itself (my current understanding). You can check this by shutting down the Unifi NVR and the cameras are still integrated within HA and providing video streams (until restart).

Unifi Protect Notes:

Get Camera Password:

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

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

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


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


I’d be willing to start with a simple component that connects directly to the cameras, aka you need to pass that info as part of the component.

Another interesting find.

I spun up another Unifi-NVR docker, all the cameras show up as un-managed while protect was still running and actually doing the recordings (this is supported per Ubiquiti documentation). Provided the API key and camera password to HA. Camera feeds load just fine. So the basic integration with the camera is just fine with the current component, just needs to be tweaked a bit to integrate with either the NVR or pass camera IP and creds individually.

I really wish there was a component…

It’s still on my back burner of ideas, the trickiest part is trying to figure out how to scrape what cameras are in protect like the NVR component does. The rest of the component works in the same fashion.

For now I have it setup as a generic camera that works in the same manor as before, just have to manually configure them. I went this route especially because of new stream component.

The one thing I haven’t sorted, and didn’t spend much time on, is passing camera user and pass credentials so I just enabled anonymous snapshots for now. Log into each camera and enable that function and it works.

Enable RTSP under the protect interface and use that URL for the stream source if you want streaming, if not remove that section.

  - platform: generic
    name: Camera
    still_image_url: https://CAMERA_IP/snap.jpeg
    stream_source: rtsp://PROTECT_IP/RTSPURL
    verify_ssl: false
1 Like

Is there anything else you had to do to get the generic camera platform working? I have my flex working as an ffmpeg camera but when I try to configure as generic the stream won’t load in the front end and interestingly it also breaks my Ring and Nest cameras…

Same here, @geekoftheweek I have RSTP set up in protect and I have my camera set up like above but I am not getting any streaming. What am I missing? The “snap.jpeg” is solid but not the same quality…

It does break Ring, I noticed that as well. I haven’t had much time this weekend to look into it, but it seems to break something with FFMPEG. I haven’t found a fix just yet.

you might want to check my comment on the previous thread about the javascript autodetect, add ?latest to the end of your URL and test it:

1 Like

Make sure you enable anon snapshots as well, to make it load in the UI, you have to log into each camera to do so. I haven’t spent much time trying to figure out how to pass the auth creds back to it. No API on protect so it works different than how the NVR component is setup. The NVR component pulls the same exact snap.jpeg file so that works exactly the same once you get it to load.

You are also able to to configure the password in the GUI using this Guide

  1. Access the UniFi Cloud Key Gen2 Plus (UCK-G2-PLUS) via SSH. The SSH credentials will be the same as those used to access the Cloud Key’s management portal. By default, these credentials will be ubnt/ubnt.

  2. Once credentials have been accepted, update the system packages and install Nano with the following command:

    `apt-get update && apt-get install nano -y`
  3. The following command will open the configuration file for UniFi Protect using Nano and allow editing:

    `nano /usr/etc/unifi-protect/config.json`
  4. You should see text like this:

    { "ssl": {
    "crt": "/etc/ssl/private/cloudkey.crt",
    "key": "/etc/ssl/private/cloudkey.key"
    "mbToKeepFree": 32768

    Modify the file, adding a line at the end for “enableSsh”, to look like this:

     { "ssl": {
     "crt": "/etc/ssl/private/cloudkey.crt",
     "key": "/etc/ssl/private/cloudkey.key"
     "mbToKeepFree": 32768,
     "enableSsh": true
  5. Use Ctrl+O, followed by Ctrl+X to save the config.json file and exit Nano.

  6. Restart UniFi-Protect with one of these commands:

    service unifi-protect restart


    systemctl restart unifi-protect
  7. Login to Unifi Protect, Click the image on the dashboard

  8. In General you will now have an option for Device Password which you can specify.

  1. Login to the camera https://192.168.x.x/camera/config with the user credentials

    Username: ubnt
    Password: *Device_Password from GUI*

I believe that option is now exposed by default and wasn’t needed for my newer installs.

That’s right–no SSH is required at this point.

Does anyone have a way of enabling and disabling motion detection from within SSH?

1 Like

Thanks to the info in this thread, I was able to get stills and streams working with a Cloud Key Gen 2 Plus.

Thanks @geekoftheweek and @noodlemctwoodle!

1 Like

I understand replying to an existing thread is not ideal. However, I have everything working except the live stream. For some reason,I am not able to view it through HA.

This is my configuration.yaml configuration section:

  - platform: generic
    name: Front Porch
    stream_source: rtsp://
    verify_ssl: false

And this is my ui-lovelace.yaml file section:

  - title: Cameras

      - type: picture-entity
        entity: camera.front_porch
        name: Camera1 Still

      - type: picture-entity
        entity: camera.front_porch
        name: Front Porch Live Stream
        camera_view: live

      - type: picture-glance
        entities: []
        camera_image: camera.front_porch
    icon: 'mdi:camera'
    panel: false
    path: cameras

The stills are visible, the stream is not.
Anything obvious I might be missing? TIA

Opening new thread for my question… My apologies, should have done that from the start.

@kymnyth Did you find a solution to viewing the live steam?

I’m using the custom camera module which shows the live view from the unifi G3.



  - platform: generic
    name: Back Garden
    stream_source: rtsp://
    verify_ssl: false

Lovelace config:

url: /local/custom_ui/camera-card.js
  - type: module

entity: camera.back_garden
type: 'custom:camera-card'

@noodlemctwoodle No I have verified everything a number of times with no luck. I have not tried making custom cards and I’m not sure how to go about what you suggest.

Is there any new progress with trying to get some sort of Unifi Protect support?

It seems like without an API like the previous Unifi NVR that this might not be possible? I found this active thread that would be worth upvoting: https://community.ui.com/questions/Unifi-Protect-API-or-Motion-alerts-hit-API/b5c6cf44-651c-4751-98a8-c55d7ce9bd5f