question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Downloader not saving full image before returning control to event loop

See original GitHub issue

The problem

When using the local file upload of an image, the image sometimes only partially uploads despite it being correct and fully formed locally.

Image appears on slack like this: image

However the exact same file (same timestamp) is fully formed and captured properly in the Local Media folder: image

My automation basically downloads a bunch of snapshots from various cameras, then sends them via the Slack notification before finally streaming video from one of them to the chromecast TV.

At first, I thought there needed to be a delay between the download and notification in case it started to send the slack notification file before it completed downloading the file in ‘Downloader’ so I added 2 seconds between each Slack Notify but that didn’t make a difference. I also don’t want to delay the streaming at the end by too much .

What version of Home Assistant Core has the issue?

Home Assistant 2022.11.4 Frontend 20221108.0 - latest

What was the last working version of Home Assistant Core?

Home Assistant 2022.11.4 Frontend 20221108.0 - latest

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Slack

Link to integration documentation on our website

https://www.home-assistant.io/integrations/slack

Diagnostics information

No response

Example YAML snippet

alias: Announce Someone Is At The Door
description: ""
trigger:
  - platform: device
    device_id: xxxxxxx
    domain: nest
    type: camera_person
condition: []
action:
  - service: media_player.volume_set
    target:
      entity_id: media_player.speakers_group
    data:
      volume_level: 0.5
  - service: shell_command.sonoff_tv_on
    data: {}
  - service: media_player.play_media
    data:
      media_content_id: http://xx.xx.xx.xx/someoneisatthedoor.mp3
      media_content_type: audio/mp3
    target:
      entity_id: media_player.speakers_group
  - service: downloader.download_file
    data_template:
      url: >-
        http://xx.xx.xx.xx:88/cgi-bin/CGIProxy.fcgi?usr=xxx&pwd=xxx&cmd=snapPicture2
      filename: frontdoor_snap.jpg
      overwrite: true
  - service: downloader.download_file
    data_template:
      url: >-
        http://xx.xx.xx.xx:88/cgi-bin/CGIProxy.fcgi?usr=xx&pwd=xxx&cmd=snapPicture2
      filename: driveway_snap.jpg
      overwrite: true
  - service: shell_command.snapshot_nest_frontdoor
    data: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: notify.ha_slack_bot
    data:
      message: Front Door (Foscam) Snapshot
      data:
        file:
          path: /media/frontdoor_snap.jpg
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: notify.ha_slack_bot
    data:
      message: Driveway Snapshot
      data:
        file:
          path: /media/driveway_snap.jpg
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: notify.ha_slack_bot
    data:
      message: Front Door (Nest) Snapshot
      data:
        file:
          path: /media/frontdoor_nest_snap.jpg
  - service: camera.play_stream
    target:
      entity_id:
        - camera.front_door
    data:
      media_player: media_player.gallnuaimium
mode: parallel
max: 10

Anything in the logs that might be useful for us?

No response

Additional information

No response

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
tkdrobcommented, Jan 2, 2023

You will need to add those urls to allowlist_external_urls under homeassistant: in configuration.yaml,

https://www.home-assistant.io/docs/configuration/basic/#allowlist_external_urls

1reaction
tkdrobcommented, Jan 2, 2023

Something else just came to mind. Use url: instead of path: for the Slack service call. That way you can skip downloading it locally.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to download image using requests - python
The file is saved with its filename as in specified url. import requests url = "http://example.com/image.jpg" filename = url.split("/ ...
Read more >
Async for Data Scientists — Don't Block the Event Loop
CPU-hungry tasks or non-async I/O libraries may block the event loop of your program. Learn how to avoid this in Python. Image by...
Read more >
How to Avoid Issues When Waiting On Multiple Events in ...
A task is scheduled to run if it is not waiting on an external event. When tasks complete they are removed from the...
Read more >
How To Process Images in Node.js With Sharp - DigitalOcean
The process involves reading an image, applying methods to alter or enhance the image, and then saving the processed image. It's common for ......
Read more >
Understanding Control Flow with Async and Await in C# ...
The await keyword does not block the current thread. What do we mean by that? Let's look at some examples of blocking code....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found