twrecked / hass-aarlo

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

Snapshots #276

Open damien67 opened 4 years ago

damien67 commented 4 years ago

Hey everyone, I am pulling my hair with snapshots... First of all, one question:

Do you need to execute aarlo.camera_request_snapshot before executing aarlo.camera_request_snapshot_to_file ??

I am simply trying to get the following accomplished:

Is it possible? Can the camera record and take a snapshot at the same time (this seems to be an issue on 6.9x versions) I just installed Alpha6, and do not see improvements. (I had read that an overall was done in regards to snapshots). It may even be worse now... Problem is, whatever service I call, I get the same UPS guy in my front lawn, who is long gone!

Also, when renaming a camera name in the Arlo app, how can we have the new name updated in HA?

Here is the automation yaml...

- id: '1592328668176'
  alias: alarm_frontdoor
  description: ''
  trigger:
  - entity_id: camera.aarlo_living_room
    platform: state
    to: recording
    for: 00:00:03
  condition: []
  action:
  - data:
      filename: www/file.jpg
    entity_id: camera.aarlo_living_room
    service: aarlo.camera_request_snapshot_to_file
  - delay: 00:00:06
  - data:
      data:
        attachment:
          hide-thumbnail: false
          url: https://xxxxx.duckdns.org/local/file.jpg
      message: 'Front door: Motion Detected'
    service: notify.mobile_app_xxxx

Thanks for your help as always!!! Damien

twrecked commented 4 years ago

Sorry for the issues. What version of Aarlo are you on?

damien67 commented 4 years ago

Nothing to be sorry about, I love your work, and you've always been super responsive and helpful! I was on 0.6.19.1, and I just upgraded to 0.7.0 Alpha6.

So here, I live in Georgia, it is almost 10PM, so it is night time. I call:

aarlo.camera_request_snapshot
entity_id: camera.aarlo_living_room

The HA Aarlo Lovelace card goes from:

But as you can see the card picture is still daylight, and picture has not updated.

Then I call: aarlo.camera_request_snapshot_to_file entity_id: camera.aarlo_living_room filename: 'www/testfile.jpg'

File doesn't exist, to make sure I don't run into overwriting existing files and possibly troubleshooting another issue. I wait a few seconds and browse to ***.duckdns.org/local/testfile.jpg. Here is the result:link

Am I not understanding the aarlo.camera_request_snapshot and aarlo.camera_request_snapshot_to_file services? What I am expecting is for them to take a snapshot for "right now".

Thank you!

twrecked commented 4 years ago

Picture update:

Service call:

The service calls will take a snapshot of right now. Arlo doesn't provide a simple snapshot mechanism so the calls have to do some intermediary steps:

The 2 services start the same way but the request_to_file service waits for the snapshot to finish and will write it out to a file. If the snapshot fails no file is written.

One other thing to check is the your file permissions. You have to whitelist the directory you are writing to.

homeassistant:
  ...
  whitelist_external_dirs:
    - /www

Naming

Yeah, this is a bit of pain. If you renamed your camera you might have a new entity with a new name. Checking the debug in config/homeassistant.log will help, you will see a list of cameras created. Look for lines like this near the top of the debug.

2020-07-03 09:41:59 DEBUG (SyncWorker_36) [pyaarlo] set:ArloCamera/4NXXXXXXXXX/deviceId=4N71687207851
2020-07-03 09:41:59 DEBUG (SyncWorker_36) [pyaarlo] set:ArloCamera/4NXXXXXXXXX/deviceName=Garage Camera
2020-07-03 09:41:59 DEBUG (SyncWorker_36) [pyaarlo] set:ArloCamera/4NXXXXXXXXX/deviceType=camera

I did create a version where you can request device_id for the entity ids but it fell behind when I started on 0.7.

damien67 commented 4 years ago

Steve, sorry for the delay. I will get back with you later today on those. Weekends are always super busy with the family!

damien67 commented 4 years ago

Ok! Finally got some time!

  1. Yes, I called the service, image wasn't updated. I rebooted HA and image did update.
  2. Yes, 1.1 was installed when I checked
  3. Now you are mentioning this, yes, seems like this specific camera has not updated. Last available videos in the library were from this weekend. Few recording were made today, and I can't see them. Once I rebooted all today's recordings were available.
  4. Ok, logs enabled

Thanks for the additional information about services. This is how I understood them in the first place, but I wasn't certain as I was troubleshooting. The permissions shouldn't be an issue, I am able to write files to the directory calling request_to_file.

So, after all this, I called the service again, and no change. I actually cannot find "mediaUploadNotification" in my logs. For peace of mind, I also tested another Arlo camera, and got the exact same result. Image doesn't update, I get the picture as a jpg in my www folder, but actual picture is from last motion detection (not now).

What do you think? Any other info I could get you from the logs? I am willing to troubleshoot this further. We could even do a remote session if that'd help.

Thanks!

dermotduffy commented 4 years ago

Long time (aarlo) listener, first time (snapshot) caller -- FWIW, I believe I am experiencing the same behavior that @damien67 describes. It will create the snapshot file, but it will be a previous image the camera took (earlier in the day). The media_retry does not appear to make a material difference, it won't update from that earlier state.

@twrecked I'll email you some logs.

twrecked commented 4 years ago

It's stopped working here too, I'll investigate it.

But also - holy crap, they've changed the way streaming works, we can directly stream from Arlo now...

ajcooper72 commented 4 years ago

Sorry, deleted my post as it had one of my camera ID's in.

here's a cleaner log if needed

2020-07-14 16:45:14 DEBUG (MainThread) [custom_components.aarlo.camera] request_snapshot_image for garden 2020-07-14 16:45:14 DEBUG (SyncWorker_0) [pyaarlo] _start_stream2::activities={'snapshot-stream'} 2020-07-14 16:45:14 DEBUG (SyncWorker_0) [pyaarlo] post+response running 2020-07-14 16:45:14 DEBUG (ArloEventStream) [pyaarlo] sending cameras/xxxxxxxxxxxxx to xxxxxxxxxxxxx 2020-07-14 16:45:14 DEBUG (ArloEventStream) [pyaarlo] Garden CAMERA got one cameras/xxxxxxxxxxxxx 2020-07-14 16:45:14 DEBUG (ArloEventStream) [pyaarlo] set:ArloCamera/xxxxxxxxxxxxx/activityState=startUserStream 2020-07-14 16:45:14 DEBUG (ArloEventStream) [custom_components.aarlo.camera] callback:Garden:activityState:startUserStream 2020-07-14 16:45:17 DEBUG (SyncWorker_0) [pyaarlo] url=rtsps://arlostreaming90-z3-prod.wowza.arlo.com:443/vzmodulelive/xxxxxxxxxxxxx_1594741514696?egressToken=xxxxxxxxxxxxx&userAgent=iOS&cameraId=xxxxxxxxxxxxx_1594741514696 2020-07-14 16:45:17 DEBUG (SyncWorker_0) [pyaarlo] waiting for stream 2020-07-14 16:45:17 DEBUG (ArloEventStream) [pyaarlo] sending cameras/xxxxxxxxxxxxx to xxxxxxxxxxxxx 2020-07-14 16:45:17 DEBUG (ArloEventStream) [pyaarlo] Garden CAMERA got one cameras/xxxxxxxxxxxxx 2020-07-14 16:45:17 DEBUG (ArloEventStream) [pyaarlo] _event::stream::activities={'user-stream-active', 'snapshot-stream'} 2020-07-14 16:45:17 DEBUG (ArloEventStream) [pyaarlo] set:ArloCamera/xxxxxxxxxxxxx/activityState=userStreamActive 2020-07-14 16:45:17 DEBUG (ArloEventStream) [custom_components.aarlo.camera] callback:Garden:activityState:userStreamActive 2020-07-14 16:45:17 DEBUG (SyncWorker_0) [pyaarlo] got True 2020-07-14 16:45:19 DEBUG (SyncWorker_0) [pyaarlo] request_snapshot::activities={'user-stream-active', 'snapshot', 'snapshot-stream'} 2020-07-14 16:45:19 DEBUG (SyncWorker_0) [pyaarlo] streaming/recording snapshot 2020-07-14 16:45:19 DEBUG (SyncWorker_0) [pyaarlo] set:ArloCamera/xxxxxxxxxxxxx/activityState=fullFrameSnapshot 2020-07-14 16:45:19 DEBUG (SyncWorker_0) [custom_components.aarlo.camera] callback:Garden:activityState:fullFrameSnapshot 2020-07-14 16:45:19 DEBUG (SyncWorker_0) [pyaarlo] handle dodgy cameras 2020-07-14 16:45:19 DEBUG (ArloBackgroundWorker) [pyaarlo] post+response running 2020-07-14 16:45:22 INFO (MainThread) [homeassistant.components.esphome] Can't connect to ESPHome API for 192.168.86.22: Error connecting to ('192.168.86.22', 6053): [Errno 113] Connect call failed ('192.168.86.22', 6053) 2020-07-14 16:45:22 INFO (MainThread) [homeassistant.components.esphome] Trying to reconnect in 60 seconds 2020-07-14 16:45:49 DEBUG (ArloEventStream) [pyaarlo] sending cameras/xxxxxxxxxxxxx to xxxxxxxxxxxxx 2020-07-14 16:45:49 DEBUG (ArloEventStream) [pyaarlo] Garden CAMERA got one cameras/xxxxxxxxxxxxx 2020-07-14 16:45:49 DEBUG (ArloEventStream) [pyaarlo] got a stream/recording stop 2020-07-14 16:45:49 DEBUG (ArloEventStream) [pyaarlo] queueing update in 15 2020-07-14 16:45:49 DEBUG (ArloEventStream) [pyaarlo] resetting activity state 2020-07-14 16:45:49 DEBUG (ArloEventStream) [pyaarlo] _event::idle::activities=set() 2020-07-14 16:45:49 DEBUG (ArloEventStream) [pyaarlo] turning recent ON for Garden 2020-07-14 16:45:49 DEBUG (ArloEventStream) [custom_components.aarlo.camera] callback:Garden:recentActivity:True 2020-07-14 16:45:49 DEBUG (ArloEventStream) [pyaarlo] set:ArloCamera/xxxxxxxxxxxxx/activityState=idle 2020-07-14 16:45:49 DEBUG (ArloEventStream) [custom_components.aarlo.camera] callback:Garden:activityState:idle 2020-07-14 16:45:59 DEBUG (ArloBackgroundWorker) [pyaarlo] turning recent OFF for Garden 2020-07-14 16:45:59 DEBUG (ArloBackgroundWorker) [custom_components.aarlo.camera] callback:Garden:recentActivity:False 2020-07-14 16:46:00 DEBUG (ArloBackgroundWorker) [pyaarlo] fast refresh 2020-07-14 16:46:00 DEBUG (ArloBackgroundWorker) [pyaarlo] day testing with 2020-07-14! 2020-07-14 16:46:10 DEBUG (ArloBackgroundWorker) [pyaarlo] pinging Arlo 2020-07-14 16:46:10 DEBUG (ArloBackgroundWorker) [pyaarlo] notify+response running 2020-07-14 16:46:10 DEBUG (ArloBackgroundWorker) [pyaarlo] post+response running 2020-07-14 16:46:10 DEBUG (ArloBackgroundWorker) [pyaarlo] set:ArloBase/4Rxxxxxxxxxxx/connectionState=available 2020-07-14 16:46:10 DEBUG (ArloBackgroundWorker) [pyaarlo] queueing image library update 2020-07-14 16:46:12 DEBUG (ArloBackgroundWorker) [pyaarlo] updating image library 2020-07-14 16:46:12 DEBUG (ArloBackgroundWorker) [pyaarlo] post+response running 2020-07-14 16:46:12 DEBUG (ArloBackgroundWorker) [pyaarlo] ml:update-count=2 2020-07-14 16:46:12 DEBUG (ArloBackgroundWorker) [pyaarlo] getting media image for Garden 2020-07-14 16:46:12 DEBUG (ArloBackgroundWorker) [pyaarlo] reloading cache for Garden 2020-07-14 16:46:12 DEBUG (ArloBackgroundWorker) [pyaarlo] set:ArloCamera/xxxxxxxxxxxxx/capturedToday=0 2020-07-14 16:46:12 DEBUG (ArloBackgroundWorker) [custom_components.aarlo.sensor] callback:Captured Today Garden:capturedToday:0

damien67 commented 4 years ago

But also - holy crap, they've changed the way streaming works, we can directly stream from Arlo now...

Would you mind summarizing what it means and what makes it different than before?

twrecked commented 4 years ago

Just to re-iterate, I think has stopped working because Arlo has changed their behavior. If I start a stream on the arlo website and take a snapshot nothing updates there as well. I will look into how to get this to work.

@damien67 For the current streaming we ask Arlo to start a stream and pass the returned URL into Home Assistant and it converts the stream into a HLS stream. It looks like we can get the HLS stream directly from Arlo so removes some load from the Home Assistant devices. Means we can probably get the Arlo Ultra cameras working.

w00master commented 4 years ago

Hey folks, I'm having this snapshot issue as well, and my issues extend to motion sensors as well. Everything else, however, works for me: camera, last activity, battery level, sound, connected arlo hub/camera. I've tried updating multiple times. Logs also seem to not be helpful either, all it says for these (example: motion sensor) is "Unavailable" and now being "disabled."

Have I missed something? This happened to me when I updated from .111 to .112 (now on .113)

2020-07-25 16:06:36 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.aarlo_motion_backyard_center, old_state=None, new_state=<state binary_sensor.aarlo_motion_backyard_center=unavailable; restored=True, supported_features=0, device_class=motion @ 2020-07-25T16:06:36.401744-04:00>>

twrecked commented 4 years ago

I'll get a chance to look at this one this week. I swear I had all this working great in 0.7 so I'm going to ahead and blame changes in the back end!

w00master commented 4 years ago

I'll get a chance to look at this one this week. I swear I had all this working great in 0.7 so I'm going to ahead and blame changes in the back end!

Love your custom component man. Thanks for all the help. Some additional info that may help: I'm using Arlo Pro 2 cameras and the Arlo Pro 2 hub.

iannecj commented 4 years ago

First thanks @twrecked for this fantastic work. Been watching this issue. I think there are at least 2 issues here. One can be handled with timing. In the automation below, I trigger on recording, call snapshot to file, and use the token to get the picture id api url.

I send a notification with the time of the last image as aarlo sees it and manual snapshot url, I also send url to picture entity with token.

The picture entity matches my.arlo.com website everytime and its relatively quick but as others have said token expires fairly quickly so if you don't click on that link in notification in like a minute, the token has expired.

Now the snap shot that was taken manually also has a url in notification. when I click on that I notice the local file date/time is often not updated. Even if I wait for the file to update date/time locally (as seen in windows explorer) and then goto the local snapshot link its often an old file. If I continue to hit refresh on browsers...sometimes 5-10 seconds....the local snapshot displayed eventually matches the image that I saw on my.arlo and saw with the short lived token link.


- id: '1578507691474'
  alias: AArlo_Motion_Detected_No_One_Home
  description: ''
  trigger:
  - entity_id: camera.aarlo_foyer
    for: 00:00:01
    platform: state
    to: recording
  condition: []
  action:
  - data:
      entity_id: camera.aarlo_foyer
      filename: www/cameras/snapshot_foyer.jpg
    entity_id: camera.aarlo_foyer
    service: aarlo.camera_request_snapshot_to_file
  - delay: 00:00:05
  - data:
      data:
        image: https://xxx.ui.nabu.casa/local/cameras/snapshot_foyer.jpg
        url: https://xxx.ui.nabu.casa/local/cameras/snapshot_foyer.jpg
        vibration: 0,65,706,86,657,95,668,100
      message: https://xxx.ui.nabu.casa{{state_attr('camera.aarlo_foyer','entity_picture')}}
      title: Foyer motion but no one home {{state_attr('camera.aarlo_foyer','image_source')}}
    service: notify.join
  mode: single
twrecked commented 4 years ago

I've reverted to the original snapshot type in 0.7.0-beta.1. I remember what I was trying to do - handle some original Arlo cameras that failed to snapshot most of the time - and broke most everybody else in the mean time.

The new build adds an option stream_snapshot that defaults to False, the old behavior, but can be set to True for the new, broken, behavior.

I ran some tests with my 2 different camera types and found the following:

camera user_agent stream_snapshot worked size
street linux yes yes 640x352
street linux no sometimes
front linux yes yes 1920x1072
front linux no yes
street apple yes no*
street apple no sometimes 1280x720
front apple yes yes
front apple no yes 1920x1072

*And I know up until about 2 weeks ago this row was working.

street is an original Arlo (VMC3030) front is an Arlo Pro (VMC4030P)

I'm going to play around with some more and then I'm thinking of making the snapshot configuration more granular, maybe allow you to specify a list of cameras that work best with streaming snapshots.

bwarman commented 3 years ago

Is this supposed to be working now or is there a fix for it? I'm doing the same process as the original poster by calling the camera_request_snapshot_to_file service but then I'm using the aarlo_snapshot_ready event to send my notification to my iOS device. That way I know the snapshot is done. The snapshots being sent to my iOS device seem to be ones from previous triggers during the day.

Thanks for all of your work on this twrecked! It's an amazing integration and I don't want to only complain about it. Just curious if everyone is still having the problem or if there's something I should do to fix mine.

Edit: I should mention, it looks like I'm on version 0.7.0.beta.2

twrecked commented 3 years ago

It's mostly working! I haven't had much time in the last couple of weeks to look at this but I'll try and make some time this week and verify what you're trying to do works.

How are you sending the snapshots to your iOS device?

edit: I think I've found a way of properly making it work, I'm looking at it now. edit: Turns out I can use the snapshots in the media library more reliably, I'm testing a fix now.

bwarman commented 3 years ago

I'm using Node-Red with an event node for motion on a camera (binary_sensor.aarlo_motion_back_left). When that event is triggered I pass it to a service node (camera_request_snapshot_to_file) using the camera.aarlo_back_left entity. That writes the file to a public directory and I use the aarlo_snapshot_ready event to send the notification with the URL of the snapshot.

When I just did a test, manually triggering the flow, it downloaded a file from the site but the snapshot was from earlier in the day. The timestamp on the file was at the time that I tested, but the Arlo site still had a snapshot from earlier in the day. Then when I tested it again, the Arlo web snapshot had updated to the one I just took when testing, and AARLO downloaded that one. Seems there's something fishy with the timing of snapshots being taken and updated.

Is there a way to write a snapshot to file when Arlo has updated a snapshot or a way to know that Arlo has actually pushed a new snapshot and I'm not just pulling down an old one from the Arlo site?

twrecked commented 3 years ago

Can you try 0.7.0.beta.4. And try with streaming snapshots. The code should work the way you want it to but there was - as you surmised - a timing issue in the code.

bwarman commented 3 years ago

Ok, I'll give beta 4 a try. How do I pass the streaming snapshot to an iOS notification, since iOS needs a publicly accessible URL to send images through push notifications? Do the streaming snapshots exist in an accessible location?

twrecked commented 3 years ago

Streaming snapshot won't affect your Node-Red set up, it changes how the camera gets the snapshot but the file will be copied to the same place.

Add this to your config:

aarlo:
  stream_snapshot: True

And if you are still having problems, try change the user agent to linux.

aarlo:
  user_agent: linux
bwarman commented 3 years ago

Updated to beta.4. Tried adding

stream_snapshot: True

and

user_agent: linux

and still had the previous snapshot being delivered when triggered by motion.

It appears when I trigger the snapshot manually it will deliver a brand new snapshot, taken when I manually triggered it in Node Red, but when it's triggered by binary_sensor.aarlo_motion_back_left it sends an old snapshot. Not sure what else it could be.

twrecked commented 3 years ago

I need more information on your automation? Do you request a snapshot when aarlo_motion_back_left activates? Because it won't automatically generate a snapshot. If you record a video it will push a new image when that is finished.

edit: Another thing you might be interested in is this. It will save any new images and updates out to a file automatically (format for this example - /config/camera-name.jps) . It will also fire a aarlo_image_updated event with the camera id in it.

aarlo:
  save_updates_to: /config
bwarman commented 3 years ago

First of all, thank you for working through this with me. I really appreciate it.

For my automation, when motion is detected by the camera, using the binary_sensor.aarlo_motion_back_left entity, that event activation triggers the camera_request_snapshot_to_file service with the camera.aarlo_back_left as the Entity ID. To be sure the snapshot is ready, I wait for the aarlo_snapshot_ready event to fire and then I send the notification to my iOS device with the snapshot attached.

twrecked commented 3 years ago

Sounds like it should work, I'll try it here.

Does the camera record video or are you just using the motion detection?

bwarman commented 3 years ago

I just tested it and it seems to be working now. I'm not getting Arlo notifications from that camera now, but that's ok because I'd rather not get double notifications. I'm sensing this may be an Arlo problem and not an AARLO problem. Arlo's been so slow lately that it doesn't surprise me that it could be a backend problem on their side. I'll keep testing it and let you know if I discover anything else.

Thanks so much for your help!

twrecked commented 3 years ago

Keep an eye on it and let me know if anything weird happens. You can always turn on debugging to see what messages are flying about:

logger:
  default: info
  logs:
    custom_components.aarlo: debug
    custom_components.aarlo.camera: debug
    pyaarlo: debug

Sometimes the problem is we're automating systems that are triggered by the user so the backend will complain it's not ready.

bwarman commented 3 years ago

So, for what it's worth it does look like it's an Arlo problem because sometimes it works and sometimes it doesn't. My logs are indicating that the camera didn't stream:

2020-09-15 11:35:34 WARNING (SyncWorker_49) [pyaarlo] error in response={'data': {'error': '5011', 'message': 'The device failed to connect. Please try again.', 'reason': 'Camera did not stream'}, 'success': False}

I get that error frequently and it appears to be when motion is detected. I'm going to assume that AARLO integration is timing out, waiting for Arlo to actually start a stream.

townsmcp commented 3 years ago

This is an interesting thread. I implemented similar yesterday and am also seeing the notification image showing a previous event image on iphone and apple watch. My automation code is:

  alias: Camera Snapshot - Create and send notification - Back Garden Camera
  trigger:
  - entity_id: camera.aarlo_back_garden_camera, camera.aarlo_back_garden_camera
    for: 00:00:03
    from: idle
    platform: state
    to: recording
  - entity_id: camera.aarlo_back_garden_camera, camera.aarlo_back_garden_camera
    for: 00:00:03
    from: recently active
    platform: state
    to: recording
  condition: []
  action:
  - data_template:
      entity_id: '{{ trigger.entity_id }}'
    service: camera.aarlo_request_snapshot
  - service: notify.mobile_app_james_iphone
    data_template:
      title: Arlo Camera
      message: 'Motion has been detected on the {{trigger.to_state.attributes.friendly_name}} at {{now().strftime(''%r %d-%m-%y'')}}'
      data:
        push:
          category: camera
        entity_id: "{{ trigger.entity_id }}"
  mode: single

Somthing else I notice, when I click on the iOS notification and click on play button, the video showing is so slow, but thats another issue that can be addressed later. I have 0.7.0-beta.4 installed

EDIT: just to clarify, the small notification picture is from previous event. When you push and hold the notification to play the video, this is of the new event

townsmcp commented 3 years ago

First of all, thank you for working through this with me. I really appreciate it.

For my automation, when motion is detected by the camera, using the binary_sensor.aarlo_motion_back_left entity, that event activation triggers the camera_request_snapshot_to_file service with the camera.aarlo_back_left as the Entity ID. To be sure the snapshot is ready, I wait for the aarlo_snapshot_ready event to fire and then I send the notification to my iOS device with the snapshot attached.

@bwarman would you mind sharing your code please? I think im getting the incorrect syntax somewhere as its not working for me at the moment. Thanks

bwarman commented 3 years ago

First of all, thank you for working through this with me. I really appreciate it. For my automation, when motion is detected by the camera, using the binary_sensor.aarlo_motion_back_left entity, that event activation triggers the camera_request_snapshot_to_file service with the camera.aarlo_back_left as the Entity ID. To be sure the snapshot is ready, I wait for the aarlo_snapshot_ready event to fire and then I send the notification to my iOS device with the snapshot attached.

I'm actually using Node-RED for my automation so I don't really have any code to post. I've always found Node-RED to be easier for me to grasp than YAML.

townsmcp commented 3 years ago

@bwarman interesting about using NR. Can you export your flow and post here?

bwarman commented 3 years ago

@bwarman interesting about using NR. Can you export your flow and post here?

Here's a gist of my flow.

https://gist.github.com/bwarman/ee9cb111a0107e5e055f7211f4d3a370

townsmcp commented 3 years ago

@twrecked Ive just been having a play with this again. On the documentation page, under Events it states:

Event Description
aarlo_image_updated The image updated
aarlo_snapshot_updated The image updated, and it was caused by a snapshot.
aarlo_image_updated The image updated, and it was caused by an Arlo recording.

Stupid question, but what is the difference between the 1st line and 3rd line? They are the same event call arent they?

I noticed aarlo_snapshot_ready is deprecated so im not using that call for NR/automations

twrecked commented 3 years ago

It's a typo. It's updated now. The last one should read aarlo_capture_updated.

townsmcp commented 3 years ago

Thanks @twrecked. Out of curisoty, any progress about this issue? Ive installed v0.7.0-beta.6.1 and have the following settings in configuration.yaml:

user_agent: linux stream_snapshot: False

I have tried setting user_agent to apple and stream_snapshot to true (and vice versa to have all combinations with these 2 settings). Im using aarlo motion to trigger a snapshot to file. My cameras are Arlo Pro

twrecked commented 3 years ago

It should be working but let me take a look.

edit: Looks like the file downloaded is wrong. I'll look again.

townsmcp commented 3 years ago

Thanks @twrecked, much appreciated. As you noticed, the downloaded file is the previous event. Also, just an FYI, I have just upgraded to 0.116, restarted the Pi4 completely and still get the same - image is the previous event

twrecked commented 3 years ago

It's something I overlooked. I do the hard work of troggering the snapshot, waiting for it to finish and then don't wait for the new image to download...

twrecked commented 3 years ago

I created a new release that has better snapshot handling. This should fix the download file issue and generally speed up the snapshot taking. But, some cameras might still give you some grief, look here for some config you can use.

townsmcp commented 3 years ago

@twrecked thank you for the update. It is working well😀 I’m just playing around now with the agent again to see which gives the best result. Agent as ‘apple’ and ‘stream_snapshot’ set to true has so far yielded 640 image on Arlo Pro 2. So I’m just changing agent to ‘Linux’

townsmcp commented 3 years ago

Pictures are coming through very quickly. In case anyone is interested, Im using Node Red (thanks to @bwarman for the help there):

[{"id":"7faeba0.b7df0c8","type":"tab","label":"Notifications","disabled":false,"info":""},{"id":"41ab39f5.b9f1e","type":"group","z":"7faeba0.b7df0c8","name":"Car Port Camera Detection","style":{"fill":"#addb7b","label":true,"color":"#000000"},"nodes":["d7e571c2.5c4a28","d27acfe0.531e68","2e44267a.88e48a","738628c4.cd3fe8","8d16b59c.3437e"],"x":114,"y":279,"w":872,"h":142},{"id":"490c9f07.bdfc","type":"group","z":"7faeba0.b7df0c8","name":"Notification Response","style":{"fill":"#ffbfbf","label":true},"nodes":["54a14385.11b814","2533923e.5faf66","ff323a63.a0b058"],"x":114,"y":679,"w":532,"h":162},{"id":"4da54512.cfcdec","type":"group","z":"7faeba0.b7df0c8","name":"Send iOS Push Notification","style":{"fill":"#addb7b","label":true,"color":"#000000"},"nodes":["9d1eb002.d60ea","3ef16d6b.36e412","8df8b14e.1d423","b92b7626.db8fe","d25d204a.8e323","95f4c5cc.fa9918","a0ea4c54.70ab1"],"x":114,"y":459,"w":932,"h":182},{"id":"61388b30.cd57bc","type":"group","z":"7faeba0.b7df0c8","name":"Back Garden Camera Detection","style":{"fill":"#addb7b","label":true,"color":"#000000"},"nodes":["abc4548.9a7b5a8","9ca8873e.5436e","9d40e1ee.c18118","1c429a6e.8d44de","ba9f174a.674ce8","a0b5742d.f4d7c"],"x":114,"y":39,"w":872,"h":202},{"id":"9d1eb002.d60ea","type":"server-events","z":"7faeba0.b7df0c8","g":"4da54512.cfcdec","name":"Snapshot Ready","server":"9f14629c.16082","event_type":"aarlo_snapshot_ready","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"x":220,"y":500,"wires":[["3ef16d6b.36e412","b92b7626.db8fe"]]},{"id":"3ef16d6b.36e412","type":"debug","z":"7faeba0.b7df0c8","g":"4da54512.cfcdec","name":"Full debug to find attributes","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":420,"y":600,"wires":[]},{"id":"8df8b14e.1d423","type":"api-call-service","z":"7faeba0.b7df0c8","g":"4da54512.cfcdec","name":"Send Notification Back Garden","server":"9f14629c.16082","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_james_iphone","entityId":"","data":"{\"title\":\"Back Garden Camera\",\"message\":\"Motion detected - {{myhourpm}}:{{myminute}}.{{mysecond}} {{mypm}} {{mydom}}/{{mymonthn}}/{{myyear}}\",\"data\":{\"attachment\":{\"content-type\":\"jpeg\",\"url\":\"https://eh97tcjj07ca5liwwqfi1ohvvilx6av9.ui.nabu.casa/local/CamSnaps/BackGarden.jpg\"},\"push\":{\"category\":\"arlo_back_garden_notifications\",\"thread_id\":\"arlo-back-garden\"}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":890,"y":500,"wires":[[]]},{"id":"b92b7626.db8fe","type":"switch","z":"7faeba0.b7df0c8","g":"4da54512.cfcdec","name":"Change by device","property":"payload.event.entity_id","propertyType":"msg","rules":[{"t":"eq","v":"camera.aarlo_back_garden_camera","vt":"str"},{"t":"eq","v":"camera.aarlo_carport_camera","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":500,"wires":[["95f4c5cc.fa9918"],["a0ea4c54.70ab1"]]},{"id":"d25d204a.8e323","type":"api-call-service","z":"7faeba0.b7df0c8","g":"4da54512.cfcdec","name":"Send Notification Car Port","server":"9f14629c.16082","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_james_iphone","entityId":"","data":"{\"title\":\"Car Port Camera\",\"message\":\"Motion detected - {{myhourpm}}:{{myminute}}.{{mysecond}} {{mypm}} {{mydom}}/{{mymonthn}}/{{myyear}}\",\"data\":{\"attachment\":{\"content-type\":\"jpeg\",\"url\":\"https://eh97tcjj07ca5liwwqfi1ohvvilx6av9.ui.nabu.casa/local/CamSnaps/CarPort.jpg\"},\"push\":{\"category\":\"arlo_car_port_notifications\",\"thread_id\":\"arlo-car-port\"}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":880,"y":560,"wires":[[]]},{"id":"d7e571c2.5c4a28","type":"server-state-changed","z":"7faeba0.b7df0c8","g":"41ab39f5.b9f1e","name":"Car Port Motion","server":"9f14629c.16082","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.aarlo_motion_carport_camera","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":220,"y":380,"wires":[["d27acfe0.531e68"],[]]},{"id":"d27acfe0.531e68","type":"api-current-state","z":"7faeba0.b7df0c8","g":"41ab39f5.b9f1e","name":"Automation enabled?","server":"9f14629c.16082","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.car_port_arlo_automation","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":480,"y":380,"wires":[["2e44267a.88e48a"],[]]},{"id":"2e44267a.88e48a","type":"api-call-service","z":"7faeba0.b7df0c8","g":"41ab39f5.b9f1e","name":"Snapshot to file","server":"9f14629c.16082","version":1,"debugenabled":false,"service_domain":"aarlo","service":"camera_request_snapshot_to_file","entityId":"camera.aarlo_carport_camera","data":"{\"filename\":\"www/CamSnaps/CarPort.jpg\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":700,"y":380,"wires":[["738628c4.cd3fe8"]]},{"id":"738628c4.cd3fe8","type":"debug","z":"7faeba0.b7df0c8","g":"41ab39f5.b9f1e","name":"Snapshot","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":880,"y":320,"wires":[]},{"id":"8d16b59c.3437e","type":"inject","z":"7faeba0.b7df0c8","g":"41ab39f5.b9f1e","name":"Push New Image","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":520,"y":320,"wires":[["2e44267a.88e48a"]]},{"id":"54a14385.11b814","type":"server-events","z":"7faeba0.b7df0c8","g":"490c9f07.bdfc","name":"iOS Action","server":"9f14629c.16082","event_type":"ios.notification_action_fired","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"x":200,"y":760,"wires":[["2533923e.5faf66","ff323a63.a0b058"]]},{"id":"2533923e.5faf66","type":"debug","z":"7faeba0.b7df0c8","g":"490c9f07.bdfc","name":"iOS Action Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":440,"y":800,"wires":[]},{"id":"ff323a63.a0b058","type":"switch","z":"7faeba0.b7df0c8","g":"490c9f07.bdfc","name":"Back Garden Snapshot pressed","property":"payload.event.actionName","propertyType":"msg","rules":[{"t":"eq","v":"BACK_GARDEN_SNAPSHOT","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":490,"y":720,"wires":[[]]},{"id":"95f4c5cc.fa9918","type":"simpletime","z":"7faeba0.b7df0c8","g":"4da54512.cfcdec","name":"Time Now","mydate":true,"myymd":true,"myyear":true,"mymonth":true,"mymonthn":true,"mydom":true,"mydoy":true,"myday":true,"myhourpm":true,"myhour":true,"mytime":true,"mytimes":true,"myminute":true,"myminutes":true,"mysecond":true,"mymillis":true,"myepoch":true,"myrawdate":true,"mypm":true,"x":660,"y":500,"wires":[["8df8b14e.1d423"]]},{"id":"a0ea4c54.70ab1","type":"simpletime","z":"7faeba0.b7df0c8","g":"4da54512.cfcdec","name":"Time Now","mydate":true,"myymd":true,"myyear":true,"mymonth":true,"mymonthn":true,"mydom":true,"mydoy":true,"myday":true,"myhourpm":true,"myhour":true,"mytime":true,"mytimes":true,"myminute":true,"myminutes":true,"mysecond":true,"mymillis":true,"myepoch":true,"myrawdate":true,"mypm":true,"x":660,"y":560,"wires":[["d25d204a.8e323"]]},{"id":"abc4548.9a7b5a8","type":"server-state-changed","z":"7faeba0.b7df0c8","g":"61388b30.cd57bc","name":"Back Garden Motion","server":"9f14629c.16082","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.aarlo_motion_back_garden_camera","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":230,"y":200,"wires":[["9ca8873e.5436e","ba9f174a.674ce8"],[]]},{"id":"9ca8873e.5436e","type":"debug","z":"7faeba0.b7df0c8","g":"61388b30.cd57bc","name":"Back Garden Test","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":470,"y":140,"wires":[]},{"id":"9d40e1ee.c18118","type":"api-call-service","z":"7faeba0.b7df0c8","g":"61388b30.cd57bc","name":"Snapshot to file","server":"9f14629c.16082","version":1,"debugenabled":false,"service_domain":"aarlo","service":"camera_request_snapshot_to_file","entityId":"camera.aarlo_back_garden_camera","data":"{\"filename\":\"www/CamSnaps/BackGarden.jpg\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":700,"y":200,"wires":[["1c429a6e.8d44de"]]},{"id":"1c429a6e.8d44de","type":"debug","z":"7faeba0.b7df0c8","g":"61388b30.cd57bc","name":"Snapshot","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":880,"y":140,"wires":[]},{"id":"ba9f174a.674ce8","type":"api-current-state","z":"7faeba0.b7df0c8","g":"61388b30.cd57bc","name":"Automation enabled?","server":"9f14629c.16082","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.back_garden_arlo_automation","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":480,"y":200,"wires":[["9d40e1ee.c18118"],[]]},{"id":"a0b5742d.f4d7c","type":"inject","z":"7faeba0.b7df0c8","g":"61388b30.cd57bc","name":"Push New Image","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":620,"y":80,"wires":[["9d40e1ee.c18118"]]},{"id":"9f14629c.16082","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

NOTE: The 'Take Snapshot' button on notification to ios device is not yet implemented. Output example:

Notification

configuration.yaml settings:

aarlo:
  username: XXX
  password: XXX
  user_agent: apple
  db_motion_time: 30
  db_ding_time: 10
  recent_time: 10
  stream_snapshot: False
  last_format: '%m-%d %H:%M'
  refresh_devices_every: 1
  stream_timeout: 120
  reconnect_every: 90
  #save_updates_to: /config

switch:
  - platform: aarlo
    siren: True
    all_sirens: True
    snapshot: True
    siren_volume: 1
    siren_duration: 10

media_player:
  - platform: aarlo

ios:
  push:
    categories:
      - name: "Alarm Control" 
        identifier: 'alarm_notification' 
        actions: 
          - identifier: 'SOUND_ALARM'
            title: 'Sound Alarm'
          - identifier: 'SILENCE_ALARM'
            title: 'Dismiss Alarm'
      - name: "Arlo Back Garden"
        identifier: 'arlo_back_garden_notifications'
        actions:
          - identifier: 'BACK_GARDEN_SNAPSHOT'
            title: 'Take Snapshot'
      - name: "Arlo Car Port"
        identifier: 'arlo_car_port_notifications'
        actions:
          - identifier: 'CAR_PORT_SNAPSHOT'
            title: 'Take Snapshot'
bwarman commented 3 years ago

As of now I would say you can call this issue closed. Things seem to be working very smoothly with the new code and accompanying suggestions. Thanks @twrecked !!!

damien67 commented 3 years ago

I finally got some time to re-implement the automation and notifications logics, and yes, issue is resolved! Finally getting an accurate snapshot! Thank you so much @twrecked ! That's a $3/month/camera Arlo feature handled by HA for free.

bwarman commented 3 years ago

I finally got some time to re-implement the automation and notifications logics, and yes, issue is resolved! Finally getting an accurate snapshot! Thank you so much @twrecked ! That's a $3/month/camera Arlo feature handled by HA for free.

Agreed. @twrecked, do you have a buymeacoffee or patreon fund? Definitely worth throwing some money your way.

townsmcp commented 3 years ago

I finally got some time to re-implement the automation and notifications logics, and yes, issue is resolved! Finally getting an accurate snapshot! Thank you so much @twrecked ! That's a $3/month/camera Arlo feature handled by HA for free.

@damien67 check out DeepStack as well - that way you should be able to get all notifications that Arlo bundle in their subscription (people/package detection). I started implementing it but stopped while the snapshot issue was looked into. Now that it's been resolved I will start back on DeepStack 😃

damien67 commented 3 years ago

@townsmcp Looks like a very cool project, thanks for the suggestion!! And one more docker container to deploy and play with! :)

bwarman commented 3 years ago

Just got a couple of delayed snapshots. They weren't "old" ones necessarily but whatever triggered the snapshot was not in the frame. When I looked in the Arlo app the thing that triggered the snapshot (my dog) was in frame. Anything I can do to fix that issue?

twrecked commented 3 years ago

@bwarman Did you ask for a snapshot? Because without an explicit snapshot request we should be showing what the Arlo app is showing.

bwarman commented 3 years ago

@twrecked Yes, I used the camera_request_snapshot_to_file service and then used the snapshot_ready trigger to actually send the notification. I'm not sure if it's still sending delayed snapshots though. It's obviously at the mercy of the internet anyway so it's possible that my connection was just wonky that day. I'll let you know if it continues.