I have a few motion sensors and cameras set up. I get notifications based on line crossings, and/or motion. I get a lot of “false Alerts”, well too many alerts sometimes, like maybe kids are playing in the driveway, etc.
I feel like I have done some good logic to reduce false alerts.
Anyway, what I’d like to do, is after the “event(s)” have finished is to send a message to my email archive
I’d like to see if I can only send images with a timestamp that happened in the past 1 minute. Depending on the circumstances it could be 1, 2 or 3 of the images.
I guess the logic would apply to any files. So How would I conditionally send only files within a specific time stamp?
Adding the high level concept for the automation (without having figured out timestamps
- alias: Send Camera Pics to Archive
trigger:
- platform: state
entity_id: timer.camera_action
to: 'idle'
for:
minutes: 1
- service: notify.gmail_house_archive
data:
title: 'Driveway Line Crossing Events'
message: "{{ as_timestamp (now()) | timestamp_custom('%I:%M %p') }} on {{ now().strftime('%d %b %Y') }}"
data:
images:
- /tmp/driveway1.jpg
- /tmp/frontdoor.jpg
- /tmp/driveway2.jpg
Basically when the cameras trigger motion or line crossing, I start a timer, I use the timer as a way of keeping multiple events from triggering. When the timer is done, I’d like to send any “new” pics. It would almost always be at least 2 pics, sometimes 3.
Each image would be captured based on a specific automation.
So
automation.cameras_drive_way_1_picture
automation.cameras_drive_way_2_picture
automation.cameras_drive_way_front_door_motion
Maybe a template based on last_triggered. Ultimately only include images as the attachment based on the automation being ran within the last minute (or less)?
Just talking to myself here, but posting for anyone else in the future. Sometimes the simple solution is the best solution. I added a simple shell command at the end of the automation, to delete all images. When the automation fires it sends whichever ones are there, and skips the ones that are not there. Works well.
- alias: Send Camera Pics to Archive
trigger:
- platform: state
entity_id: timer.camera_action
to: 'idle'
for:
minutes: 1
- service_template: ...
data:
title: 'Driveway Line Crossing Events'
message: "{{ as_timestamp (now()) | timestamp_custom('%I:%M %p') }} on {{ now().strftime('%d %b %Y') }}"
images: ...
So the reason i left the … for images and service_template is because you’ll need 3 separate timers for each image. Once you have those timers, we can check the time and I can help you write a template for that. Without the timer entity_id’s / syntax, can’t really help.
This is what I ended up doing, and so far it’s working very well. I get 1, 2 and occasionly 3 pics. But I like what you shared, I have a few other automations I might use some of this for.
- alias: Send Camera Pics to Archive
trigger:
- platform: state
entity_id: timer.camera_action
to: 'idle'
for:
minutes: 1
action:
- service: notify.gmail_house_archive
data:
title: 'Driveway Line Crossing Events'
message: "{{ as_timestamp (now()) | timestamp_custom('%I:%M %p') }} on {{ now().strftime('%d %b %Y') }}"
data:
images:
- /tmp/driveway1.jpg
- /tmp/frontdoor.jpg
- /tmp/driveway2.jpg
- delay:
seconds: 10
- service: shell_command.delete_snapshots