Custom Component: Unifi Protect

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.

Most likely a caching issue in your browser. See this post Not listed in Add Integrations? · Discussion #262 · briis/unifiprotect · GitHub

@briis you were totally right! Thanks! I tried a different browser and it worked.

1 Like

Hi all,

New to HA and Unifi. I have Unifi Protect integrated in HA via HACS with 3 G4 Pros and 1 G4 Doorbell. Everything is working, but I can not figure out how to make it so when a person (or motion) is detected it notifies me (iPhone) of the notification and includes a picture of what is happening.

How do I make that happen? Configuration > Automatons > New Automation > Switch to Yaml mode? Then what?

Here is what I have now:

alias: Front Yard Motion
description: ''
trigger:
  - type: motion
    platform: device
    device_id: 9ed32acb09386bffff99f0fe4ef8d158
    entity_id: binary_sensor.motion_front_yard
    domain: binary_sensor
condition: []
action:
  - service: notify.mobile_app_mr_walters
    data:
      message: There is motion in the front yard
mode: single

Thanks!

Just a general heads-up for anyone using the save_thumbnail service with any Unifi cameras that don’t support object detection.

With the release of Protect v1.19.0 - release notes here they have adopted square thumbnails.

In my experience this effectively renders the image_width parameter of the service irrelevant, and testing on my G3-Flex basically produces an image that does not reflect a clear view of the motion event. With our garage camera I tested by entering the garage and received a small square image of one wing of one of our cars. The thumbnail gave no visual indication that a person was in the garage.

I’ve experimented with using the camera.snapshot service however for motion events I’d have to factor in a nearly 20 second delay on the stream, making it unusable. Note that I understand why this issue occurs and that it is outside the purview of the component. As we want audio on the stream the alternatives are not particularly viable for our setup.

With that in mind I’ve expanded my use of Deepstack to scan for and identify objects based on the motion triggers provided by the component, and limited snapshots to physical events (e.g. the garage door closing, the doorbell being pushed, etc.)

Just wanted to give any other users of the save_thumbnail service a heads up - YMMV of course.

Sorry if this already answered here but there are a lot of posts and searching for add-on didn’t really give any definitive results.
Is there a Unifi Protect as an add-on?
I know there’s the controller add-on, but that’s separate.
I found this, so it makes me think it’s quite possible:

I know my performance might not be great but I kind of want to try this all out before I commit to any more hardware than just the camera.

Very surprised to see an option to install Protect in docker. My understanding is that Protect requires a “console” to function. And the only available ones that I know of are the UDMP, an NVR or the USG CK2.

I doubt the Protect app is supported outside of Unifi hardware so I’d be worried about investing money into the cameras, only to have the Protect app break because of changes made by Unifi.

Just my 2c.

Eh that’s what returns are for?
It’s not an investment until the return window is closed.
My Amcrest just went back because it’s not as reliable as the Nest, just a little more tweakable.
I almost have the container working.
We’ll see if I can add the doorbell.

1 Like