Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save webmasterkai/6011ff64fc1a236b8025181a535dbf87 to your computer and use it in GitHub Desktop.
Save webmasterkai/6011ff64fc1a236b8025181a535dbf87 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint - Save a camera snapshot with archive when motion is detected
blueprint:
name: Save a camera snapshot when motion is detected
description: Save a camera snapshot with archive when motion is detected
domain: automation
source_url: https://gist.github.com/webmasterkai/6011ff64fc1a236b8025181a535dbf87
input:
motion_sensor:
name: Motion sensor
description: The sensor wich triggers the snapshot creation
selector:
entity:
domain: binary_sensor
device_class: motion
camera:
name: Camera
description: The camera which creates the snapshot
selector:
entity:
domain: camera
file:
name: File Path
description: The file path to store the most current snapshot.
default: '/media/CAMERA_NAME/last_motion.jpg'
archive_file:
name: Archive File Path
description: The file path to store the snapshot in an archive folder.
default: '/media/CAMERA_NAME/archive/{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg'
delay:
name: Delay (Optional)
description: Save another archive snapshot after delay.
default: 10
selector:
number:
min: 0.0
max: 60.0
unit_of_measurement: seconds
mode: slider
step: 1.0
trigger:
platform: state
entity_id: !input motion_sensor
from: 'off'
to: 'on'
variables:
motion_sensor: !input 'motion_sensor'
camera: !input 'camera'
file: !input file
archive_file: !input archive_file
delay: !input 'delay'
action:
- service: camera.snapshot
entity_id: !input 'camera'
data:
filename: !input archive_file
- service: camera.snapshot
entity_id: !input 'camera'
data:
filename: !input file
- delay: '{{ delay }}'
- service: camera.snapshot
entity_id: !input 'camera'
data:
filename: !input archive_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment