This blueprint takes a snapshot of a camera when a binary sensor is triggered/set to ‘on’. You can add additional actions afterward.
For example, you can send a notification to your phone using the variable {{ snapshot_file_path }}
as the image URL.
blueprint:
name: Camera snapshot and actions when binary sensor is triggered
description: >-
Creates a snapshot and triggers a subsequent action when a binary sensor is triggered
domain: automation
input:
binary_sensor:
name: Binary sensor
description: The sensor wich triggers the snapshot creation
selector:
entity:
domain: binary_sensor
camera:
name: Camera
description: The camera which creates the snapshot
selector:
entity:
domain: camera
delay:
name: 'Snapshot Delay (Optional)'
description: 'Wait before creating camera snapshot'
default: 0.0
selector:
number:
min: 0.0
max: 60.0
unit_of_measurement: seconds
mode: slider
step: 1.0
additional_actions:
name: 'Additional Actions'
description: >-
Actions after taking snapshot. (Optional)
Example: A notification using {{ snapshot_file_path }} as the image.
default: []
selector:
action:
source_url: https://community.home-assistant.io/t/camera-snapshot-and-additional-actions-when-binary-sensor-is-triggered/255382
mode: restart
variables:
binary_sensor: !input 'binary_sensor'
binary_sensor_name: '{{ states[binary_sensor].name }}'
camera: !input 'camera'
delay: !input 'delay'
snapshot_create_file_path: '/config/www/tmp/snapshot_{{ states[camera].object_id }}.jpg'
snapshot_file_path: '{{ snapshot_create_file_path | replace(''/config/www'', ''/local'') }}'
trigger:
platform: state
entity_id: !input 'binary_sensor'
from: 'off'
to: 'on'
action:
- delay: '{{ delay }}'
- service: camera.snapshot
entity_id: !input 'camera'
data:
filename: '{{ snapshot_create_file_path }}'
- choose:
default: !input additional_actions
Thanks to this blueprint which this one was based on.