Magic Snapshot blueprint. V2.02
Hello community, here one of the blueprint i use for few month now to get some “animated” snapshot of my camera
The blueprint let you choose
The triggering entity ( binary)
The Camera / video stream
Animated Or fixed image.
The delay to capture it.
The Id of the telegram you want to send it to.
The content of your message.
First you need to add some line to your
configuration.yaml
shell_command:
process_alert_video: "ffmpeg -y -i /config/www/snapshots/temp_raw.mp4 -vf 'fps=2' -c:v libx264 -preset ultrafast -an /config/www/snapshots/alert_final.mp4"
Then , Magic thing recommended by Forum Sir ![]()
Do now forget to reboot your Home assistant after that. (Completely, not only the yaml file reload. You lazy little thing…
For the purist, here’s the code:
blueprint:
name: "Magic Capture (Video/Snapshot)"
description: "Captures a video sequence or a snapshot after an optional delay, and notifies via Telegram."
domain: automation
input:
delay_capture:
name: "Delay before capture"
description: "Waiting time (in seconds) before triggering the recording or snapshot."
default: 0
selector:
number:
min: 0
max: 15
step: 0.5
mode: slider
capture_mode:
name: "Capture mode"
description: "Format of the media to capture and send."
default: "video"
selector:
select:
options:
- label: "Video sequence"
value: "video"
- label: "Snapshot (Still image)"
value: "snapshot"
motion_sensor:
name: "Sensor"
description: "The binary entity that triggers the alert."
selector:
entity:
domain: binary_sensor
camera_entity:
name: "Camera"
description: "The source camera."
selector:
entity:
domain: camera
record_duration:
name: "Duration (video only)"
description: "Recording time in seconds."
default: 3
selector:
number:
min: 2
max: 8
step: 1
mode: slider
telegram_chat_id:
name: "Telegram Chat ID"
description: "The numerical identifier of the chat."
selector:
text: {}
notify_title:
name: "Notification title"
description: "Header of the Telegram message (will be bolded)."
default: "Alert"
selector:
text: {}
notify_text:
name: "Notification text"
description: "Accompanying text below the title."
default: "at {{ now().strftime('%H:%M') }}, on {{ now().strftime('%d.%m.%Y') }}."
selector:
text:
multiline: true
variables:
mode: !input capture_mode
var_title: !input notify_title
var_text: !input notify_text
trigger:
- platform: state
entity_id: !input motion_sensor
to: "on"
action:
# 1. Delay before capture action
- delay:
seconds: !input delay_capture
# 2. Routing to the selected mode
- choose:
# Branch 1: Video Mode
- conditions:
- condition: template
value_template: "{{ mode == 'video' }}"
sequence:
- action: camera.record
target:
entity_id: !input camera_entity
data:
filename: "/config/www/snapshots/temp_raw.mp4"
duration: !input record_duration
lookback: 0
- action: shell_command.process_alert_video
- action: telegram_bot.send_video
data:
target: !input telegram_chat_id
file: "/config/www/snapshots/alert_final.mp4"
caption: "<b>{{ var_title }}</b>\n{{ var_text }}"
parse_mode: "html"
# Branch 2: Snapshot Mode
- conditions:
- condition: template
value_template: "{{ mode == 'snapshot' }}"
sequence:
- action: camera.snapshot
target:
entity_id: !input camera_entity
data:
filename: "/config/www/snapshots/alert_snapshot.jpg"
- action: telegram_bot.send_photo
data:
target: !input telegram_chat_id
file: "/config/www/snapshots/alert_snapshot.jpg"
caption: "<b>{{ var_title }}</b>\n{{ var_text }}"
parse_mode: "html"
Currently only compatible with Telegram because of the video sequence, but could be adapted to another service.