I’ve made my own smart doorbell that consists of the old school doorbell (acting as a contact sensor) and a separate Tapo camera. I’ve got an automation that sends me a notification if someone presses the doorbell:
alias: Doorbell notification
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.doorbell_button
to: "on"
condition: []
action:
- service: notify.ios
data:
title: Ding Dong 🔔
message: "[{{ now().strftime('%H:%M') }}] Er staat iemand voor de deur!"
- service: camera.snapshot
data:
filename: >-
/config/www/images/front_door/snapshot_latest.jpg
enabled: true
target:
entity_id: camera.front_door_sd_stream
- service: notify.ios
data:
title: Door snapshot 📸
message: "[{{ now().strftime('%H:%M') }}] Er staat iemand voor de deur!"
data:
image: /local/images/front_door/snapshot_latest.jpg
enabled: true
Note: I’ve separated the notification in two separate messages due to the ~5s delay in the notification that includes the snapshot. If someone has suggestions to improve this, I’m all ears!
Yesterday I was testing the automation and even though the snapshot_latest.jpg file is updated every time, it keeps on sending an older (cached?) image:
It looks like it is sending a cached image, instead of the recently modified snapshot_latest.jpg file.
It is also not a timing issue; triggering the automation a few minutes later still sends the same image:
If it would be a timing issue, you would expect in the above screenshot to have the snapshot_latest.jpg with timestamp of 10:12 that we created earlier.
Does anyone know how to make Home Assistant pick the latest jpg-file from the www folder?
I had the same issue, added 100ms delay to the notification and the problem was solved.
I use “notify.notify”
for some reason Android didn’t have this issue.
another solution would be to make the name of the image unique, use a variable for timestamp or something and add it to the filename
Thanks for the suggestions!
What is before your delay in your automation? And how do you specify a target for the notify.notify service? I’ll give it a try
I might do this as a plan B, but it will also require me to clean up the www folder once in a while, which I’d like to prevent. But apart from that, I assume my approach should work so I’d like to figure out why it doesn’t!
I send also some other notifications as well, and Turn on the lights.
I do not specify devices using notify.notify. Just everyone who has installed the app gets a message.
which in my case is ok. Maybe other scenarios are different. You could still use notify.ios.
but I just want to mention there is a difference in the script.
I’ve marked @bkbartk 's reply as the answer. The trick was to use the external URL (https:///local/…) in combination with the timestamp. Thanks!
For people wanting to do more research on this topic: I think it could also be related to the fact that I use Cloudflared to connect to my home-assistant instance. Maybe Cloudflare caches the image, instead of Home Assistant?
This just saved me hours of frustration, thank you! I recently moved from DuckDNS to a Cloudlfare tunnel, and couldn’t figure out why I was getting outdated, cached images in my doorbell notifications. Using the external URL and unique timestamp was the solution.