Closed Mulle00 closed 2 years ago
unifiprotect documentation unifiprotect source (message by IssueLinks)
Hey there @briis, @angellusmortis, @bdraco, mind taking a look at this issue as it has been labeled with an integration (unifiprotect
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
Not really a bug or anything we can do about. We cannot control the timestamps HA sets for state changes. And HA is single threaded, async and integrations have no control over the event loop. So the Websocket message is sent to HA right away, but depending on the load on your server, it may take it a few seconds to process the message.
If you enable debug logging you can see when the Websocket message is processed.
If there is a 4 to 5 second delay you likely have blocking I/o in your event loop
Turn on debugpy in your configuration.yaml and restart
It is only with the 'Detected object' that there is a delay. All other sensors work perfectly like motion and doorbell ring (and all the other integrations).
It could also be that Unfi Protect (not the integration) takes a bit more time to detect something like 'person' or 'vehicle' and so is a bit slower to pass the data to the integration.
I have added 2 examples. The 'motion' sensor is perfect on time. The 'detected object' is with a lot of delay.
HA has enough memory and cpu. Only 3% CPU usage
Motion sensor : OK
Detected object : delayed
.
Smart detections are not treated any differently than any other sensor in HA. If they are then only sensor being delayed, it is not coming from HA or the HA integration. It is coming from UniFi Protect.
In UniFi Protect, smart detect events are child events for motion events, so UniFi Protect might be reporting the start of the motion event, not the smart detect event and not telling you when the smart detect event was actually started.
The problem
There is a delay of 4 to 5 seconds that sensor 'Detected Object' is triggered in HA. When using this sensor to take a snapshot, it is always too late. Time between HA and Unifi Protect is fully in sync.
Example: Unifi Protect on my cloud key see the person at 10:45:31 AM, the sensor 'Detected Object' in HA is triggered at 10:45:35 AM.
What version of Home Assistant Core has the issue?
core-2022.2.7
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
Unifi Protect
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