twrecked / hass-aarlo

Asynchronous Arlo Component for Home Assistant
GNU Lesser General Public License v3.0
395 stars 78 forks source link

Identify object *during* event - not after? #359

Open TheDK opened 3 years ago

TheDK commented 3 years ago

As discussed a couple of weeks ago Arlo transmits the object identified when a new recording is broadcast over the stream:

{'contentType': 'video/mp4',
           'createdBy': '',
           'createdDate': '20201206',
           'currentState': 'new',
           'deviceId': '',
           'donated': False,
           'lastModified': 1607258019142,
           'localCreatedDate': 1607257984967,
           'mediaDuration': '00:00:32',
           'mediaDurationSecond': 32,
           'meta': {'bit_rate': '774189\n',
                    'codec_tag_string': 'avc1',
                    'height': '1072',
                    'width': '1920'},
           'name': '',
           **'objCategory': 'Person',**
           'objRegion': '0.230,0.182,0.334,0.561',
...
           'reason': 'motionRecord',
           'timeZone': 'Europe/Amsterdam',
           'uniqueId': '',
           'utcCreatedDate': 1607257984967}

I was toying with the idead of building some "self defense" for the house - meaning that for example when a person is detected in my yard I will turn on the lights inside and outside, lower blinds, etc. --> Thanks to HA there are no limits set to what you can do. I would not want to do the same with animals, but I noticed that Arlo Smart has become pretty consistent at telling cats apart from moving branches and people working around.

The problem is that currently the oject info is only delivery together with the recording (see above), so when the event is over, which is a bit late.

As the push notification of the Arlo contains this info shortly after the event has started (in my tests 5-10 seconds) I was wondering if it was also trasmitted over the stream but couldn't find anything:

2020-12-06 13:33:05 DEBUG (ArloEventStream) [pyaarlo] packet-in=
{ 'action': 'is',
  'from': '',
  'properties': { 'activityState': 'alertStreamActive',
                  'dateStarted': 1607257984959},
  'resource': 'cameras/3',
  'transId': ''}

2020-12-06 13:33:05 DEBUG (ArloEventStream) [pyaarlo] packet-in=
{ 'action': 'is',
  'from': '',
  'properties': {'motionDetected': True},
  'resource': 'cameras/',
  'transId': ''}

2020-12-06 13:33:36 DEBUG (ArloEventStream) [pyaarlo] packet-in=
{ 'action': 'is',
  'from': '',
  'properties': {'motionDetected': False},
  'resource': 'cameras/',
  'transId': ''}

As far as I can tell I cranked logging up to max so it might be possible that Arlo is simply giving that information only on the service the app / the notifications are using.

@twrecked Do you have an idea where I could keep loking for the information?

If it can be read from somewhere best case would be to add this information as attributes to the binay sensors for movement or recent activity to use it as a trigger or a condition in automations.

twrecked commented 3 years ago

When looking for stuff I always open the debug console on a browser. I use chrome and CTRL+SHIFT+I. If you can't see what you need there we can't generally get at it.

And as you've noticed the mobile app is privy to more information than the web interface.

twrecked commented 3 years ago

@TheDK Sorry to piggy back of this but I don't know of a better way to message you. You updated the docs to say that 2FA worked in German, can I assume you speak German? If so, can you help out with this, I think he's having a config issue: https://github.com/twrecked/hass-aarlo/issues/383

TheDK commented 3 years ago

No problem, I just answered. I still have to look into this one here, but didn't have the time to fight myself through the debug...

twrecked commented 3 years ago

Thank you for doing that!

And I've actually gotten time to look at some stuff recently, and this enhancement is definitely on my list. I've also squashed a ton of little bugs that might explain some of the problems other people were seeing...

But if you're feeling brave and you use the aarlo Lovelace card, I've just re-written the thing and released a v0.2, feedback appreciated. One immediate change is it highlights the "thing" that triggered the event.

Another thing is it supports localisation, if you get time could you add a translation? It's pretty obvious, you just need to translate the English strings in en.js

https://github.com/twrecked/lovelace-hass-aarlo/tree/master/lang
TheDK commented 3 years ago

I can say the integration works absolutely stable for me in the last couple of weeks, incl. 2FA via mail. Sometimes recordings were missing in the grid view, but I saw in one of the release notes that you worked on that, so I will keep an eye out...

I will test the new Lovelace card in the next couple of weeks, just need to find time to check it out if anything breaks...

With regard to translations: From what I gather in the fs.js file I just create a file de.js that looks like that?

var messages = {

        turn_camera_on: 'Kamera einschalten',
        turn_camera_off: 'Kamera ausschalten',
}

Or do I need to reference the image / library / ... somehow?

Or just fork and rename en.js and translate everything after the : ?

twrecked commented 3 years ago

Thanks your help with this.

For the translation you just need to create a file called de.js and replace the strings inside quotes, you don't need to change image/library/... or any of that. That's just so I can keep the code more readable.

TheDK commented 3 years ago

I just got around to it and submitted a PR for the German localization.

lhart-intelycare commented 1 year ago

I'll just add that I'm very interested in this as well and for a project similar to the one that @TheDK described. I have deer that like to eat my yard's flowers in the early morning hours. I plan on creating a node-red flow that would trigger off an "arlo has detected an animal" event, triggering the Rachio irrigation zone to turn on and squirt the suckers. Happy to help debug/beta test if you need it. I have Arlo Pro 4 cameras. Thanks!

TheDK commented 1 year ago

I went through that and did not find anything in the messages at the time with regard to what was detected. Since the change to MQTT that might have changed - feel free to poke around.

After Arlo pissed me off with ever higher pricing for cameras and plans while having mediocre quality at best I have switched to Reolink cams, BlueIris and CodeProject AI. It is a bit of work and not for everyone as it basically requires a Windows PC as server. Anyway - I have shut down Arlo for good, so I can’t help…