Custom Component: Unifi Protect

Hello,
Thanks. Here are answers:

  • Unifi version: 2.1.11
  • CK Gen 2 as Protect Controller, version 1.18.1
  • HA version: core-2021.7.2
  • Error in the screenshot, during the add of the integration

image

  • Can connect to the NVR, with the same creds:

image

Thanks for your help.
Florent

Presumably you are following the installation instructions on the repo (specifically the UnifiOS variant as you are on v2.1.11 CK firmware)?
Have you checked the unifi controller logs for related issues?

Ok, found the issue. The configuration was not in the Integrations part, but was still present in .storage/core.config_entries
So i removed the entry in this file, and added it again, without error.
Thanks.
Florent

Looking to get some help with a new / re - installation.

I started my HA journey at the beginning of this year and was very happy to have found this integration for my Unifi Protect cameras. I recall setting it up very easily.

6 months later, my HA installation on my RPi SD card got corrupted and now Iā€™m trying to reinstall everything on a new card.

As of right now, the integration tells me that I am unable to ā€œconnectā€ to the UDMPro or the username/password is incorrect. I realize thatā€™s not much to go by, but are there specific things to check for other than the obvious (correct IP, username, password as those things would not be affected by the corrupt SD card)?

If it worked before your crash of the SD card, and not now, then something most have changed in the configuration of the PI. Did you change anything network related?

Try and add the debug option for unifiprotect, and look in the log if you cannot connect:

Add this to your configuration.yaml file:

logger:
  default: error
  logs:
    custom_components.unifiprotect: debug

Thanks for the tip!

What I found in the log was this

[custom_components.unifiprotect.config_flow] Unifi Protect reported authorization failure on request: https://10.0.3.1:443/api/auth/login received 401

That seems to suggest that my username/password is incorrect. I can try setting up a completely new user just to test, but that seems odd ā€¦

I was trying to think about what would have changed over the network and I couldnt come up with a specific change, but because I tinker a lot with it, maybe something VLAN related could be the culprit. I eventually just temporarily disabled all the firewall rules and tried connecting and that still didnā€™t work.

Your UDM / Unifi logs should confirm a failed login.

Do you have 2FA on?
Canā€™t speak for Unifi but 2FA can cause a lot of integrations can get hung up during first time setup.
If you do, try disabling 2FA, then get the integration setup, then reenable 2FA. Worth a shot at least.

So with a newly created account, it logs in perfectly fine. I wonder what happened to the previous login ā€¦

But I appreciate all the quick responses!

1 Like

This integration does not access the Internet, so it does not use the UI Account, and as such 2FA, should not be an issue.

1 Like

Glad it runs again.

Hi. Firstly, thank you to the developer(s) who have created and maintained this integration. As usual, at the point where I get fed up with the limitations in a commercial product I find that the OSS community has back filled most of the gaps.

I wanted to ask if thereā€™s any facility to expose which zone triggered a detection/motion event to be exposed as part of the event, please? I have a camera that covers a joint frontage between my house and my parentsā€™ house, and Iā€™d really like to be able to create a smart doorbell notification that notifies different people depending on whoā€™s in and where the motion was.

Thanks again

Unfortunately not possible based on previous feature requests like this one

I have a similar zoning issue with our driveway - we want notifications for the driveway but not for the pavement running alongside it - that Iā€™ve resolved by adding a deepstack image processing docker container into the mix. Custom component repo is available in HACs.

The added bonus for us is that Deepstack doesnā€™t detect our parking posts as people at around if itā€™s sunny (something to do with shadows I think).

This gives a flow something like this:
Protect Motion > HA automation > Deepstack Scan > Event driven HA automation > notification.

Using the protect integration cameras and JPG image format from Deepstack adds about 2 seconds in total to reaction time on a NUC5CPYH running multiple docker containers on Ubuntu 18.04.

Urgh. More half-assedry from Ubiquiti, by the look of it. OK, thanks - I rest assured that this is a common request and it will no doubt be added when/if the upstream blockers are removed.

I am not sure where to ask about issues so i hope it is ok for me to post this here.
i am also not sure what i should include.

My goal is to use g4 cameras and smart detection to trigger on and off some shelly switches.

The integration worked fine the first time but would stop working after that. i would have to restart HA to get it to work again. also sometimes it took very long to get a ā€œNone Identifiedā€ state even though in unifi protect it was not reporting any smart detections (5 minutes)

Edit: the motion is detected by home assistant in the logbook, the automation is just no triggered

FYI: i am aware that i switch on the shelly twice instead of turning it off and on that is because i am using it as a momentary switch (this is not the issue here this works fine)

Here is my yaml code

alias: Chimney lights BB
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.motion_backyard
    attribute: event_object
    to: person
    from: None Identified
condition: []
action:
  - type: turn_on
    device_id: ce20f2c19fe3c6c4f30824e52726ec28
    entity_id: switch.shelly1_8caab561bc36
    domain: switch
  - wait_for_trigger:
      - platform: state
        entity_id: binary_sensor.motion_backyard
        from: person
        to: None Identified
        attribute: event_object
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - type: turn_on
    device_id: ce20f2c19fe3c6c4f30824e52726ec28
    entity_id: switch.shelly1_8caab561bc36
    domain: switch
mode: restart
max: 10

Fixed it.
it seems the best way to do this is to use normal motion detection and to use the person detection as a condition. so the automation is always trigered when there is motion it than checks if its a person or not and if there is a person it will switch the lights on.

alias: Chimney lights BB
description: 'automation to switch on the lights when a Person walks by, the lights will only be trigered by a person and not by motion'
trigger:
  - platform: state
    entity_id: binary_sensor.motion_backyard
    to: 'on'
    from: 'off'
condition:
  - condition: state
    entity_id: binary_sensor.motion_backyard
    state: person
    attribute: event_object
action:
  - type: turn_on
    device_id: ce20f2c19fe3c6c4f30824e52726ec28
    entity_id: switch.shelly1_8caab561bc36
    domain: switch
  - wait_for_trigger:
      - platform: state
        entity_id: binary_sensor.motion_backyard
        to: 'off'
        from: 'on'
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - type: turn_on
    device_id: ce20f2c19fe3c6c4f30824e52726ec28
    entity_id: switch.shelly1_8caab561bc36
    domain: switch
mode: single

Might be slightly offtopic but I have a UniFi Switch where one port isnā€™t delivering POE, it just delivers data. Wondering if Home Assistant might have done something to it since there are functionality to turn off power to devices. I know it turns of the power to a specific device not a specific port, but just wanted to check if this could be related to HA in any way or if I should simply send it back?

This is not really UniFi Protect related. Search for the Ubiquiti UniFi Integration, as this might be the right place to ask regarding Switching Equipment.

1 Like

Ah, yeah, of course. I mixed them up in my stressed attempts at finding a solution. Thanks Bjarne!

1 Like

@briis thanks for the great works. I followed the steps from your GIT install tutorial but I dont get it working.

I have created an admin user and enabled the streams for the cameras. After that I installed the HACS component and restarted HA. Unfortunately, Unifi Protect does not show up in the Integrations list :confused: Any idea what I can do?

Maybe relevant information: I am running HA in a docker container, how does HACS write on the disc? But I dont get an error and it hacs it looks like the component is installed.