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
trigger:
- platform: state
entity_id: binary_sensor.patio_doorbell
to: 'on'
action:
- service: media_player.alexa_tts
data:
entity_id: media_player.echo_show_2
message: 'Someone is at the patio door and doesn't look good'
- service: camera.snapshot
data:
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
data:
title: "Doorbell"
message: 'Someone has pressed the door bell at {{now().strftime("%H:%M %d-%m-%y")}} '
data:
attachment:
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
data:
topic: tele/RF_Bridge/RESULT
payload: 322B02off
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
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.
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…
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.