#Cached snapshot shown in notification

1 messages Β· Page 1 of 1 (latest)

ashen egret
#

Hi all,

I have a notification which shows a short text and a snapshot when someone rings my doorbell. Right now an old picture is shown in the notification on my phone. I read online that this is a cache issue and more people are experiencing it. I thought about including the last triggered state of my automation in the filename of the snapshot so the automation has to pull an unique file name. This would prevent the automation from grabbing the cached file.

But I'm having trouble giving the file name the last triggered state of my automation.

I had this:

metadata: {}
data:
  filename: /config/www/doorbell/reolink-snapshot.jpg
target:
  entity_id: camera.reolink_video_doorbell_fluent

I tried this:

metadata: {}
data:
  filename: >-    /config/www/doorbell/reolink-snapshot.jpg?{{
states.automation.er_is_aangebeld.last_triggered}}
target:
  entity_id: camera.reolink_video_doorbell_fluent```

But it creates a file named: "reolink-snapshot.jpg?" which doesn't work.
Can anyone help me out with this?

Side question: I use google AI to create a message based on the image, but on Android the notification screen is too small to read the whole message. When I press and swipe down, it's still not fully shown. On Apple you can press and hold the notification to show all the text. Is there a solution for Android?
gritty kayak
#

Try: /config/www/doorbell/reolink-snapshot.jpg?{{as_timestamp(now())}}

#

The downside of this is that you need to write a script/cron job that deletes all old snapshots every now and then. I think you should define the image name as a variable because Now() changes constantly, so there might be a difference between the filename that you store and the filename that you retrieve.

#

Does anyone know how to delete files in the /www/ folder using an automation in HA?

#

(I did not test this by the way)

ashen egret
ashen egret
#

Here is an example

#

but even when i remove the old file, the cached file is still shown in the notifcation, hence why i created this thread πŸ™‚

gritty kayak
ashen egret
#

Understandeble πŸ™‚

gritty kayak
#

@ashen egret
You can try: /config/www/doorbell/reolink-snapshot.jpg?{{ state_attr('automation.er_is_aangebeld','last_triggered') }}

#

I tested this in the developer tools and it returns the last triggered value whereas your code does not return a value.

#

And to be sure you can remove the whitespaces like this:

/config/www/doorbell/reolink-snapshot.jpg?{{ state_attr('automation.er_is_aangebeld','last_triggered')|replace(' ','')}}

ashen egret
#

Thanks!

#

but the file extension is now the time and date

gritty kayak
#

Yes, that is the last_triggered time and date

#

That is what last_triggered returns

ashen egret
#

Yea, but now the file extension is incorrect, i can not open it

#

the date and time should be in the filename, not the file extension

gritty kayak
#

Oh wait...

ashen egret
#

if that makes sense πŸ˜„

gritty kayak
#

/config/www/doorbell/reolink-snapshot{{ state_attr('automation.er_is_aangebeld','last_triggered')|replace(' ','')}}.jpg

#

This should work (did not test it)

ashen egret
#

it works πŸ™‚

#

do i also add this:

#

/config/www/doorbell/reolink-snapshot{{ state_attr('automation.er_is_aangebeld','last_triggered')|replace(' ','')}}.jpg

#

in the google ai part?

gritty kayak
#

Yes

ashen egret
#

and in the notification

gritty kayak
#

I do hope that that field accepts template code though

gritty kayak
ashen egret
#

ill test it now πŸ˜„

gritty kayak
#

And I hope your caching issue is solved as well

ashen egret
#

it should be, i also used this with your blueprint for the reolink doorbell. that BP also creates a new image for each visitor

gritty kayak
#

Now, you only need to remove the image afterwards

ashen egret
#

yep, it now works πŸ˜„

#

this part removes the image again

gritty kayak
ashen egret
#

now i need to figure out how to show the full text in the notification in android, but thats something for another time

ashen egret
gritty kayak
#

Great that it works!

#

Now get back to work! HAHAHAHHAHA

ashen egret
#

Ssssst!! 🀣

gritty kayak
#

🀐

ashen egret
#

thanks for the help! πŸ™‚