Skip to content

Instantly share code, notes, and snippets.

@girs1982
Last active June 24, 2024 04:46
Show Gist options
  • Save girs1982/17e9ec031556c0264c03fed2daadedb9 to your computer and use it in GitHub Desktop.
Save girs1982/17e9ec031556c0264c03fed2daadedb9 to your computer and use it in GitHub Desktop.
blueprint:
name: Frigate - Telegram Notification nextgen By Gansta
description: Create automations to receive Snapshots and Clips from Frigate
domain: automation
input:
camera:
name: Frigate Camera
description: The name of the camera as defined in your Frigate configuration (/conf.yml).
target_chat:
name: Target Chat ID
description: The chat ID to which Telegram notifications will be sent.
notification:
name: Notification
description: 'Select "true" to disable notification, leave "false" to receive notification.'
selector:
select:
options:
- "true"
- "false"
default: "false"
base_url:
name: (Optional) Base URL
description: The external URL for your Home Assistant instance.
default: ""
zone_filter:
name: (Optional) Zone Filter
description: Only notify if object has entered a defined zone.
default: false
selector:
boolean: {}
variables:
form_camera: !input "camera"
saved_camera: "{{ form_camera }}"
payload: "{{ trigger.payload_json | default({}) }}"
camera: "{{ payload.get('after', {}).get('camera', saved_camera) }}"
camera_name: "{{ camera | replace('_', ' ') | title }}"
target_chat: !input "target_chat"
object: "{{ payload.get('after', {}).get('label', 'undefined') }}"
label: "{{ object | title }}"
entered_zones: "{{ payload.get('after', {}).get('entered_zones', []) }}"
type: "{{ payload.get('type', 'undefined') }}"
base_url: !input "base_url"
base_url_valid: "{{ base_url.startswith('http://') or base_url.startswith('https://') }}"
notification: !input "notification"
condition:
- "{{ type != 'end' }}"
- "{{ not zone_only or entered_zones|length > 0 }}"
- "{{ not zones|length or zones|select('in', entered_zones)|list|length > 0 }}"
- "{{ not labels|length or object in labels }}"
- "{{ not presence_entity or not is_state(presence_entity, 'home') }}"
- "{{ base_url_valid }}"
action:
- service: system_log.write
data:
message: "Payload received: {{ trigger.payload_json }}"
level: info
- service: system_log.write
data:
message: "Variables: id={{ id }}, camera={{ camera }}, camera_name={{ camera_name }}, target_chat={{ target_chat }}, object={{ object }}, label={{ label }}, entered_zones={{ entered_zones }}, type={{ type }}, base_url={{ base_url }}"
level: info
- service: downloader.download_file
data:
url: "http://192.168.80.244:5000/api/{{ camera }}/person/snapshot.jpg"
filename: "/tmp/snapshot.jpg"
- delay: '00:00:02'
- service: telegram_bot.send_photo
data:
target: "{{ target_chat }}"
disable_notification: "{{ notification == 'true' }}"
caption: "Person Detected. Camera: {{ camera_name }}"
file: "/tmp/snapshot.jpg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment