Custom Component: Unifi Protect

Could you post the json code you see, with the lastRing and ring type? I don’t have a doorbell, but if I could get the output from the api call, I might be able to write support for it.

1 Like

Hey @briis

Sure thing! I’ve included two outputs in this post: The first is the “ring” event in the events API. I’ve also kept a “motion” event in there, which is what the current integration is looking for:

    {
        "type": "motion",
        "start": 1588200292806,
        "end": 1588200321099,
        "camera": "abc123",
        "score": 91,
        "id": "cba321",
        "metadata": {
            "objectType": null,
            "objectCoords": null,
            "objectConfidence": null
        },
        "modelKey": "event",
        "partition": null,
        "thumbnail": "e-5eaa036a03793603870024dd",
        "heatmap": "e-5eaa036a03793603870024dd"
    },
    {
        "type": "ring",
        "start": 1588200312129,
        "end": 1588200313129,
        "camera": "abc123",
        "score": 0,
        "id": "cba321",
        "metadata": {
            "objectType": null,
            "objectCoords": null,
            "objectConfidence": null
        },
        "modelKey": "event",
        "partition": null,
        "thumbnail": "e-5eaa037800823603870024de",
        "heatmap": "e-5eaa037800823603870024de"
    },

And the second part which is the camera itself under the “bootstrap” API, which has the “lastRing” attribute:

{
    "authUserId": "1234",
    "accessKey": "12345",
    "cameras": [
        {
            "isDeleting": false,
            "mac": "123456",
            "host": "192.168.4.36",
            "connectionHost": "192.168.5.1",
            "type": "UVC G4 Doorbell",
            "name": "Front Door",
            "upSince": 1588263240711,
            "lastSeen": 1588594036383,
            "connectedSince": 1588535982213,
            "state": "CONNECTED",
            "hardwareRevision": "20",
            "firmwareVersion": "4.22.13",
            "firmwareBuild": "669f3ee.200417.800",
            "isUpdating": false,
            "isAdopting": false,
            "isManaged": true,
            "isProvisioned": true,
            "isRebooting": false,
            "isSshEnabled": false,
            "canManage": false,
            "isAttemptingToConnect": false,
            "isHidden": false,
            "lastMotion": 1588592518982,
            "micVolume": 100,
            "isMicEnabled": true,
            "isRecording": true,
            "isMotionDetected": false,
            "phyRate": 260,
            "hdrMode": true,
            "isProbingForWifi": false,
            "apMac": "1234564325643",
            "apRssi": 45,
            "elementInfo": "Hello",
            "chimeDuration": 300,
            "isDark": false,
            "lastRing": 1588548075682,
            "wiredConnectionState": {
                "phyRate": null
            },
 

Let me know if I can help at all! I know enough to be dangerous. Thank you!!

Hi @briis! Thank you and to the 2 contributors for your hard work on this UniFi Protect custom components!
I’m new to home automation and I’ve installed Hass.io on a RPi 2 weeks ago. I’ve installed UniFi Protect for HA using the manual installation procedure. It works very well with my two G3-Flex.
I’m running Home Assistant Core 0.108.9 and I didn’t upgraded to 0.109.3 yet.
Could you please confirm that I only need to replace me files in the custom_components/unifiprotect folder to upgrade to the new V0.2.0 version? If yes, I guess I will then be able to upgrade HA to 0.109, is that correct?
Sorry for my silly questions, again I’m discovering all this exciting world :slight_smile:

Hi @deliwyn
There are NO silly questions! And yes I can confirm that you just need to replace all the files in the unifprotect directory with the ones you download from the latest release, and then you just need to restart Home Assistant. (They also work on your current version).

I can recommend that you install HACS, this will make it much easier to install new custom addons and keep them upgraded.

3 Likes

Thanks @thegame3202. I am a bit busy this week, but let me see if I can make something you can test ASAP.
/B

1 Like

Thank you! Much appreciated :slight_smile:

Hi Bjarne,

I have 32 camera’s connected to two Cloud Key 2’s. I don’t know how to set this up with your component.

Can you help me out?

Thanks, Johan

Hi Johan,
Currently this Integration only supports one CloudKey+. But you could maybe try to make a new subdirectory in your custom_components directory and call that unifiprotect2. Copy all the files from the unifiprotect directory here. Then modify the following files in the unifiprotect2 directory:

  • manifest.json - change value of “domain” to unifiprotect2
  • __init__.py - change DOMAIN to unifiprotect2
  • switch.py- change DEPENDENCIES to unifiprotect2
  • binary_sensor.py- change DEPENDENCIES to unifiprotect2
  • sensor.py- change DEPENDENCIES to unifiprotect2
  • camera.py- change DEPENDENCIES to unifiprotect2

The add the same entries in your configuration.yamlas you did for unifiprotect just name the platform unifiprotect2

I am not sure if that will work, but it might be worth testing. Especially the Services that are created, might fail due to duplicate names.

Direct support for UnifiOS and the UDM Pro devices - Version 0.3.0

The Community strikes again. @Msv1 added support for UnifiOS. So now you can use this integration directly with both the CloudKey+ and the UDMP units.

If you were previously using the proxy developed by @silvenga, you can now skip this. Please remember to change the IP Address in your configuration.yaml file to point directly to your UDMP, and also specify the port (typically 443 for UDMP units and 7443 for CloudKey).

A BIG thank you to @Msv1 for fixing this.

It should be available in HACS within a short time.

Next Up:

  • Making a Config Flow, so this can be installed directly from the Integration Page in the UI
  • Trying to add support for the new Doorbell from Ubiquiti

/B

2 Likes

Hi Bjarne, that works exactly as one would expect.

I’m planning to copy it after every update and then run:

sudo sed -i 's/unifiprotect/unifiprotect2/g' manifest.json
sudo sed -i 's/unifiprotect/unifiprotect2/g' *.py

Thanks a lot,

Johan

Perfect. Thanks for the feedback - that might help others in your situation.

There seems not to be possible to create a local Protect user on the UDM Pro? Is it then the main login credentials that must be given in the config.yml? Can’t get it to work. Thx. :slight_smile:

Hopefully someone with a UDMP can answer this?

Seems like i had some errors in the cfg. Working now. It is the user/passwd to login the UDMP. :slight_smile:

Good to hear Klaus. I will update the REAME file to reflect this.

The best thing would still be to create a local user on the UDM Pro. On the UDM Pro it is not done within Protect but rather from the main UDM dashboard.


Click Users and add a new user. I have created a hass user as Limited Admin.
Make sure to set the Permissions of the new user so it has access to Protect

Hi @thegame3202 - I will look into this within the next days. Just one quick question: Is the doorbell added to HA as Camera when you install the Integration?
When I look in bootstrap, it should be added - without the specific doorbell things of course.

The event log, should then also detect motion. Does this work?
/B

Hey @briis

Yes it is - It’s just a “camera” entity it seems. The event API does get motion also, as well as the binary_sensor that gets created from the integration. Thank you!

Super - Then the json data makes sense and is very usefull.
Another question: What would you like to have extra for the doorbell?

  • A binary_sensor or event that get triggers when the doorbell is pushed?

What else would you like to happen or track?

1 Like

Hey @briis

Yeah - For automations to “flash lights when doorbell rang” or “Play sound on google hubs when rang” type things.

I think just that(binary_sensor) is helpful! Because by nature of HASS, we can see “last ring” through the sensor itself, so not sure if there’s a need to pull that attribute in.

Thank you sir! This is awesome!