Custom Component: Unifi Protect

Hello,

New here and trying to install the unifi protect integration on a brand new Home Assistant Blue. I cannot find it when I search for a new integration typing “unifi protect” the page is just blank.
Can’t find it on this website either : Integrations - Home Assistant

Is there somehting I am doing wrong?

Start testing if motion is triggered in the Protect APP - just to make sure that we should expect motion.
Then what setup do you have. Unifi Protect V? running on “What HW”

This is a Custom Integration, so you cannot find it without adding it first. Please read this and then I recommend you install HACS so that you easy can add non standard integrations.

Thanks @briis ! I suspected this was the case but couldn’t find a way to figure it out.
Ha en fin helg :slight_smile:

1 Like

Hi @briis and thank you so much for answering.

  • The motion is detected on Protect but not on HA: https://snipboard.io/aPuAHh.jpg
  • I see the live feed on HA (every 10 seconds shot) with around 10 seconds delay (same internal 1Gbps network)
  • Unifi Protect 1.18.1 running on CloudKey G2+ 2.1.12
  • HA OS 5.13 / Core 2021.5.5 / Supervisor 2021.04.3 running on a rpi 4
  • Unifi Protect integration 0.8.8

I might have found the culprit of the problem. I had the “sensor.motion_recording_” entity disabled and only the “binary_sensor.motion_” activated. Now that I have both activated, the second one does updates (which I think makes no sense, but maybe there’s an explanation for that).

What I’m noticing now is that it’s very slow to get the motion event, sometimes 10sec+, and if you get a motion event, it takes much longer to be able to trigger it again just after the first one is off. Is this a know limitation?

Here are my recording motion settings on the camera (G3 Flex): https://snipboard.io/H14ouE.jpg

Firstly, thank you so much for creating such an awesome component. It really does work well!

I have a couple of questions about using the person detection in an automation and I was hoping someone could help me with:

1. Thumbnail 404 error
About 50% of the time the automation is triggered my automation fails with the following error when calling the unifiprotect.save_thumbnail_image service.

Thumbnail Request failed: 404 - Reason: Not Found

I believe others have solved this by putting a timeout in before calling the service, which I have also tried and is currently set to 15s but it still currently fails regularly. Does anyone know how to implement some sort of retry for this step?

2. Trigger automation for Person Events within a smart detection zone only
I have configured a smart detection zone on the camera, but it seems that the automation is triggering for person events that are detected outside the zone as well. Is it possible to only trigger the automation when the person is detected in the zone?

Thanks!

This is not normal behavior. I see the binary motion sensor triggering instantly in Home Assistant. There is a delay in the Video Stream as described several times, so these might be out of sync, but motion triggering should be close to as instant as in the Protect APP.

There is not a direct correlation between the sensor_motion_recording_x and the binary motion sensor, so it surprises me that this makes the binary sensor work.

I am not really sure how to help, as I cannot reproduce what you experience. Is there anything in the Log files?

The thumbnail is created once the recording has finished, so hitting the right delay might be hard. I recommend that you use the camera.snapshot service instead, which will always work.

Motion events are not tied to detection zones, so that is expected behavior. I recommend that you test for the event_object attribute to check if it is a SmartDetection event. Something like this
With that said, this might be something I should look at. If you could create an issue on Github describing how you would prefer it to work, I will add this a feature request.

@briis , is there a way to access the UDM PRO NVR with this integration to playback recorded footage? My guess is that we can’t since you are using live streaming through RSTP stream but just wanted to check.

No unfortunately not. See this issue on Github.

1 Like

First off, thanks for this amazing integration!
I’ve been able to create an automation based off person & vehicle detection and its working awesome!
I do have a question though, I have a last triggered entities card, is it possible to change this to only trigger on vehicle or person detection rather than just motion?

image

title: Outside
type: entities
entities:
  - entity: binary_sensor.motion_driveway
    secondary_info: last-changed
    name: Driveway
    state_color: true
  - entity: binary_sensor.motion_garden_bed
    secondary_info: last-changed
    name: Garden Bed
    state_color: true
  - entity: binary_sensor.motion_clothesline
    secondary_info: last-changed
    name: Clothesline
    state_color: true
  - entity: binary_sensor.motion_veggie_patch
    secondary_info: last-changed
    name: Veggie Patch
    state_color: true

This will be hard. The last-changed is updated every time HA detects a change in state, and that will mean also on basic motion detection.

I noticed that with UniFi Protect Application 1.19.0-beta.10 there seems to have been a change in the API, so that motion is now only triggered when the Motion Recording is NOT set to Never. That will be good for you in this use case, but not so good for people who use the Cameras as basic motion sensors.
I am still investigating what has changed, and if possible I will fix it so that it works as it does right now.

Ahh no problem, thanks so much for the info this has saved me a lot of time :slight_smile:

Just received my G4 Doorbell and struggle to find a way to display an LCD message on the display through a script.
I was thinking this should work:

display_message_on_doorbell:
  alias: Display message on Doorbell
  sequence:
  - service: unifiprotect.set_doorbell_lcd_message      
    data:
      entity_id: camera.uvc_g4_doorbell
      message: text to display
      duration: 00:01:00
  mode: single

I always receive a "required key not provided @data[‘message’].
I guess my syntax is wrong.

Any ideas?

try ```

      message: "text to display"
      duration: "00:01:00"
1 Like

That actually did the trick, thanks! :slight_smile:
I also see duration is in minutes so I changed duration to duration: “1” for my personal use.

For some reason a doorbell press of my G4 doorbell is not recognised anymore. The binary sensor stays at “not detected” Only the attribute “last tripped time” changes.
I don’t have a harddisk installed in my UDM Pro…is that causing the issue? Switching the input booleans for motion detection and recording also don’t result in different behaviour (they switch back to their original state themselves)

1 Like

The doorbell binary is not like a normal binary, as the doorbell by nature goes off as soon as people release the button. If the last_tripped attribute changes, then it works.
So use this in automations when it triggers the on state, and then do what you need to do.

Is it possible to get microphone noise level as sensor?