Skip to content

Blink integration marks motion detection clips as already seen when snapping pictures to save them locally #799

@ml0renz0

Description

@ml0renz0

Describe the bug

This happens since HA stable docker image version 2023.8.2

I created the automation (based on this official example) that is marking clips recorded from motion detection as seen whenever this automation is executed and new motion clips were recorded:

2023-08-29 11:18:18.222 DEBUG (SyncWorker_44) [blinkpy.camera] Found 3 recent clips for entrada
2023-08-29 11:18:18.223 DEBUG (SyncWorker_44) [blinkpy.camera] Most recent clip for entrada was created at 2023-08-29T09:11:44+00:00: https://rest-e002.immedia-semi.com/api/v3/media/accounts/XXXXXX/networks/369464/lotus/86269/pir/3654965765.mp4
2023-08-29 11:18:18.224 DEBUG (SyncWorker_44) [blinkpy.api] Making GET request to https://rest-e002.immedia-semi.com/api/v3/media/accounts/XXXXXX/networks/369464/lotus/86269/thumbnail/thumbnail.jpg?ts=1693300686&ext=
2023-08-29 11:18:18.369 DEBUG (SyncWorker_44) [blinkpy.api] Making GET request to https://rest-e002.immedia-semi.com/api/v3/media/accounts/XXXXXX/networks/369464/lotus/86269/pir/3654965765.mp4

It seems this GET is what is marking my video as seen:
2023-08-29 11:18:18.369 DEBUG (SyncWorker_44) [blinkpy.api] Making GET request to https://rest-e002.immedia-semi.com/api/v3/media/accounts/XXXXXX/networks/369464/lotus/86269/pir/3654965765.mp4

Let's check the code, it seems HA version 2023.8.2 includes blinkpy version 0.21.0 that includes this PR: Add get_videos_metadata function (@rhhayward #685)

Hmmm, could it be that this PR (introduced in blinkpy-0.21.0 that comes with HA 2023.8.2) raises this issue as a side effect?

Tracing back from said log line we get to:

Hope this helps.

To Reproduce
Steps to reproduce the behaviour:

  1. Create automation based on the official example to snap pictures and save them locally:
    alias: actualizar captura portero
    description: ""
    trigger:
      - platform: time_pattern
        hours: "*"
        minutes: /5
        seconds: "0"
    condition: []
    action:
      - service: blink.trigger_camera
        data: {}
        target:
          device_id: bd4a5bf0740aad568d894cfb7e1d0c80
      - delay:
          hours: 0
          minutes: 0
          seconds: 5
          milliseconds: 0
      - service: blink.blink_update
        data: {}
      - service: camera.snapshot
        data:
          filename: /tmp/portero.jpg
        target:
          device_id: bd4a5bf0740aad568d894cfb7e1d0c80
    mode: single
    
  2. wait for automation to capture photos
  3. generate some motion detection clips
  4. see how new motion detection clips are already marked as seen when you open blink app to check on new motion detection clips.

Expected behavior
This PR added the possibility to retrieve clips' metadata, but since its merge (blinkpy version 0.21.0) motion detection clips are being marked as read. It seems that it downloads the video, marking it as seen on blink servers, only to get its metadata. It shouldn't mark motion clips as already seen if they weren't downloaded by the user whatsoever.

Home Assistant version (if applicable): since 2023.8.2

blinkpy version (not needed if filling out Home Assistant version): since 0.21.0

Log Output/Additional Information
If using home-assistant, please paste the output of the log showing your error below. If not, please include any additional useful information.

2023-08-29 11:18:18.222 DEBUG (SyncWorker_44) [blinkpy.camera] Found 3 recent clips for entrada
2023-08-29 11:18:18.223 DEBUG (SyncWorker_44) [blinkpy.camera] Most recent clip for entrada was created at 2023-08-29T09:11:44+00:00: https://rest-e002.immedia-semi.com/api/v3/media/accounts/XXXXXX/networks/369464/lotus/86269/pir/3654965765.mp4
2023-08-29 11:18:18.224 DEBUG (SyncWorker_44) [blinkpy.api] Making GET request to https://rest-e002.immedia-semi.com/api/v3/media/accounts/XXXXXX/networks/369464/lotus/86269/thumbnail/thumbnail.jpg?ts=1693300686&ext=
2023-08-29 11:18:18.369 DEBUG (SyncWorker_44) [blinkpy.api] Making GET request to https://rest-e002.immedia-semi.com/api/v3/media/accounts/XXXXXX/networks/369464/lotus/86269/pir/3654965765.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThere is an issue causing unexpected resultshelp-wantedAssistance required due to lack of resources for testing or complexity

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions