Automation downloaded image telegram

Hi everybody,

I am trying to download, then send an image via telegram upon motion detection. My script is below. The file will successfully download to <hass-dir>/downloads/cams, but I won’t receive any telegram notifications. Could you please tell me what I am doing wrong here?

# Bewegung Unterstand Kamera
- id: 'cam000000000001'
  alias: Kamera Unterstand
  trigger:
    - platform: mqtt
      topic: "espurnarf/rfin"
  condition:
    - condition: template
      value_template: >
        {{ trigger.payload.endswith('E223DE') }}
  action:
    - service: downloader.download_file
      data:
        url: <url>
        subdir: "cams"
        filename: "unterstand_snap_01.jpg"
        overwrite: true
    - service: notify.<telegram>
      data:
        photo:
          - file: "downloads/cams/unterstand_snap_01.jpg"
            caption: "Bewegung im Unterstand"

I took that section of code from the telegram example. Also tried sending it manually via developer tools, but that won’t work, either (no error, but also nothing happening). The file exists and changes each time I (manually) trigger the event. But it will not be sent via telegram.

Thanks in advance for your input :slight_smile:

Update: there must be something wrong with how I am trying to send the file. If I change it to

- service: notify.telegram
  data:
    title: Image
    message: Something
    data:
      photo:
        - url: http://some-image-url.jpg
          caption: my image

, then I will receive a current still from my webcam. It works via url but not when trying to first download the image, then send it via telegram as a photo.

This is fine, in fact, I prefer it this way. But some of my cameras do not provide a still image jpg file that I can just use, so I’ll have to use an external (bash) script. So at least those images would have to be sent as a file via telegram, not a photo. Anybody got an idea on how this can be achieved?

is the download folder whitelisted for HA to use?

Thank you.
tbh. I am not sure. Since home assistant can write to it (it downloads the file), I assume that I can read it as well…? I will look into this.

update: the folder is inside the configuration directory (/downloads). Does it still need to be whitelisted? I wasn’t able to find information about this— it is definitely not an external directory.

I’d be willing to bet that the downloader component doesn’t check to see if the directory is whitelisted, where the notification component does. Either way, just whitelist the directory and try again.

1 Like

Thank you! You were absolutely right. It works now :pray: