Keep old camera snapshots

Hello there, I have a working doorbell automation but I would like to keep the old snapshoots instead of overwriting the same jpg all the time.
I have found some example but I am not sure why the image doens’t get pushed to the IOS app.
Using the code below, snapshot is created inside the patio folder which is accessible from the internet but it doesn’t get pushed to the ios app.
Obviously the syntax is wrong url: ‘https://myha:8123/local/patio/patiocamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg’ but according to the examples it shoudl work.
What I am doing wrong?

Thank you!

 - alias: 'Patio Doorbell'
hide_entity: true
- platform: state
  entity_id: binary_sensor.patio_doorbell
  to: 'on'
- service: media_player.alexa_tts
    entity_id: media_player.echo_show_2
    message: 'Someone is at the patio door and doesn't look good'
- service: camera.snapshot
    entity_id: camera.patio_camera
    filename: '/config/www/patio/patiocamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg'
- service: notify.mobile_app_joes_phone  
    title: "Doorbell"
    message: 'Someone has pressed the door bell at {{now().strftime("%H:%M %d-%m-%y")}} '
        content-type: jpg
        url: 'https://myha:8123/local/patio/patiocamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg'
        hide-thumbnail: false
- service: mqtt.publish
    topic: tele/RF_Bridge/RESULT
    payload: 322B02off

I replied in your other message.

Try replacing data with data_template
Whenever you don’t want something hard coded but want to use a template to use one of HA’s entity values, use data_template

@tom_l I suspect that’s the advice you also provided, but as there was no link to the other message, I’ve replied anyway in case someone has a similar issue :wink:

thank you Lolouk, yes I did try data_template: nothing has changed, I use IOS Beta2.0, all works pictures are in the patio folder and accessible from outside, just no attachment.

This is the other thread

sounds like a different issue I guess.
so your screenshots work well and now get saved without being overwritten, yes?
but you’re not getting them in the notification?
My first guess would be that it’s because your filename is dynamic:
/config/www/patio/patiocamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg
you will use the current time to save the file and the current time to access the file. Most likely the time between saving and the time between accessing has changed and therefore you’re looking for a file that does not exist.
You’d need to temporarily save the timestamp somewhere and use it to save the file and access it. potentially in an input_text…

I start suspecting that may be the IOS 2.0 beta…
I have pointed to an existand file
url: “https://xxxxxxxxxxx:8123/local/patio/patiocamera.png
also tried file: “https://xxxxxxxxxxx:8123/local/patio/patiocamera.png
with " and ’ or without any quotes, image still doesn’t show up!

Or drop the seconds. Then it’s only a 1 of 60 chance of crossing a minute boundary…

turns out it is the IOS 2.0 beta
Thank you guys for your help, I guess will circle back when the problem with the app has been solved!

I have solved this issue with the following automation:

- alias: "30001 - Someone rings the doorbell"
    snapshot_filename: '/tmp/mycamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg'
    platform: state
    entity_id: binary_sensor.my_doorbell
    to: 'on'
    - service: camera.snapshot
        entity_id: camera.my_doorbell_camera
        filename: '{{ snapshot_filename }}'
    - service: notify.my_notify
        message: There is someone at the door
            - file: '{{ snapshot_filename }}'

notify.my_notify sends the message to both telegram AND my Home Assistant companion app

and you do not have an issue if there is a time difference between the file creation and the timr you access the file for the notification ??

I mean the time changes so the file name as well, no ??

No the filename does not change. It is set at the beginning of the automation in the variables section and stays the same until the end of the current automation.

Next time the automation is triggered, it is set again at time.