Skip to content

Instantly share code, notes, and snippets.

@calipee
Last active July 18, 2022 12:46
Show Gist options
  • Save calipee/2e70566f6fb6377ae6d1e38f485112ac to your computer and use it in GitHub Desktop.
Save calipee/2e70566f6fb6377ae6d1e38f485112ac to your computer and use it in GitHub Desktop.
Blueprint for a clickable notification with a snapshot of your camera pointing to an URL.
blueprint:
name: Send Camera Snapshot
description: Send camera snapshot to mobile app
domain: script
input:
camera:
name: Camera
description: The camera which creates the snapshot
selector:
entity:
domain: camera
notify_device:
name: Device to notify
description: Device needs to run the official Home Assistant app to receive notifications
selector:
device:
integration: mobile_app
is_ios:
name: Is it an iOS device?
description: Toggle if your selected device runs iOS, default is Android
selector:
boolean:
default: false
notification_title:
name: Notification title (Optional)
description: "test"
default: "Camera Snapshot!"
notification_message:
name: Notification message (Optional)
description: "test"
default: "{{ camera }} snapshot!"
url:
name: URL (Optional)
description: "URL to where notification should link"
default: "/lovelace/0"
delay:
name: Delay (Optional)
description: Wait before creating camera snapshot
default: 0
selector:
number:
min: 0
max: 60
unit_of_measurement: seconds
mode: slider
variables:
camera: !input camera
notify_device: !input notify_device
is_ios: !input is_ios
notification_title: !input notification_title
notification_message: !input notification_message
delay: !input delay
snapshot_create_file_path: "/media/snapshots/snapshot_{{ states[camera].object_id }}.jpg"
snapshot_access_file_path: "{{ snapshot_create_file_path | replace('/media','/media/local') }}"
url: !input url
sequence:
- delay: "{{ delay }}"
- service: camera.snapshot
entity_id: !input camera
data:
filename: "{{ snapshot_create_file_path }}"
- device_id: !input notify_device
domain: mobile_app
type: notify
title: "{{ notification_title }}"
message: "{{ notification_message }}"
data: >
{% set android_data = {"image": "%s", "clickAction": "%s"} | format(snapshot_access_file_path, url) %}
{% set ios_data = {"attachment": {"url": "%s", "content_type": "JPEG"}, "url": "%s"} | format(snapshot_access_file_path, url) %}
{{ ios_data if is_ios else android_data }}
mode: restart
@calipee
Copy link
Author

calipee commented Jul 18, 2022

This blueprint was heavily inspired by 📸 Send camera snapshot notification on motion.
The main point of my automation is increased privacy due to saving the snapshots in the /media instead of /www which is publicly accessible and you are also not required to use a motion sensor. You can just include this script in any automation you wish to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment