Skip to content

Instantly share code, notes, and snippets.

@timmo001
Last active December 14, 2020 18:11
Show Gist options
  • Save timmo001/a5633f81dbc95a85854df46280bfeb3a to your computer and use it in GitHub Desktop.
Save timmo001/a5633f81dbc95a85854df46280bfeb3a to your computer and use it in GitHub Desktop.
Camera snapshot and actions when binary sensor is triggered
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/u/timmo001
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment