I have this automation which is supposed to sent a notification with an image upon detected motion
This only sometimes works, sadly most of the time the image is missing.
The image is locally available and works. The image is just missing in the notification.
Sometimes it’s works, so the automation is not completely failing
What might be the cause of this?
- id: camera_notificatie_beweging_voordeur
alias: Stuur notificatie bij beweging voordeur
trigger:
platform: state
entity_id: binary_sensor.camera_oprit_line_crossing
to: 'on'
action:
- service: camera.snapshot
data:
entity_id: camera.oprit
filename: /config/www/snapshots/motion_snapshot_{{ now ().year }}_{{ now ().month }}_{{ now ().day }}_{{ now ().hour }}_{{ now ().minute }}.jpg
- service: notify.iedereen
data_template:
title: Beweging voordeur!
message: Beweging voordeur om {{now().strftime("%H:%M op %d-%m-%Y")}}
data:
persistent: true
tag: persistent
push:
sound: ready.mp3
attachment:
content-type: jpeg
url: https://my_public.url:40443/local/snapshots/motion_snapshot_{{ now ().year }}_{{ now ().month }}_{{ now ().day }}_{{ now ().hour }}_{{ now ().minute }}.jpg
First, the camera.snapshot service may take longer than usual sometimes. You may need to add a delay between the two actions.
Second, and probably the real issue, the filename template is rendered twice. If the minute changes between the two then they two actions will use different file names.
I would suggest adding an initial action that sets (at least the last part of) the filename into an input_text. Then in the other two actions, use the value of the input_text to render the filename.