hass-aarlo icon indicating copy to clipboard operation
hass-aarlo copied to clipboard

Better response time for last_arlo_x or service to poll status

Open broomeydj opened this issue 1 year ago • 13 comments

I have noticed that there is a significant lag between other arlo entities and the last_arlo_x entity getting refreshed. This results in me having to use wait templates that can often take over a minute to poll the last_arlo_x status where my phone is pining the alert from alro with with detected object type.

Is this a limitation of the web api? - would it be possible to have a service that polls the object detection so I can poll rather than wait?

broomeydj avatar Mar 16 '23 14:03 broomeydj

It's a limitation of the API. What we get is:

  • motionDetected: True
  • activityState: streamActive
  • motionDetected: False
  • activityState: idle

And after that we get a resource: mediaUploadNotification, when we see that the video is ready, that's when we update the last_ entries because that is the first time we see the object type.

What is your automation doing? There might be something else we can hook into or a tweak we can make.

edit: Take a look at the media_retry option, it could speed things up.

twrecked avatar Mar 16 '23 16:03 twrecked

ah. that explains the inconsistent delays! - most of my cameras are set to record for 30 seconds, but sometimes it takes ages with cameras set to dynamic recording.

this is a shame, although the API must have some hidden code because the native app and IFTTT don't seem to suffer this delay. In-fact if it wasn't for the high cost with IFTTT I would use a web hook trigger from that.

broomeydj avatar Mar 16 '23 19:03 broomeydj

They might add something down the road but we are limited by the web API. I think IFTTT, Smartthings and the native app get access to a different API completely. If you are comfortable with a browser you can look at the packets coming and going (CTRL+SHIFT+I) and try to spot something useful, different users sometimes have different web calls. We just need 1 example of packet getting the object type to make this work.

What are you trying do?

twrecked avatar Mar 16 '23 19:03 twrecked

Sure. I am quite familiar with packet tracers and stuff like Fiddler and Google Chrome dev so I will see what I can find out. Regarding my use case. I have an extensive network or arlo cameras monitoring my farm and I have an automation that works out activity in various zones and then announces via alexa. Something I have been building for a while, once I can get rid of the false positives I can also get it to play alarms.

Based on your comments I might try the native detection in Home Assistant. I will likely have the same issue of needing the full recording though. Although my other thoughts are to se the Arlo recordings to their minimum duration and then maybe make longer recordings in Home Assistant. it's a massive WIP but I can share my scripts once it's complete.

broomeydj avatar Mar 16 '23 20:03 broomeydj

One thing is you can do is take a snapshot while the device is still recording and that image will appear pretty quickly. The Arlo integration will fire a snapshot ready event when it has finished. You could have an automation that asks for a snapshot when motion is detected.

That snapshot might have the object in it, I was thinking of doing this and feeding into some image recognition software - I was trying to spot my son's school bus coming up the road - I just never got the time do it.

twrecked avatar Mar 16 '23 20:03 twrecked

thanks. i might give that a go. My plan is to make this quite modular. so I will update a custom object that represents the object in the area and have this reset after a time (the last object just holds the last detected object) - that way my automation can key off the object in area for x seconds and it also means later on I can improve the logic that feeds the custom object and not have to worry about recoding any automations.

i think knowing how the last variable works has been a big clue. I have already dropped the recording time on my test camera to 10 seconds and I am now getting very consistent results with my automation.

broomeydj avatar Mar 16 '23 21:03 broomeydj

This one affects me too. I created an automation for when the camera detects a person at my front door it announces it inside on various devices. The camera detects a person coming down the path to the door and I was thinking it would make the announcement then but it doesn’t. Your explanation reveals why. I don’t think there is any other way to do it if I only want it to trigger on a person and not spiders in the middle of the night.

dw1562 avatar Mar 29 '23 07:03 dw1562

Setting the record time to 10 seconds gives me the right balance for notifications and recordings. I find that arlo cameras will retrigger and record motion often so you don't miss too much in terms of video footage.

I have a separate automation that puts the cameras in a different alarm mode so recordings last as long a necessary, since recordings are more important than realtime notifications when I am asleep!

I am currently working on a template sensor to group multiple cameras and cut down on re-trigger notifications by smoothing out the object alerts.

broomeydj avatar Mar 29 '23 08:03 broomeydj

I have similar needs. I use a Doorbell and I'd like to turn on the lights when someone is coming on my front door. Right now it takes more than 30s to trigger the automation...

Aymkdn avatar Nov 09 '23 18:11 Aymkdn

@Aymkdn if you don't mind some false positives then motion detection is pretty quick.

I've been updating the code recently so I'll see if I can improve this but don't hold out too much hope, I think the API is going to hold us back.

twrecked avatar Nov 09 '23 19:11 twrecked

Thanks for the quick reply and amazing library!

I don't want to trigger on motion because at some point I want to turn the door alarm on, and turn on a light inside the house (when someone is there during the night). Obviously I don't want a cat or a car to trigger it 😅 But I may have some ideas to mitigate it.

Aymkdn avatar Nov 09 '23 19:11 Aymkdn

@twrecked do you think using db_motion_time will help in anyway? I'm not sure to understand what this parameter is doing…

Aymkdn avatar Nov 10 '23 08:11 Aymkdn

@broomeydj did you figure out how to react only on Person-events in ifttt? I haven't seen anything like that there... just "motion" as an event which does not really help :/

chaelli avatar Jan 15 '24 20:01 chaelli