It was too inconsistent, I eventually just put a delay in the automation - so it waits a minute after its triggered before sending the file
I think i’ve figured this out now. Its over engineered, but seems to be working more consistently, and get access to a higher image in the notification (the nest ones were blurry)
So it uses Watch Folder to check when a new file is created in the specified folder, that will trigger my shell command that will simply copy the newest file from the nest directory , and copy it to the www folder at ‘latest’ (Used copy to keep the originals in nest folder incase I ever need them & move to latest in destination folder so that this folder doesn’t fill up)
The notification simply uses the latest.jpg image each time, which so far get’s updated and haven’t noticed a significant delay from the original way of doing it (both automations are running while i assess) and of course, each time you have a valid image
move_media_file_for_notification: cp $(ls -t1 /ls -t1 nest/event_media/a5a101b3b10822886f2c9a1155538391/*camera_person.jpg | head -n1) /config/www/media/latest.jpg
- id: doorbellnewfilecreatedinnestfolder
alias: Doorbell - Person detected - Screenshot
trigger:
- platform: event
event_type: folder_watcher
event_data:
event_type: created
condition:
# If holiday mode on no automations
- condition: state
entity_id: input_boolean.holiday_mode
state: 'off'
# If send notification boolean is true
- condition: state
entity_id: input_boolean.doorbell_person_detected_notification
state: 'on'
action:
- service: shell_command.move_media_file_for_notification
- service: notify.mobile_app_v0f9p0cww7
data:
message: "Person detected"
data:
image: "/local/media/latest.jpg"