home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.9k stars 30.97k forks source link

UniFi Protect smart detection sensors are not turning on after Protect 4.1.x fixed in 5.0.31 except for license plates (LPR) #124967

Open IvSan opened 2 months ago

IvSan commented 2 months ago

The problem

The G5 Bullet camera, which has smart detection for persons enabled, is integrated into Home Assistant via the unifiprotect integration. This setup includes a binary sensor Person Detected associated with the camera. However, starting from August 30, 2024, this sensor has stopped triggering, even though the general motion detection sensor continues to work correctly. The person detection feature is functioning properly on the UniFi OS side, so it seems the issue lies within the integration between Home Assistant and UniFi OS. This may have occurred due to a recent update to the UniFi Protect app by UniFi OS.

What version of Home Assistant Core has the issue?

core-2024.6.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

unifiprotect

Link to integration documentation on our website

https://www.home-assistant.io/integrations/unifiprotect

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 2 months ago

unifiprotect documentation unifiprotect source

Stewbo1 commented 2 months ago

I am also having this issue since the latest Unifi Protect update to 4.1.53 What is strange is that the smart detection (person or vehicle) for my 9 cameras (G4 and G5s) is switching on/off in HA, but the switching is no longer impacting the Binary Sensor Groups that they are in and since all of my automations are triggered by groups, nothing triggered by HA is working.

blackdragon2300 commented 2 months ago

I am also having this problem but on my side it looks like the binary sensor for person detection trips on and off at the same or nearly the same time. I am running unifi protect Version 4.1.53, HA core 2024.8.3 . g4 instant front door Capture

Stewbo1 commented 2 months ago

Well spotted @blackdragon2300 you are right, same issue here, it is turning off in the same moment that it switches on, that is why it is not triggering the Groups.

Screenshot 2024-08-31 150610

I am now struggling to work out how to downgrade my Cloud Key G2+ back to the previous Unifi Protect version.

IvSan commented 2 months ago

My situation is not the same, "Person Detected" is not triggered at all.

image
Stewbo1 commented 2 months ago

I have worked out how to downgrade Unifi Protect back to 4.0.33. This fixed the issue for me, note that I am no expert so this is at your own risk but hopefully it may save you the couple of hours that I have spent on this today ... thankfully the Test Match was on to keep me sane [cricket]!

  1. Enable SSH in the Unifi Site Manager - Control Plane. Give it a password if you need to.
  2. Stop Unifi Protect in Site Manager
  3. Open a SSH terminal (I just use Window's CMD in administrator mode)
  4. root@192.168.1.30 (whatever the IP is of your CK / CK G2+)
  5. Enter your SSH password Type:
  6. unifi-os shell (not needed on UCKG2+)
  7. apt-get update
  8. apt-get install --reinstall --allow-downgrades unifi-protect=4.0.33 -y Give it a few minutes to run... it will go back to "root@Home:~#" once complete

Go back into Unifi Site Manager, refresh your page and you are back with Unifi Protect 4.0.33 which will have already started.

  1. Switch off automatic updates! And disable SSH if you so wish.

Everything then worked again for me in HA. I hope this helps!

Stewbo1 commented 2 months ago

@IvSan does 'Object Detection' still capture the detection? That has been the workaround that some others have used since 4.1.50 albeit they like me have had our sensors turning on and immediately off, rather than not come on at all.

IvSan commented 2 months ago

If you're asking about binary sensor object_detected, yes, it's capturing something.

image
GeeGee-be commented 2 months ago

Same issue here. My events in HA that are triggered by smart detections (alarm, opening garage…) stopped working. Those updates can screw things up…

mizike22 commented 2 months ago

I am having the same issue with the license plate detections smart detection.

exedox commented 2 months ago

I to am having the same issue, good to know its hitting everyone else too. hope for a fix soon

apo5698 commented 2 months ago

Same issue - Individual smart detections immediately turn off after on, but the combined object_detected works.

mgrinspan commented 2 months ago

Same issue here. Unifi Protect 4.1.53 - person and vehicle detection binary sensors turn on and immediately off in the same moment.

tehzwen commented 2 months ago

I have worked out how to downgrade Unifi Protect back to 4.0.33. This fixed the issue for me, note that I am no expert so this is at your own risk but hopefully it may save you the couple of hours that I have spent on this today ... thankfully the Test Match was on to keep me sane [cricket]!

  1. Enable SSH in the Unifi Site Manager - Control Plane. Give it a password if you need to.
  2. Stop Unifi Protect in Site Manager
  3. Open a SSH terminal (I just use Window's CMD in administrator mode)
  4. root@192.168.1.30 (whatever the IP is of your CK / CK G2+)
  5. Enter your SSH password Type:
  6. unifi-os shell (not needed on UCKG2+)
  7. apt-get update
  8. apt-get install --reinstall --allow-downgrades unifi-protect=4.0.33 -y Give it a few minutes to run... it will go back to "root@Home:~#" once complete

Go back into Unifi Site Manager, refresh your page and you are back with Unifi Protect 4.0.33 which will have already started. 9. Switch off automatic updates! And disable SSH if you so wish.

Everything then worked again for me in HA. I hope this helps!

This worked perfectly. I contacted support about the issue and was told tough luck basically.

TheJulianJES commented 2 months ago

Yet to dig into this, but here are some debug logs of a working motion detection and a person detection that starts and ends instantly, both with UniFi Protect 4.1.53.

Person detection - broken, starts and ends at the same time:

# event starts:
2024-09-02 19:59:02.804 DEBUG (MainThread) [uiprotect.api] emitting message: WSAction.UPDATE:ModelType.CAMERA:6650c67f003d7d03e40199a4:['is_smart_detected', 'is_recording']
2024-09-02 19:59:02.805 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5 Turret Ultra (F4E2C67B8E24)
2024-09-02 19:59:02.808 DEBUG (MainThread) [uiprotect.api] emitting message: WSAction.ADD:ModelType.EVENT:66d5fce603383103e400357e:['model', 'id', 'type', 'start', 'end', 'score', 'heatmap_id', 'camera_id', 'smart_detect_types', 'smart_detect_event_ids', 'thumbnail_id', 'user_id', 'timestamp', 'metadata', 'deleted_at', 'deletion_type', 'category', 'sub_category']
2024-09-02 19:59:02.808 DEBUG (MainThread) [uiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d5fce603383103e400357e', 'type': <EventType.SMART_DETECT: 'smartDetectZone'>, 'start': datetime.datetime(2024, 9, 2, 17, 59, 0, 581000, tzinfo=datetime.timezone.utc), 'end': None, 'score': 50, 'heatmap_id': None, 'camera_id': '6650c67f003d7d03e40199a4', 'smart_detect_types': [], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 19:59:02.808 DEBUG (MainThread) [uiprotect.utils] G5 Turret Ultra (F4E2C67B8E24): New smart detection started for [] (66d5fce603383103e400357e)
2024-09-02 19:59:02.808 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5 Turret Ultra (F4E2C67B8E24)
2024-09-02 19:59:02.808 DEBUG (MainThread) [homeassistant.components.unifiprotect.entity] Updating state [G5 Turret Ultra Object detected (F4E2C67B8E24)] [True, False, {}] -> (True, True, {'event_id': '66d5fce603383103e400357e', 'event_score': 50})
# object event ends here:
2024-09-02 19:59:16.720 DEBUG (MainThread) [uiprotect.api] emitting message: WSAction.UPDATE:ModelType.CAMERA:6650c67f003d7d03e40199a4:['is_smart_detected', 'is_recording']
2024-09-02 19:59:16.722 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5 Turret Ultra (F4E2C67B8E24)
2024-09-02 19:59:16.724 DEBUG (MainThread) [uiprotect.api] emitting message: WSAction.UPDATE:ModelType.EVENT:66d5fce603383103e400357e:['end', 'score', 'smart_detect_types']
2024-09-02 19:59:16.724 DEBUG (MainThread) [uiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d5fce603383103e400357e', 'type': <EventType.SMART_DETECT: 'smartDetectZone'>, 'start': datetime.datetime(2024, 9, 2, 17, 59, 0, 581000, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 9, 2, 17, 59, 18, 248000, tzinfo=datetime.timezone.utc), 'score': 65, 'heatmap_id': None, 'camera_id': '6650c67f003d7d03e40199a4', 'smart_detect_types': [<SmartDetectObjectType.PERSON: 'person'>], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 19:59:16.724 DEBUG (MainThread) [uiprotect.utils] G5 Turret Ultra (F4E2C67B8E24): Smart detection ended for [<SmartDetectObjectType.PERSON: 'person'>] (66d5fce603383103e400357e)
2024-09-02 19:59:16.724 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5 Turret Ultra (F4E2C67B8E24)
2024-09-02 19:59:16.725 DEBUG (MainThread) [homeassistant.components.unifiprotect.entity] Updating state [G5 Turret Ultra Object detected (F4E2C67B8E24)] [True, True, {'event_id': '66d5fce603383103e400357e', 'event_score': 50}] -> (True, False, {})
# ...
2024-09-02 19:59:17.124 DEBUG (MainThread) [uiprotect.data.bootstrap] Unknown model type: smartDetectObject  # lib is unaware of this?
2024-09-02 19:59:17.202 DEBUG (MainThread) [uiprotect.api] emitting message: WSAction.UPDATE:ModelType.EVENT:66d5fce603383103e400357e:['smart_detect_types', 'metadata']
2024-09-02 19:59:17.202 DEBUG (MainThread) [uiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d5fce603383103e400357e', 'type': <EventType.SMART_DETECT: 'smartDetectZone'>, 'start': datetime.datetime(2024, 9, 2, 17, 59, 0, 581000, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 9, 2, 17, 59, 18, 248000, tzinfo=datetime.timezone.utc), 'score': 65, 'heatmap_id': None, 'camera_id': '6650c67f003d7d03e40199a4', 'smart_detect_types': [<SmartDetectObjectType.PERSON: 'person'>], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': [{'clock_best_wall': datetime.datetime(2024, 9, 2, 17, 59, 14, 177000, tzinfo=datetime.timezone.utc), 'type': 'person', 'cropped_id': '66d5fcf500773103e4003580', 'attributes': {'color': None, 'vehicle_type': None}, 'name': None}]}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 19:59:17.202 DEBUG (MainThread) [uiprotect.utils] G5 Turret Ultra (F4E2C67B8E24): Smart detection ended for [<SmartDetectObjectType.PERSON: 'person'>] (66d5fce603383103e400357e)
2024-09-02 19:59:17.202 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5 Turret Ultra (F4E2C67B8E24)

And for comparison: Motion detection - fine, starts and ends properly:

# event starts:
2024-09-02 20:01:07.314 DEBUG (MainThread) [uiprotect.api] emitting message: WSAction.ADD:ModelType.EVENT:66d5fd6301463103e4003589:['model', 'id', 'type', 'start', 'end', 'score', 'heatmap_id', 'camera_id', 'smart_detect_types', 'smart_detect_event_ids', 'thumbnail_id', 'user_id', 'timestamp', 'metadata', 'deleted_at', 'deletion_type', 'category', 'sub_category']
2024-09-02 20:01:07.314 DEBUG (MainThread) [uiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d5fd6301463103e4003589', 'type': <EventType.MOTION: 'motion'>, 'start': datetime.datetime(2024, 9, 2, 18, 1, 4, 52000, tzinfo=datetime.timezone.utc), 'end': None, 'score': 0, 'heatmap_id': None, 'camera_id': '6650c67f003d7d03e40199a4', 'smart_detect_types': [], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 20:01:07.314 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5 Turret Ultra (F4E2C67B8E24)
2024-09-02 20:01:07.315 DEBUG (MainThread) [homeassistant.components.unifiprotect.entity] Updating state [G5 Turret Ultra Motion (F4E2C67B8E24)] [True, False, {}] -> (True, True, {'event_id': '66d5fd6301463103e4003589', 'event_score': 0})
2024-09-02 20:01:07.317 DEBUG (MainThread) [uiprotect.api] emitting message: WSAction.UPDATE:ModelType.CAMERA:6650c67f003d7d03e40199a4:['is_motion_detected', 'is_recording']
2024-09-02 20:01:07.317 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5 Turret Ultra (F4E2C67B8E24)
# shortly before end?:
2024-09-02 20:01:18.901 DEBUG (MainThread) [uiprotect.api] emitting message: WSAction.UPDATE:ModelType.CAMERA:6650c67f003d7d03e40199a4:['is_motion_detected', 'is_recording']
2024-09-02 20:01:18.901 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5 Turret Ultra (F4E2C67B8E24)
2024-09-02 20:01:18.922 DEBUG (MainThread) [uiprotect.api] emitting message: WSAction.UPDATE:ModelType.EVENT:66d5fd6301463103e4003589:['score']
2024-09-02 20:01:18.923 DEBUG (MainThread) [uiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d5fd6301463103e4003589', 'type': <EventType.MOTION: 'motion'>, 'start': datetime.datetime(2024, 9, 2, 18, 1, 4, 52000, tzinfo=datetime.timezone.utc), 'end': None, 'score': 100, 'heatmap_id': None, 'camera_id': '6650c67f003d7d03e40199a4', 'smart_detect_types': [], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 20:01:18.923 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5 Turret Ultra (F4E2C67B8E24)
2024-09-02 20:01:18.923 DEBUG (MainThread) [homeassistant.components.unifiprotect.entity] Updating state [G5 Turret Ultra Motion (F4E2C67B8E24)] [True, True, {'event_id': '66d5fd6301463103e4003589', 'event_score': 0}] -> (True, True, {'event_id': '66d5fd6301463103e4003589', 'event_score': 100})
# event ends here:
2024-09-02 20:01:19.649 DEBUG (MainThread) [uiprotect.api] emitting message: WSAction.UPDATE:ModelType.EVENT:66d5fd6301463103e4003589:['end', 'metadata']
2024-09-02 20:01:19.649 DEBUG (MainThread) [uiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d5fd6301463103e4003589', 'type': <EventType.MOTION: 'motion'>, 'start': datetime.datetime(2024, 9, 2, 18, 1, 4, 52000, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 9, 2, 18, 1, 20, 435000, tzinfo=datetime.timezone.utc), 'score': 100, 'heatmap_id': None, 'camera_id': '6650c67f003d7d03e40199a4', 'smart_detect_types': [], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': [{'clock_best_wall': datetime.datetime(2024, 9, 2, 18, 1, 14, 389000, tzinfo=datetime.timezone.utc), 'type': 'motion', 'cropped_id': '66d5fd6f01553103e400358b', 'attributes': None, 'name': None}]}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 20:01:19.649 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5 Turret Ultra (F4E2C67B8E24)
2024-09-02 20:01:19.650 DEBUG (MainThread) [homeassistant.components.unifiprotect.entity] Updating state [G5 Turret Ultra Motion (F4E2C67B8E24)] [True, True, {'event_id': '66d5fd6301463103e4003589', 'event_score': 100}] -> (True, False, {})

Relevant logbook entries for the person detection: Bildschirmfoto 2024-09-02 um 19 59 42

Logbook entries for properly working motion detection: Bildschirmfoto 2024-09-02 um 20 01 53

So, for me, it looks like the "object detected" sensor works properly and the "person detected" sensor is only triggered on, then immediately off AFTER the actual detection STOPPED.

bdraco commented 2 months ago

It looks like its not fixable as UI isn't sending the person detection until the end of the event now.

Event starts: notice that smart_detect_types is empty

2024-09-02 19:59:02.808 DEBUG (MainThread) [uiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d5fce603383103e400357e', 'type': <EventType.SMART_DETECT: 'smartDetectZone'>, 'start': datetime.datetime(2024, 9, 2, 17, 59, 0, 581000, tzinfo=datetime.timezone.utc), 'end': None, 'score': 50, 'heatmap_id': None, 'camera_id': '6650c67f003d7d03e40199a4', 'smart_detect_types': [], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}

Events ends: notice that smart_detect_types is now populated

2024-09-02 19:59:16.724 DEBUG (MainThread) [uiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d5fce603383103e400357e', 'type': <EventType.SMART_DETECT: 'smartDetectZone'>, 'start': datetime.datetime(2024, 9, 2, 17, 59, 0, 581000, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 9, 2, 17, 59, 18, 248000, tzinfo=datetime.timezone.utc), 'score': 65, 'heatmap_id': None, 'camera_id': '6650c67f003d7d03e40199a4', 'smart_detect_types': [<SmartDetectObjectType.PERSON: 'person'>], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}

bdraco commented 2 months ago

It looks like this is a fundamental change in protect 4.1.x which means we likely can't do anything about it.

This is either a regression in protect 4.1.x or an intentional breaking change in protect. The protect iOS app appears behaves the same way as well and event doesn't get declared until it ends. Its does look like UI intended this behavior change.

IvSan commented 2 months ago

Hi @TheJulianJES, please do not rename this issue, your renaming is not reflecting my problem. Thank you.

IvSan commented 2 months ago

It looks like this is a fundamental change in protect 4.1.x which means we likely can't do anything about it. This is either a regression in protect 4.1.x or an intentional breaking change in protect.

I came to the same conclusions unfortunately =(

bdraco commented 2 months ago

Hi @TheJulianJES, please do not rename this issue, your renaming is not reflecting my problem. Thank you.

Please check your logbook. Mine is still turning off and on but much much quicker. Its likely still detecting the event but the duration is now in microseconds instead of seconds

IvSan commented 2 months ago

No, it is not my case. Person detection is not triggered at all on my system. Last one was 3 days ago, that was before UniFi OS update, no single one after.

image
bdraco commented 2 months ago

Sadly it looks like there are multiple problems as I can definitely still see person events, but they are microseconds long now. Can you post the debug for the events like TheJulianJES posted above?

Screenshot 2024-09-02 at 9 50 57 AM
TheJulianJES commented 2 months ago

No, it is not my case. Person detection is not triggered at all on my system. Last one was 3 days ago, that was before UniFi OS update, no single one after.

That's the wrong entity. Notice the "turned on triggered by service Switch: Turn on" at the top. You need the binary sensor entity, not the switch one for turning on/off person detections. By default, the entity you want to check is named something like "Camera Person detected".

IvSan commented 2 months ago

Yes, you're right, it was a wrong entity, here is correct one. Person detection was triggered one time since update. I assure you there are dozens of person evens in front of the camera daily. So the fact it was triggered but only once is really confusing me.

image
TheJulianJES commented 2 months ago

That one time was already with the 4.1.x update though, right? I wonder if the event can be so short it's not recorded in the logbook, maybe depending on processing power or other factors..? Getting debug logs would be helpful to confirm it's the same issue with short events.

IvSan commented 2 months ago

That one time was already with the 4.1.x update though, right?

Yes

Getting debug logs would be helpful to confirm it's the same issue with short events.

Give me some time to figure out how to share it.

TheJulianJES commented 2 months ago

You should be able to go to the integration page for UniFi Protect and click "Enable debug logging", then trigger the camera's person detection, and click the button to disable debug logs again. That should prompt you to download the home-assistant.log file. You can just copy/paste the short/relevant section from it. image

Also, looking at the logbook live whilst triggering the camera might cause you to see different events in cases like this.

IvSan commented 2 months ago

Ok, here is my log, I hope it helps.

2024-09-02 22:10:05.901 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.CAMERA:*some_camera_id*:[]
2024-09-02 22:10:05.901 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:05.910 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.ADD:ModelType.EVENT:66d61b9d03762e03e400596d:['model', 'id', 'type', 'start', 'end', 'score', 'heatmap_id', 'camera_id', 'smart_detect_types', 'smart_detect_event_ids', 'thumbnail_id', 'user_id', 'timestamp', 'metadata', 'deleted_at', 'deletion_type', 'category', 'sub_category']
2024-09-02 22:10:05.911 DEBUG (MainThread) [pyunifiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d61b9d03762e03e400596d', 'type': <EventType.MOTION: 'motion'>, 'start': datetime.datetime(2024, 9, 2, 20, 9, 58, 652000, tzinfo=datetime.timezone.utc), 'end': None, 'score': 0, 'heatmap_id': None, 'camera_id': 'cam_id', 'smart_detect_types': [], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 22:10:05.911 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:05.914 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.CAMERA:*some_camera_id*:['is_motion_detected', 'is_recording']
2024-09-02 22:10:05.914 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:05.915 DEBUG (MainThread) [homeassistant.components.unifiprotect.entity] Updating state [G5_Entrance Motion (G5)] (True, False, {}) -> (True, True, {'event_id': '66d61b9d03762e03e400596d', 'event_score': 0})
2024-09-02 22:10:06.219 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.CAMERA:*some_camera_id*:['is_smart_detected', 'is_recording']
2024-09-02 22:10:06.219 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:06.223 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.ADD:ModelType.EVENT:66d61b9e00d52e03e400596e:['model', 'id', 'type', 'start', 'end', 'score', 'heatmap_id', 'camera_id', 'smart_detect_types', 'smart_detect_event_ids', 'thumbnail_id', 'user_id', 'timestamp', 'metadata', 'deleted_at', 'deletion_type', 'category', 'sub_category']
2024-09-02 22:10:06.223 DEBUG (MainThread) [pyunifiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d61b9e00d52e03e400596e', 'type': <EventType.SMART_DETECT: 'smartDetectZone'>, 'start': datetime.datetime(2024, 9, 2, 20, 9, 59, 887000, tzinfo=datetime.timezone.utc), 'end': None, 'score': 74, 'heatmap_id': None, 'camera_id': 'cam_id', 'smart_detect_types': [], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 22:10:06.224 DEBUG (MainThread) [pyunifiprotect.utils] G5_Entrance (G5): New smart detection started for [] (66d61b9e00d52e03e400596e)
2024-09-02 22:10:06.224 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:06.224 DEBUG (MainThread) [homeassistant.components.unifiprotect.entity] Updating state [G5_Entrance Object Detected (G5)] (True, False, {}) -> (True, True, {'event_id': '66d61b9e00d52e03e400596e', 'event_score': 74})
2024-09-02 22:10:06.275 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.CAMERA:*some_camera_id*:[]
2024-09-02 22:10:06.275 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:06.278 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.EVENT:66d61b9d03762e03e400596d:['score', 'smart_detect_event_ids']
2024-09-02 22:10:06.279 DEBUG (MainThread) [pyunifiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d61b9d03762e03e400596d', 'type': <EventType.MOTION: 'motion'>, 'start': datetime.datetime(2024, 9, 2, 20, 9, 58, 652000, tzinfo=datetime.timezone.utc), 'end': None, 'score': 100, 'heatmap_id': None, 'camera_id': 'cam_id', 'smart_detect_types': [], 'smart_detect_event_ids': ['66d61b9e00d52e03e400596e'], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 22:10:06.279 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:06.280 DEBUG (MainThread) [homeassistant.components.unifiprotect.entity] Updating state [G5_Entrance Motion (G5)] (True, True, {'event_id': '66d61b9d03762e03e400596d', 'event_score': 0}) -> (True, True, {'event_id': '66d61b9d03762e03e400596d', 'event_score': 100})
2024-09-02 22:10:07.468 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.ADD:ModelType.EVENT:66d61b9f01cb2e03e4005970:['model', 'id', 'type', 'start', 'end', 'score', 'heatmap_id', 'camera_id', 'smart_detect_types', 'smart_detect_event_ids', 'thumbnail_id', 'user_id', 'timestamp', 'metadata', 'deleted_at', 'deletion_type', 'category', 'sub_category']
2024-09-02 22:10:07.468 DEBUG (MainThread) [pyunifiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d61b9f01cb2e03e4005970', 'type': <EventType.SMART_DETECT_LINE: 'smartDetectLine'>, 'start': datetime.datetime(2024, 9, 2, 20, 10, 1, 111000, tzinfo=datetime.timezone.utc), 'end': None, 'score': 81, 'heatmap_id': None, 'camera_id': 'cam_id', 'smart_detect_types': [], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 22:10:07.468 DEBUG (MainThread) [pyunifiprotect.utils] G5_Entrance (G5): New smart detection started for [] (66d61b9f01cb2e03e4005970)
2024-09-02 22:10:07.468 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:07.468 DEBUG (MainThread) [homeassistant.components.unifiprotect.entity] Updating state [G5_Entrance Object Detected (G5)] (True, True, {'event_id': '66d61b9e00d52e03e400596e', 'event_score': 74}) -> (True, True, {'event_id': '66d61b9f01cb2e03e4005970', 'event_score': 81})
2024-09-02 22:10:07.531 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.CAMERA:*some_camera_id*:[]
2024-09-02 22:10:07.532 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:07.535 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.EVENT:66d61b9d03762e03e400596d:['smart_detect_event_ids']
2024-09-02 22:10:07.535 DEBUG (MainThread) [pyunifiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d61b9d03762e03e400596d', 'type': <EventType.MOTION: 'motion'>, 'start': datetime.datetime(2024, 9, 2, 20, 9, 58, 652000, tzinfo=datetime.timezone.utc), 'end': None, 'score': 100, 'heatmap_id': None, 'camera_id': 'cam_id', 'smart_detect_types': [], 'smart_detect_event_ids': ['66d61b9e00d52e03e400596e', '66d61b9f01cb2e03e4005970'], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 22:10:07.536 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:10.503 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.CAMERA:*some_camera_id*:['is_motion_detected', 'is_recording']
2024-09-02 22:10:10.503 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:10.504 DEBUG (MainThread) [homeassistant.components.unifiprotect.entity] Updating state [G5_Entrance Motion (G5)] (True, True, {'event_id': '66d61b9d03762e03e400596d', 'event_score': 100}) -> (True, False, {})
2024-09-02 22:10:11.128 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.EVENT:66d61b9d03762e03e400596d:['end', 'metadata']
2024-09-02 22:10:11.129 DEBUG (MainThread) [pyunifiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d61b9d03762e03e400596d', 'type': <EventType.MOTION: 'motion'>, 'start': datetime.datetime(2024, 9, 2, 20, 9, 58, 652000, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 9, 2, 20, 10, 12, 27000, tzinfo=datetime.timezone.utc), 'score': 100, 'heatmap_id': None, 'camera_id': 'cam_id', 'smart_detect_types': [], 'smart_detect_event_ids': ['66d61b9e00d52e03e400596e', '66d61b9f01cb2e03e4005970'], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': [{'clock_best_wall': datetime.datetime(2024, 9, 2, 20, 10, 5, 887000, tzinfo=datetime.timezone.utc), 'type': 'motion', 'cropped_id': '66d61ba203bd2e03e4005971', 'attributes': None, 'name': None}]}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 22:10:11.129 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:12.063 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.CAMERA:*some_camera_id*:[]
2024-09-02 22:10:12.064 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:12.066 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.ADD:ModelType.EVENT:66d61ba4003a2e03e4005975:['model', 'id', 'type', 'start', 'end', 'score', 'heatmap_id', 'camera_id', 'smart_detect_types', 'smart_detect_event_ids', 'thumbnail_id', 'user_id', 'timestamp', 'metadata', 'deleted_at', 'deletion_type', 'category', 'sub_category']
2024-09-02 22:10:12.067 DEBUG (MainThread) [pyunifiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d61ba4003a2e03e4005975', 'type': <EventType.MOTION: 'motion'>, 'start': datetime.datetime(2024, 9, 2, 20, 10, 4, 767000, tzinfo=datetime.timezone.utc), 'end': None, 'score': 0, 'heatmap_id': None, 'camera_id': 'cam_id', 'smart_detect_types': [], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 22:10:12.067 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:12.124 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.CAMERA:*some_camera_id*:['is_motion_detected', 'is_recording']
2024-09-02 22:10:12.125 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:12.125 DEBUG (MainThread) [homeassistant.components.unifiprotect.entity] Updating state [G5_Entrance Motion (G5)] (True, False, {}) -> (True, True, {'event_id': '66d61ba4003a2e03e4005975', 'event_score': 0})
2024-09-02 22:10:12.175 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.EVENT:66d61ba4003a2e03e4005975:['smart_detect_event_ids']
2024-09-02 22:10:12.175 DEBUG (MainThread) [pyunifiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d61ba4003a2e03e4005975', 'type': <EventType.MOTION: 'motion'>, 'start': datetime.datetime(2024, 9, 2, 20, 10, 4, 767000, tzinfo=datetime.timezone.utc), 'end': None, 'score': 0, 'heatmap_id': None, 'camera_id': 'cam_id', 'smart_detect_types': [], 'smart_detect_event_ids': ['66d61b9e00d52e03e400596e'], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 22:10:12.175 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:12.313 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.CAMERA:*some_camera_id*:['is_smart_detected', 'is_recording']
2024-09-02 22:10:12.313 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:12.313 DEBUG (MainThread) [homeassistant.components.unifiprotect.entity] Updating state [G5_Entrance Object Detected (G5)] (True, True, {'event_id': '66d61b9f01cb2e03e4005970', 'event_score': 81}) -> (True, False, {})
2024-09-02 22:10:12.319 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.EVENT:66d61b9f01cb2e03e4005970:['end', 'smart_detect_types', 'metadata']
2024-09-02 22:10:12.320 DEBUG (MainThread) [pyunifiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d61b9f01cb2e03e4005970', 'type': <EventType.SMART_DETECT_LINE: 'smartDetectLine'>, 'start': datetime.datetime(2024, 9, 2, 20, 10, 1, 111000, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 9, 2, 20, 10, 16, 767000, tzinfo=datetime.timezone.utc), 'score': 81, 'heatmap_id': None, 'camera_id': 'cam_id', 'smart_detect_types': [<SmartDetectObjectType.PERSON: 'person'>], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 22:10:12.320 DEBUG (MainThread) [pyunifiprotect.utils] G5_Entrance (G5): Smart detection ended for [<SmartDetectObjectType.PERSON: 'person'>] (66d61b9f01cb2e03e4005970)
2024-09-02 22:10:12.321 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:12.574 DEBUG (MainThread) [pyunifiprotect.data.bootstrap] Unknown model type: smartDetectObject
2024-09-02 22:10:12.649 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.EVENT:66d61b9f01cb2e03e4005970:['smart_detect_types', 'metadata']
2024-09-02 22:10:12.650 DEBUG (MainThread) [pyunifiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d61b9f01cb2e03e4005970', 'type': <EventType.SMART_DETECT_LINE: 'smartDetectLine'>, 'start': datetime.datetime(2024, 9, 2, 20, 10, 1, 111000, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 9, 2, 20, 10, 16, 767000, tzinfo=datetime.timezone.utc), 'score': 81, 'heatmap_id': None, 'camera_id': 'cam_id', 'smart_detect_types': [<SmartDetectObjectType.PERSON: 'person'>], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': [{'clock_best_wall': datetime.datetime(2024, 9, 2, 20, 10, 7, 111000, tzinfo=datetime.timezone.utc), 'type': 'person', 'cropped_id': '66d61ba402002e03e4005977', 'attributes': {'color': None, 'vehicle_type': None}, 'name': None}]}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 22:10:12.650 DEBUG (MainThread) [pyunifiprotect.utils] G5_Entrance (G5): Smart detection ended for [<SmartDetectObjectType.PERSON: 'person'>] (66d61b9f01cb2e03e4005970)
2024-09-02 22:10:12.651 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:12.722 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.EVENT:66d61b9e00d52e03e400596e:['end', 'score', 'smart_detect_types']
2024-09-02 22:10:12.723 DEBUG (MainThread) [pyunifiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d61b9e00d52e03e400596e', 'type': <EventType.SMART_DETECT: 'smartDetectZone'>, 'start': datetime.datetime(2024, 9, 2, 20, 9, 59, 887000, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 9, 2, 20, 10, 17, 229000, tzinfo=datetime.timezone.utc), 'score': 81, 'heatmap_id': None, 'camera_id': 'cam_id', 'smart_detect_types': [<SmartDetectObjectType.PERSON: 'person'>], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': None}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 22:10:12.723 DEBUG (MainThread) [pyunifiprotect.utils] G5_Entrance (G5): Smart detection ended for [<SmartDetectObjectType.PERSON: 'person'>] (66d61b9e00d52e03e400596e)
2024-09-02 22:10:12.723 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:13.029 DEBUG (MainThread) [pyunifiprotect.data.bootstrap] Unknown model type: smartDetectObject
2024-09-02 22:10:13.096 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.EVENT:66d61b9e00d52e03e400596e:['smart_detect_types', 'metadata']
2024-09-02 22:10:13.096 DEBUG (MainThread) [pyunifiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d61b9e00d52e03e400596e', 'type': <EventType.SMART_DETECT: 'smartDetectZone'>, 'start': datetime.datetime(2024, 9, 2, 20, 9, 59, 887000, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 9, 2, 20, 10, 17, 229000, tzinfo=datetime.timezone.utc), 'score': 81, 'heatmap_id': None, 'camera_id': 'cam_id', 'smart_detect_types': [<SmartDetectObjectType.PERSON: 'person'>], 'smart_detect_event_ids': [], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': [{'clock_best_wall': datetime.datetime(2024, 9, 2, 20, 10, 7, 111000, tzinfo=datetime.timezone.utc), 'type': 'person', 'cropped_id': '66d61ba403e72e03e400597d', 'attributes': {'color': None, 'vehicle_type': None}, 'name': None}]}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 22:10:13.097 DEBUG (MainThread) [pyunifiprotect.utils] G5_Entrance (G5): Smart detection ended for [<SmartDetectObjectType.PERSON: 'person'>] (66d61b9e00d52e03e400596e)
2024-09-02 22:10:13.097 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:16.293 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.CAMERA:*some_camera_id*:['is_motion_detected', 'is_recording']
2024-09-02 22:10:16.294 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
2024-09-02 22:10:16.294 DEBUG (MainThread) [homeassistant.components.unifiprotect.entity] Updating state [G5_Entrance Motion (G5)] (True, True, {'event_id': '66d61ba4003a2e03e4005975', 'event_score': 0}) -> (True, False, {})
2024-09-02 22:10:16.855 DEBUG (MainThread) [pyunifiprotect.api] emitting message: WSAction.UPDATE:ModelType.EVENT:66d61ba4003a2e03e4005975:['end', 'metadata']
2024-09-02 22:10:16.856 DEBUG (MainThread) [pyunifiprotect.utils] event WS msg: {'model': <ModelType.EVENT: 'event'>, 'id': '66d61ba4003a2e03e4005975', 'type': <EventType.MOTION: 'motion'>, 'start': datetime.datetime(2024, 9, 2, 20, 10, 4, 767000, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 9, 2, 20, 10, 17, 853000, tzinfo=datetime.timezone.utc), 'score': 0, 'heatmap_id': None, 'camera_id': 'cam_id', 'smart_detect_types': [], 'smart_detect_event_ids': ['66d61b9e00d52e03e400596e'], 'thumbnail_id': None, 'user_id': None, 'timestamp': None, 'metadata': {'client_platform': None, 'reason': None, 'app_update': None, 'light_id': None, 'light_name': None, 'type': None, 'sensor_id': None, 'sensor_name': None, 'sensor_type': None, 'doorlock_id': None, 'doorlock_name': None, 'from_value': None, 'to_value': None, 'mount_type': None, 'status': None, 'alarm_type': None, 'device_id': None, 'mac': None, 'license_plate': None, 'detected_thumbnails': [{'clock_best_wall': datetime.datetime(2024, 9, 2, 20, 10, 11, 319000, tzinfo=datetime.timezone.utc), 'type': 'motion', 'cropped_id': '66d61ba802762e03e4005984', 'attributes': None, 'name': None}]}, 'deleted_at': None, 'deletion_type': None, 'category': None, 'sub_category': None}
2024-09-02 22:10:16.856 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G5_Entrance (G5)
jxlarrea commented 2 months ago

I am also experiencing this issue. Seems like the "person detected" sensor is only being updated once a person is no longer being detected by the camera. The "on" and "off" states are being updated simultaneously (with the same timestamp) only when the detection stops.

Screenshot 2024-09-02 164302
JamesToohey commented 2 months ago

Chiming in that I'm experiencing identical behaviour since updating Protect to 4.1.53 yesterday. "Person detected" events now turn on and off at the exact same time

sethkor commented 2 months ago

+1 for having this issue. I also noticed the Protect App seems to be not detcting it properly, perhaps only notfying after the event has ended.

Also: https://community.ui.com/questions/Changes-to-Protect-with-Detections-Break-Integrations/026d2cbc-43d2-4320-b58b-581ce8fc65a8?page=1

Since it also seems to be observed via the protect apps (event is not in app until after cleared) it would seem to be a bug

IvSan commented 2 months ago

@sethkor Nice catch with Ubiquiti forum question! Also your idea to submit a support ticket to Ubiquiti itself is probably the best.

webmogul1 commented 2 months ago

Hopefully this is something Ubiquiti will fix. Turning on lights when person is detected was really helpful. Not so, when person was detected.

kurtguy commented 2 months ago

I have worked out how to downgrade Unifi Protect back to 4.0.33. This fixed the issue for me, note that I am no expert so this is at your own risk but hopefully it may save you the couple of hours that I have spent on this today ... thankfully the Test Match was on to keep me sane [cricket]!

  1. Enable SSH in the Unifi Site Manager - Control Plane. Give it a password if you need to.
  2. Stop Unifi Protect in Site Manager
  3. Open a SSH terminal (I just use Window's CMD in administrator mode)
  4. root@192.168.1.30 (whatever the IP is of your CK / CK G2+)
  5. Enter your SSH password Type:
  6. unifi-os shell (not needed on UCKG2+)
  7. apt-get update
  8. apt-get install --reinstall --allow-downgrades unifi-protect=4.0.33 -y Give it a few minutes to run... it will go back to "root@Home:~#" once complete

Go back into Unifi Site Manager, refresh your page and you are back with Unifi Protect 4.0.33 which will have already started. 9. Switch off automatic updates! And disable SSH if you so wish.

Everything then worked again for me in HA. I hope this helps!

This worked for me. Thanks for the information <3

Still sucks that Unifi stuffed this up and now i cant update. Their chat support is hopeless and didnt know wtf i was talking about and now will apparently email me back with a better answer..... Maybe....

Lateralleap commented 2 months ago

If this is not an intentional change, which seems likely in terms of imact on the Protect App, then yet again it shows a really poor level of regression testing within Ubiquiti's release process...

I suspect it's part of their "fancy" new Alarm system. The Irony is that they have a popup that talks about how grea this will be for WebHook integrations :-)

This may be a silly suggestion... There is no way to get around the delay (without a time machine) but if this is intentional and won't get fixed, could the integration not turn the coincident (same timestamp) on/off event pair into a pseudo pair of events separated by a minimum duration that would give time for groups and automations to respond, possibly with a new (pseudo) entity_id to enable users to distinguish them?

Events that are not coincident could be passed through in case the behaviour changes in the future

sethkor commented 2 months ago

Honestly Unifis usual silence has been pretty pathetic in this instance. Im just rollingback.

GeeGee-be commented 2 months ago

Maybe upvoting the issue at UI community might help. I tried using Webhook via their new alarm manager and it's exactly the same. I get the detection. I'm guessing it's a bug in their new alarm manager and will need a fix, not only for the HA integration, but for any other. https://community.ui.com/questions/Changes-to-Protect-with-Detections-Break-Integrations/026d2cbc-43d2-4320-b58b-581ce8fc65a8?page=2

chasut commented 2 months ago

Maybe upvoting the issue at UI community might help.

Done! thanks.

My temporary workaround using the object_detected sensor is working fine for now, so I am not downgrading. I suspect they will fix it eventually, but It may take several cycles in EA before it is fully back.

I would love to have a nice chat with the engineering team that thought a fire alarm after the house burns down was a reasonable MVP. ugh.

starsoccer commented 2 months ago

Maybe upvoting the issue at UI community might help.

Done! thanks.

My temporary workaround using the object_detected sensor is working fine for now, so I am not downgrading. I suspect they will fix it eventually, but It may take several cycles in EA before it is fully back.

I would love to have a nice chat with the engineering team that thought a fire alarm after the house burns down was a reasonable MVP. ugh.

Any chance you can give an example of what your using as a work around for now?

jxlarrea commented 2 months ago

Maybe upvoting the issue at UI community might help.

Done! thanks. My temporary workaround using the object_detected sensor is working fine for now, so I am not downgrading. I suspect they will fix it eventually, but It may take several cycles in EA before it is fully back. I would love to have a nice chat with the engineering team that thought a fire alarm after the house burns down was a reasonable MVP. ugh.

Any chance you can give an example of what your using as a work around for now?

Just replace the Person Detected sensor for Object Detected in your automations or NodeRED.

Stewbo1 commented 2 months ago

Maybe upvoting the issue at UI community might help.

Done! thanks. My temporary workaround using the object_detected sensor is working fine for now, so I am not downgrading. I suspect they will fix it eventually, but It may take several cycles in EA before it is fully back. I would love to have a nice chat with the engineering team that thought a fire alarm after the house burns down was a reasonable MVP. ugh.

Any chance you can give an example of what your using as a work around for now?

Just replace the Person Detected sensor for Object Detected in your automations or NodeRED.

Do package smart detections activate this sensor as if they do it will create problems for some?

codyayers commented 2 months ago

It seems slower to me, but you can use Webhooks from the new Alarm Manager feature to trigger automations (Person Detected) in Home Assistant as a work around.

madsci1016 commented 2 months ago

Do we have an idea on what exact versions of Protect are currently "safe" from this issue? Any 4.0.x is ok?

blackdragon2300 commented 2 months ago

Do we have an idea on what exact versions of Protect are currently "safe" from this issue? Any 4.0.x is ok?

I rolled back to 4.0.33 for now. everything is back working. no issues sofar. there is a how to higher up in the thread

madsci1016 commented 2 months ago

Do we have an idea on what exact versions of Protect are currently "safe" from this issue? Any 4.0.x is ok?

I rolled back to 4.0.33 for now. everything is back working. no issues sofar. there is a how to higher up in the thread

Thanks. Thankfully thats what i'm on, i've been gun shy to ever update quickly since 4.0 broke alot of things and we lost a developer here. But i'm having stability issues in protect itself and was wondering if there was any version i could update too without breaking smart detections.

Seems like i just need to stay for now. Sigh. Ubiquiti is getting more frustrating every day.

tehzwen commented 2 months ago

It seems slower to me, but you can use Webhooks from the new Alarm Manager feature to trigger automations (Person Detected) in Home Assistant as a work around.

Yeah my first attempt was this but detection to notification time added an extra 5 to 10 seconds which was unusable for me so I downgraded to 4.0.33

bdraco commented 2 months ago

Good news. It looks like UI is looking into the issue https://www.reddit.com/r/Ubiquiti/comments/1fd6f87/open_letter_to_ubiquiti_fix_this_talk_to_us/

Lateralleap commented 2 months ago

That thread is encouraging (maybe) for long term but worrying in short term.

We need this fixed NOW whilst they work on their "grand plan for the future"

desigi commented 2 months ago

That thread is encouraging (maybe) for long term but worrying in short term.

We need this fixed NOW whilst they work on their "grand plan for the future"

My thoughts exactly. It's nice that they responded but they don't directly address the issue created from their last release.

mattstocum commented 2 months ago

For what it's worth, this seems to affect everything, not just the API HA is using. From my testing, WebHooks don't fire until the detection is complete, and more telling, even push notifications from the Protect app itself on iOS aren't firing until the notification is complete. If this was an intentional change by Ubiquiti, it was mind bogglingly stupid. What is the point of a push notification that tells you, "a package was at your front door, but no longer is there"?