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
74.07k stars 31.09k 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 3 months ago

IvSan commented 3 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

Stewbo1 commented 1 month ago

So my auto recovery issue (every 3 days or so) only started since I upgraded to Protect v5. My working assumption was that it was my Seagate 5gb 2.5” drive starting to fail after 2.5 years (the usual CKG2+ replacement drive issue) and I was just about to splash out for a WD Purple Pro and power supply/long SATA cable but maybe there is something else at play here if you are also seeing it since upgrading.

Safe/happy travels by the way.

VeniceNerd commented 1 month ago

So my auto recovery issue (every 3 days or so) only started since I upgraded to Protect v5. My working assumption was that it was my Seagate 5gb 2.5” drive starting to fail after 2.5 years (the usual CKG2+ replacement drive issue) and I was just about to splash out for a WD Purple Pro and power supply/long SATA cable but maybe there is something else at play here if you are also seeing it since upgrading.

Safe/happy travels by the way.

@Stewbo1 no no let me clarify! Here is what happened:

So at no point was I ever on 5.x. When this problem started for me (August 30th) I was on 3.x and I hadn’t done ANY upgrades to my system since April.

markpetrie1980 commented 1 month ago

I've got a few AI cameras with LPR detection running into HA, and a few different setups, all have the same symptoms - since 5.x it's never run properly, I've got one Camera that's facing a busy road so quite easy to test, symptoms are that via the "sensor.*_license_plate_detected" sensor it only triggers on around 10% of LPR detections.

bdraco commented 1 month ago

LPR detection reporting remains broken in the latest firmware

gionimi commented 1 month ago

I've got a few AI cameras with LPR detection running into HA, and a few different setups, all have the same symptoms - since 5.x it's never run properly, I've got one Camera that's facing a busy road so quite easy to test, symptoms are that via the "sensor.*_license_plate_detected" sensor it only triggers on around 10% of LPR detections.

same problems here

markpetrie1980 commented 1 month ago

I've got a few AI cameras with LPR detection running into HA, and a few different setups, all have the same symptoms - since 5.x it's never run properly, I've got one Camera that's facing a busy road so quite easy to test, symptoms are that via the "sensor.*_license_plate_detected" sensor it only triggers on around 10% of LPR detections.

same problems here

I'm not sure UI really know that this is outstanding, any thoughts on bringing it up specifically under the EA release topic in the UI forums?

Stewbo1 commented 1 month ago

So far 5.0.45 has been very stable.

  1. Smart detections coming through fine
  2. All the Protect Integration sensors have not randomly frozen and required disable/re-enable of the integration.
  3. Since I reset recording manager by applying the same rules to all of my cameras the daily Auto Recoveries have stopped happening (CKG2+).
mazdarx2001 commented 1 month ago

So far 5.0.45 has been very stable.

  1. Smart detections coming through fine
  2. All the Protect Integration sensors have not randomly frozen and required disable/re-enable of the integration.
  3. Since I reset recording manager by applying the same rules to all of my cameras the daily Auto Recoveries have stopped happening (CKG2+).

I'm still on Protect 4.0.33 and my automations with person detection work fine. Would you recommend using 5.0.45? Are the person detections still responsive and trigger every time effectively? Thanks!

markpetrie1980 commented 1 month ago

I'm not seeing any change with 5.0.45 for AI Detections - still very few LPR events hitting the HA sensor

almonie commented 1 month ago

I had the same issue. I fixed it by disabling and reenabling smart detections in the UniFi Protect app

Stewbo1 commented 1 month ago

I had the smart detections drop off again last night for about 8 hours. I know as I can see the smart detections in Protect but no sign of them in HA. Yet the Protect integration was not offline in HA at any time, and the data kept coming through for CPU and memory utilisation, but the smart detections were stuck on ‘off’. And the camera preview cards all grey but when clicked large the live feed resumes. Normal service resumed by itself.

I’m really struggling with how to diagnose this. Any help would be much appreciated.

HarlemSquirrel commented 1 month ago

I have a feeling this is the same underlying issue as https://github.com/home-assistant/core/issues/127764

It sounds like the API service on the Unifi device, unifi-core process, is crashing and restarting but doesn't properly reconnect to the unifi-protect process.

So I don't think this is really a home assistant issue but rather a Unifi issue. Has anyone reported this to Ubiquiti?

cholywell posted a workaround that they report is working for them so far: https://github.com/home-assistant/core/issues/127764#issuecomment-2436012299

VeniceNerd commented 1 month ago

I have a feeling this is the same underlying issue as #127764

It sounds like the API service on the Unifi device, unifi-core process, is crashing and restarting but doesn't properly reconnect to the unifi-protect process.

So I don't think this is really a home assistant issue but rather a Unifi issue. Has anyone reported this to Ubiquiti?

cholywell posted a workaround that they report is working for them so far: #127764 (comment)

@stewbo1 Do you think this is our issue, though, with the motion detection sensors to stop firing? It seems @cholywell also has issues with his camera streams stopping. That's never an issue for me. My camera streams always seem to work. It's just the motion detection sensors that are the issue.

Stewbo1 commented 1 month ago

I have a feeling this is the same underlying issue as #127764 It sounds like the API service on the Unifi device, unifi-core process, is crashing and restarting but doesn't properly reconnect to the unifi-protect process. So I don't think this is really a home assistant issue but rather a Unifi issue. Has anyone reported this to Ubiquiti? cholywell posted a workaround that they report is working for them so far: #127764 (comment)

@Stewbo1 Do you think this is our issue, though, with the motion detection sensors to stop firing? It seems @cholywell also has issues with his camera streams stopping. That's never an issue for me. My camera streams always seem to work. It's just the motion detection sensors that are the issue.

I’m not 100%. My video cards go grey during the sensor outages, but the RTSP feeds stay live. I didn’t have the insecure camera feed entities enabled like he has so have now enabled that and will watch for it dropping next time this happens.

Stewbo1 commented 1 month ago

Ok so it happened again this morning. The video feed did go offline, so the automation fired and let me know, which is good. However a single reload of the Protect integration was insufficient. Protect needed restarted and then the integration needed reloaded.

cefoster0 commented 1 month ago

I have a feeling this is the same underlying issue as #127764

It sounds like the API service on the Unifi device, unifi-core process, is crashing and restarting but doesn't properly reconnect to the unifi-protect process.

So I don't think this is really a home assistant issue but rather a Unifi issue. Has anyone reported this to Ubiquiti?

cholywell posted a workaround that they report is working for them so far: #127764 (comment)

I only have the LPR issue mentioned in the new title and the above workaround doesn't seem to help with that. Never see my instance go to 'unavailable' but no LPR alerts for sure.

mazdarx2001 commented 1 month ago

Same, my integration seems to work well for the most part.-Steve Swanson On Oct 28, 2024, at 6:53 AM, cefoster0 @.***> wrote:

I have a feeling this is the same underlying issue as #127764 It sounds like the API service on the Unifi device, unifi-core process, is crashing and restarting but doesn't properly reconnect to the unifi-protect process. So I don't think this is really a home assistant issue but rather a Unifi issue. Has anyone reported this to Ubiquiti? cholywell posted a workaround that they report is working for them so far: #127764 (comment)

I only have the LPR issue mentioned in the new title and the above workaround doesn't seem to help with that. Never see my instance go to 'unavailable' but no LPR alerts for sure.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

cholywell commented 1 month ago

I posted to the Ubiquiti Community about the errors I found on the CloudKey.

https://community.ui.com/questions/Unifi-Protect-API-crashes-knock-Home-Assistant-connection-offline/7140d950-c058-40f3-abf8-2f9cfb3294ed

VeniceNerd commented 1 month ago

I just want to point out that I’m running on UniFi NVR and not the cloud key like you guys. So this issue does not seem to be specific to cloud key.

Message ID: @.***>

markpetrie1980 commented 1 month ago

I just want to point out that I’m running on UniFi NVR and not the cloud key like you guys. So this issue does not seem to be specific to cloud key. Message ID: @.***>

I can second this, it's happening to me on the UNVR Pro - I have not done anywhere near the same detail of troubleshooting, but I have seen if the connection between HA and the UNVR is interrupted then it detections start again for a short period, the same when HA is restarted.

Stewbo1 commented 1 month ago

I just want to point out that I’m running on UniFi NVR and not the cloud key like you guys. So this issue does not seem to be specific to cloud key. Message ID: @.***>

I can second this, it's happening to me on the UNVR Pro - I have not done anywhere near the same detail of troubleshooting, but I have seen if the connection between HA and the UNVR is interrupted then it detections start again for a short period, the same when HA is restarted.

Thanks. Would you mind adding to the post on the UI Forum please as we need UI to see it is worth them looking into.

I only have the LPR issue mentioned in the new title and the above workaround doesn't seem to help with that. Never see my instance go to 'unavailable' but no LPR alerts for sure.

Yes there’s two issues on the go in this thread I sympathise. Both starting from the 4.X update. I haven’t seen anyone drill into the NPR issue in depth yet. I don’t have an AI camera so can’t opine, sorry.

gionimi commented 4 weeks ago

Protect updated to version 5.0.47, and the issues persist.

markpetrie1980 commented 3 weeks ago

Protect updated to version 5.0.47, and the issues persist.

It's also still persistent on 5.0.50 EA. I doubt that it's close to even being a high priority for UI's dev's being a niche userbase so maybe if a few of us could continue to post on the UI forums as well. I've put a post on the EA 5.0.50 Protect forum too.

It is something that they will eventually need to fix.. so may as well do it sooner than later :) so some gentle pressure could help (as long as the fix is not removing the local API!)

gionimi commented 3 weeks ago

I have already posted in all the forums I know, and I don’t know who else to ask for help. Until the Unifi integration developer dedicates time to fixing this, we won’t have a solution anytime soon.

bdraco commented 3 weeks ago

This integration is looking for a maintainer. However, in this case it won't help because the problem needs to be fixed by UI since they are the ones that made the change that broke LPR detection.

HarlemSquirrel commented 3 weeks ago

Ideally there would be a contact at Ubiquiti dedicated to supporting the smart home but right now it seems like this segment of their business is low priority.

gionimi commented 3 weeks ago

Ubiquiti told me that it doesn’t support third-party integration. It seems to me that this is something that will need to be adjusted within the integration, not in the Protect API

HarlemSquirrel commented 3 weeks ago

Ubiquiti told me that it doesn’t support third-party integration. It seems to me that this is something that will need to be adjusted within the integration, not in the Protect API

I thought we decided that the problem lies with the Unifi local API which can only be fixed by Ubiquiti since their software is not open source.

cefoster0 commented 3 weeks ago

Ubiquiti told me that it doesn’t support third-party integration. It seems to me that this is something that will need to be adjusted within the integration, not in the Protect API

I thought we decided that the problem lies with the Unifi local API which can only be fixed by Ubiquiti since their software is not open source.

I haven't looked at the code, does this integration using a private API or a public one? I imagine corporate customers wouldn't like it broken either.

gionimi commented 3 weeks ago

@HarlemSquirrel sincerely, I'm not sure if this is our decision to make, I just shared my attempts and what was passed on to me. Ubiquiti has always told me that they don't provide any support for integration or third-party software. They only offer support for hardware and the Protect application.

gionimi commented 3 weeks ago

@cefoster0 I believe it is private.

gionimi commented 3 weeks ago

@HarlemSquirrel look this answer Sem título

HarlemSquirrel commented 3 weeks ago

Yes, UI doesn't support home assistant. That is the wrong way to ask for help from them.

There is already an issue open with them to address the crashing.

Read the other posts in this issue, especially this one: https://github.com/home-assistant/core/issues/124967#issuecomment-2443552799

lopanwang commented 2 weeks ago

I found another workaround to get LPR to work. The G4 Doorbell Pro fingerprint and NFC readers were finally activated in the EA release of UniFi Protect Application 5.1.34. To get it to work with HA, you have to use Unifi Protect Alarm Manager and webhooks. Seeing that it worked, I decided to try the LPR detection and am happy to say it works now!

Here's how I did it:

  1. In HA create a new automation. Click Trigger -> other triggers -> Webhook (all the way at the bottom)

  2. HA will automatically assign a random Webhook ID #. I believe you can change it to whatever you want.

  3. A simple Then Do action send to Open your garage/gate and of course another automation with the same assigned Webhook ID # to Close. Add any conditions you may require.

  4. Now in Unifi Protect Alarm Manager, you can either create a new alarm or use the system made one, Vehicle of interest.

  5. The Trigger is LPR ID and check Vehicle of Interest. This requires you to appoint the vehicles you want to trigger the automation. I don't see a way where you can manually input a specific license plate # like we used to do it in HA.

  6. In Target, include the LPR camera (e.g. AI Pro)

  7. In Action, select Webhook and change Slack Post to Custom Webhook

  8. For Delivery URL, you want to use your IP address where HA is connected to including port number. It should look like this "http://YourHAIPAddress:8123/api/webhook/YourWebhookID"

  9. Still in the Action portion, check the Advanced Settings and the Method is POST

If this doesn't work, you may need to do a reset in Alarm Manager which is located in the upper right corner. You probably should click on it first before doing all this as it will reset any custom alarms. Hope this helps!

markpetrie1980 commented 1 week ago

I found another workaround to get LPR to work. The G4 Doorbell Pro fingerprint and NFC readers were finally activated in the EA release of UniFi Protect Application 5.1.34. To get it to work with HA, you have to use Unifi Protect Alarm Manager and webhooks. Seeing that it worked, I decided to try the LPR detection and am happy to say it works now!

Here's how I did it:

  1. In HA create a new automation. Click Trigger -> other triggers -> Webhook (all the way at the bottom)
  2. HA will automatically assign a random Webhook ID #. I believe you can change it to whatever you want.
  3. A simple Then Do action send to Open your garage/gate and of course another automation with the same assigned Webhook ID # to Close. Add any conditions you may require.
  4. Now in Unifi Protect Alarm Manager, you can either create a new alarm or use the system made one, Vehicle of interest.
  5. The Trigger is LPR ID and check Vehicle of Interest. This requires you to appoint the vehicles you want to trigger the automation. I don't see a way where you can manually input a specific license plate # like we used to do it in HA.
  6. In Target, include the LPR camera (e.g. AI Pro)
  7. In Action, select Webhook and change Slack Post to Custom Webhook
  8. For Delivery URL, you want to use your IP address where HA is connected to including port number. It should look like this "http://YourHAIPAddress:8123/api/webhook/YourWebhookID"
  9. Still in the Action portion, check the Advanced Settings and the Method is POST

If this doesn't work, you may need to do a reset in Alarm Manager which is located in the upper right corner. You probably should click on it first before doing all this as it will reset any custom alarms. Hope this helps!

It is a way to "work around" instead of using the integration, the only thing I find is that it's quite slow compared to using the sensor integration, which is a bit of a pain for time sensitive, for example LPR to open a gate.