Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Calimerorulez/14164088af9d913c9e2e7d09680d9732 to your computer and use it in GitHub Desktop.
Save Calimerorulez/14164088af9d913c9e2e7d09680d9732 to your computer and use it in GitHub Desktop.
Frigate Notification Blueprint
blueprint:
name: Frigate Notification Cast
description: |
## Frigate Notification Cast
This blueprint will send a notification to your device when a Frigate event for the selected camera is fired. The notification will initially include the thumbnail of the detection, but will update to include actionable notifications allowing you to view the saved clip/snapshot when available, or silence the notification for a configurable amount of time.
With this blueprint, you may send the notification to multiple devices by leaving "Device" blank and instead use a [notification group][1].
### Required entities:
- Frigate Camera Name
- Mobile App Device **or** the name of a Notification Group
### Optional features:
- You can limit notifications to objects entering **any** pre-defined [zones][2] in Frigate.
- You can specify which [zones][2] to be notified about. This must be a list (e.g.):
```yaml
- backyard
```
- You can specify what type of [objects][3] to be notified about. This must be a list (e.g.):
```yaml
- person
- car
```
- You can disable notifications if a presence entity or group is "home".
- You can configure a cooldown for the camera to reduce the number of notifications when back-to-back events occur.
- You can silence future notifications for a defined amount of time through actionable notifications. This is helpful in situations where you know you will be triggering detections for an extended period of time, like when the kids are playing outside.
[1]: https://companion.home-assistant.io/docs/notifications/notifications-basic#sending-notifications-to-multiple-devices
[2]: https://blakeblackshear.github.io/frigate/configuration/cameras#zones
[3]: https://blakeblackshear.github.io/frigate/configuration/objects
domain: automation
source_url: https://gist.github.com/Calimerorulez/14164088af9d913c9e2e7d09680d9732
input:
camera:
name: Frigate Camera
description: The name of the camera as defined in your frigate configuration.
base_url:
name: (Optional) Base URL
description: >
The external url for your Home Assistant instance. This will default to a relative
URL and will open the clips in the app instead of the browser, which may cause issues
on some devices.
default: ""
zone_filter:
name: (Optional) Zone Filter
description: Only notify if object has entered a defined zone.
default: false
selector:
boolean:
zones:
name: (Optional) Trigger Zones
description: A list (-) of zones you wish to recieve notifications for.
default: []
selector:
object:
labels:
name: (Optional) Trigger Objects
description: A list (-) of objects you wish to recieve notifications for.
default: []
selector:
object:
presence_filter:
name: (Optional) Presence Filter
description: Only notify if selected presence entity is not "home".
default: ""
selector:
entity:
cooldown:
name: (Optional) Cooldown
description: Delay before sending another notification for this camera after the last event.
default: 30
selector:
number:
max: 300
min: 0
unit_of_measurement: seconds
silence_timer:
name: (Optional) Silence Notifications
description: >
How long to silence notifications for this camera when requested as part of the
actionable notification.
default: 30
selector:
number:
max: 300
min: 0
unit_of_measurement: minutes
mode: single
max_exceeded: silent
trigger:
platform: mqtt
topic: frigate/events
payload: !input camera
value_template: "{{ value_json['after']['camera'] }}"
variables:
id: "{{ trigger.payload_json['after']['id'] }}"
camera: "{{ trigger.payload_json['after']['camera'] }}"
camera_name: "{{ camera | replace('_', ' ') | title }}"
object: "{{ trigger.payload_json['after']['label'] }}"
label: "{{ object | title }}"
entered_zones: "{{ trigger.payload_json['after']['entered_zones'] }}"
type: "{{ trigger.payload_json['type'] }}"
base_url: !input base_url
zone_only: !input zone_filter
input_zones: !input zones
zones: "{{ input_zones | list }}"
input_labels: !input labels
labels: "{{ input_labels | list }}"
presence_entity: !input presence_filter
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') }}"
action:
- service: media_player.play_media
target:
entity_id: media_player.woonkamer_hub
data:
media_content_type: "video/mp4"
media_content_id: "{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4"
- repeat:
sequence:
- wait_for_trigger:
- platform: mqtt
topic: frigate/events
payload: "{{ id }}"
value_template: "{{ value_json['after']['id'] }}"
timeout:
minutes: 2
continue_on_timeout: false
- condition: template
value_template: "{{ wait.trigger.payload_json['type'] == 'end' }}"
until: "{{ wait.trigger.payload_json['type'] == 'end' }}"
- delay:
minutes: !input silence_timer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment