Telegram send photo which name is a variable

hi im trying to send an image from an automation which capture a screenshot.
the screenshot name is a variable but it wont reach telegram

here is the automation :

alias: CHange file name door bell
variables:
snapshot_filename: /config/www/mycamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg
description: “”
trigger: []
condition: []
action:

  • service: blink.trigger_camera
    data: {}
    target:
    entity_id: camera.blink_door_bell
  • delay:
    hours: 0
    minutes: 0
    seconds: 0
    milliseconds: 10
  • service: blink.blink_update
    data: {}
  • service: camera.snapshot
    data:
    filename: “{{ snapshot_filename }}”
    target:
    entity_id: camera.blink_door_bell
  • service: telegram_bot.send_photo
    data:
    authentication: digest
    url: https://hatmeh80.xyz/local/{{ snapshot_filename }}
    target: 6064819421

mode: single

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

What is the question? What is the problem on this?
What do the logs say?

Sorry a noob here, this is an automation to get a snapshot from blink door bell.
the problem is an overwritten normal image does not get updated when i send a notification.
i tried to save the filename as a variable and it saves.

but the url i use https://hatmeh80.xyz/local/{{ snapshot_filename }} to send the image is not working

What do the logs say?

Logger: homeassistant.components.telegram_bot
Source: components/telegram_bot/init.py:855
Integration: Telegram bot (documentation, issues)
First occurred: 1:30:47 PM (36 occurrences)
Last logged: 3:10:58 PM

Can’t send file with kwargs: {‘authentication’: ‘digest’, ‘file’: ‘/config/www//config/www/mycamera_20231017-150620.jpg’}
Can’t send file with kwargs: {‘authentication’: ‘digest’, ‘file’: ‘/config/www//config/www/mycamera_20231017-150638.jpg’}
Can’t send file with kwargs: {‘authentication’: ‘digest’, ‘file’: ‘/config/www//config/www/mycamera_20231017-150913.jpg’}
Can’t send file with kwargs: {‘authentication’: ‘digest’, ‘file’: ‘/config/www//config/www/mycamera_20231017-150930.jpg’}
Can’t send file with kwargs: {‘authentication’: ‘digest’, ‘file’: ‘/config/www//config/www/mycamera_20231017-151058.jpg’}

  1. Please use Proper formatting. Read this:
    How to help us help you - or How to ask a good question

  2. It looks like the file gets created. Have you tried “hardcoding” one picture?
    Fore example mycamera_20231017-150638.jpg ?

3:
I dont want to judge your project/plan but now you want to:

  • Get photo from your cam
  • Save photo locally on your homeassistant with a timestamp
  • View/save the picture through the internet/web (why?!), fetch it again and send it with telegram

also there are two, maybe three flaws I want to make you aware:

  • minor: Your Bandwith gets stressed unneccessarily (you download/upload too much than needed)
  • EVERYONE can access your pictures when they are saved in /config/www !
  • potentially: your Harddrive gets full after some time when you dont keep an eye on the saved pictures

Instead you could:

  • Get photo from your cam (homenetwork/LAN)
  • Save photo locally on your homeassistant with a timestamp on /media/picture.jpg
  • Fetch it from harddrive locally with a timestamp from /media/picture.jpg

See my Automation which works similiar. Maybe you can use this for your project:

alias: super_nice_alias
description: "when something triggers this, pictures get sent"
trigger:
  - type: opened
    platform: device
    device_id: 1234
    entity_id: whatever.entity.should.trigger.this
    domain: whatever.domain
condition:
  - condition: not
    conditions:
      - condition: state
        entity_id: device_tracker.whatever.condition.you.use
        state: home
action:
  - data:
      message: door opened
    service: telegram_bot.send_message
  - service: camera.snapshot
    data:
      filename: /media/door_opened_1.jpg
    target:
      device_id: 1234
  - service: camera.snapshot
    data:
      filename: /media/door_opened_2.jpg
    target:
      device_id: 1234
  - service: camera.snapshot
    data:
      filename: /media/door_opened_3.jpg
    target:
      device_id: 1234
  - service: camera.snapshot
    data:
      filename: /media/door_opened_4.jpg
    target:
      device_id: 1234
  - service: camera.snapshot
    data:
      filename: /media/door_opened_5.jpg
    target:
      device_id: 1234
  - service: telegram_bot.send_photo
    data:
      authentication: digest
      caption: "1"
      file: /media/door_opened_1.jpg
  - service: telegram_bot.send_photo
    data:
      authentication: digest
      caption: "2"
      file: /media/door_opened_2.jpg
  - service: telegram_bot.send_photo
    data:
      authentication: digest
      caption: "3"
      file: /media/door_opened_3.jpg
  - service: telegram_bot.send_photo
    data:
      authentication: digest
      caption: "4" 
      file: /media/door_opened_4.jpg
  - service: telegram_bot.send_photo
    data:
      authentication: digest
      caption: "5"
      file: /media/door_opened_5.jpg
mode: single

What are the upsides on this?

  • Pictures are not accessible through the internet by ANYONE.
  • it saves 5 pictures with a static filename (filename1-5). When it retriggers it overwrites the pictures it did before, keeping your harddrivespace clean. The pictures are archived in your telegram anyway.

Got it working, the path should be :

  • service: telegram_bot.send_photo
    data:
    file: /{{ snapshot_filename }}
    target: 6064819421

Your picture gets saved in www anyway. Please bear that in mind!