Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Frigate Notification Blueprint
blueprint:
name: Frigate Notification
description: |
## Frigate Mobile App Notification
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/hunterjm/23c1588a9f2b8b9c2a62ffc364e17f8c
input:
camera:
name: Frigate Camera
description: The name of the camera as defined in your frigate configuration.
notify_device:
name: Device
description: The device must run the official Home Assistant app to receive notifications.
default: false
selector:
device:
integration: mobile_app
notify_group:
name: Notification Group
description: The name of the notification group to call.
default: ""
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
group_target: !input notify_group
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:
- choose:
- conditions: "{{ not group_target }}"
sequence:
- device_id: !input notify_device
domain: mobile_app
type: notify
message: 'A {{ label }} was detected on the {{ camera_name }} camera.'
data:
tag: '{{ id }}'
group: 'frigate-notification-{{ camera }}'
image: '/api/frigate/notifications/{{id}}/thumbnail.jpg?format=android' # Android
attachment: # iOS
url: '/api/frigate/notifications/{{id}}/thumbnail.jpg'
default:
- service: "notify.{{ group_target }}"
data:
message: 'A {{ label }} was detected on the {{ camera_name }} camera.'
data:
tag: '{{ id }}'
group: 'frigate-notification-{{ camera }}'
image: '/api/frigate/notifications/{{id}}/thumbnail.jpg?format=android' # Android
attachment: # iOS
url: '/api/frigate/notifications/{{id}}/thumbnail.jpg'
- 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' }}"
- choose:
- conditions: "{{ not group_target }}"
sequence:
- device_id: !input notify_device
domain: mobile_app
type: notify
message: 'A {{ label }} was detected on the {{ camera_name }} camera.'
data:
tag: '{{ id }}'
group: 'frigate-notification-{{ camera }}'
url: '{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4' # iOS
clickAction: '{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4' # Android
image: '/api/frigate/notifications/{{id}}/thumbnail.jpg?format=android' # Android
sound: none
attachment: # iOS
url: '/api/frigate/notifications/{{id}}/thumbnail.jpg'
# lazy: true
actions:
- action: URI
title: View Clip
uri: '{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4'
- action: URI
title: View Snapshot
uri: '{{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg'
- action: 'silence-{{ camera }}'
title: Silence Notifications
destructive: true
default:
- service: "notify.{{ group_target }}"
data:
message: 'A {{ label }} was detected on the {{ camera_name }} camera.'
data:
tag: '{{ id }}'
group: 'frigate-notification-{{ camera }}'
url: '{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4' # iOS
clickAction: '{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4' # Android
image: '/api/frigate/notifications/{{id}}/thumbnail.jpg?format=android' # Android
sound: none
attachment: # iOS
url: '/api/frigate/notifications/{{id}}/thumbnail.jpg'
# lazy: true
actions:
- action: URI
title: View Clip
uri: '{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4'
- action: URI
title: View Snapshot
uri: '{{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg'
- action: 'silence-{{ camera }}'
title: Silence Notifications
destructive: true
until: "{{ wait.trigger.payload_json['type'] == 'end' }}"
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: 'silence-{{ camera }}'
timeout:
seconds: !input cooldown
continue_on_timeout: false
- delay:
minutes: !input silence_timer
@EM-Tom
Copy link

EM-Tom commented Jan 18, 2022

Ah good to know, cheers! Are you using your NabuCasa URL for base or IP/hostname?

@BlueArcherX
Copy link

yes, it is currently set to NabuCasa URL and that's what I have had the most luck with.

@al3xcip
Copy link

al3xcip commented Jan 22, 2022 via email

@mifbody
Copy link

mifbody commented Jan 25, 2022

edit: I resolved my own issue -- it turns out even though the device came across proper in Home Assistant ("Doorbell") it was coming across in MQTT in lowercase "doorbell" - fixed the trigger and now it works.

@randyg503
Copy link

Is it possible to use this blueprint to avoid stationary object notifications? In other words, I need to ensure that 'entered_zones' has more than 1 zone (as suggested here: https://docs.frigate.video/guides/stationary_objects/)

@jackl123
Copy link

jackl123 commented Feb 8, 2022

Thanks for the great blueprint.

I'm new to Home Assistant so sorry if this is a dumb or overly vague question but I was wondering whether anyone could point me in the direction on how to approach the below issue I'm having:

The blueprint has been working fine since I added it a month ago - I've been receiving push notifications with thumbnails whenever my cameras detect a person. However, since 6th Feb evening, the notifications have stopped. I've restarted my Home Assistant, checked my phone notification settings and can confirm that Frigate is still detecting people, but I no longer receive notifications when a person is detected. AFAIK nothing's changed with my Home Assistant set up.

If anyone else has had the same issue and/or could advise how to approach fixing this, I'd much appreciate it. Thank you!

UPDATE: Solved by reinstalling the HACS Frigate integration

@Rowleys
Copy link

Rowleys commented Feb 13, 2022

Hi, Installed but when I try trigger this manual, it don't work

thanks

@hunterjm
Copy link
Author

Correct. This automation uses information from the trigger to determine what to do. You can not simply run the actions.

@EM-Tom
Copy link

EM-Tom commented Feb 22, 2022

EDIT:
If you are running Frigate via the Proxy Add-on and not getting images to your phone

A) Install the Frigate Custom Componant via HACS per the Blueprint documentation
B) Install the Frigate Integration and point it to your self hosted Frigate instance
C) ?????
D) PROFIT (Pics work)


Sorry to bring up the same Q. Notifications run fine, but the thumbnails do not show, I am wondering if this is because I am hosting frigate totally seperately and just using the proxy integration?

I've set my Base URL as https://myInstance.ui.nabu.casa/
Within HA via Frigate in the UI I can see my events are linked as the following

https://myInstance.ui.nabu.casa/api/hassio_ingress/kwYZ0xt9X7BiR8uiGJ2yWHyzTlMBSI9Fe8gLqvVv6Wk/api/events/1645535834.363036-kjjryn/snapshot.jpg?download=true

I can see in the blueprint we're looking at

{{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg

So unless i hard code what I assume is a temp auth token, no dice for snapshots?

Cheers

@Tuurkevg
Copy link

Tuurkevg commented Mar 2, 2022

Can you add the support in the script to have multiple camera's in 1 sript now i have lik e4 notifications from 4 different camera's while I want 1 cooldown for all the camera's. BTW this bleuprint is awesome!

@toddrob99
Copy link

This is great, but why no url/clickAction or actions for the first notification?

@Gibber
Copy link

Gibber commented May 29, 2022

Great blueprint!
When I click on the "View Clip" in the notification it just opens the Frigate tab of Home Assistant. Is it supposed to actually play the clip as well?

@felipecrs
Copy link

As 0.10.0 is now stable, should I use this blueprint or the 0.10.0 one?

@sys1aeg
Copy link

sys1aeg commented Aug 18, 2022

Hi
thank you for this blueprint !
looks like python maintenance has now made integers have a value - mine was not triggering needed to change blueprint to
fps: '{{ fps_value|int(0) if is_number(fps_value) or 5 }}'
giving fps_value a initial value of 0

@glbailey
Copy link

If you're looking for the actionable notifications on iphone, just swipe left on the notification. Options and buttons are there :-)

@sys1aeg
Copy link

sys1aeg commented Aug 19, 2022

Let me clarify - there was an error in the blueprint with an uninitialized integer variable
Which was causing automaton not to trigger

@chelming
Copy link

fwiw, it's still triggering just fine for me on 2022.8.6

@Symbiot78
Copy link

hi.. Trying to run the blueprint, but if I test (run actions) - I get this error ...

Error rendering variables: ValueError: Template error: int got invalid input 'unknown' when rendering template '{{ fps_value|int if is_number(fps_value) or 5 }}' but no default was specified

I have no idea what it means.

@sys1aeg
Copy link

sys1aeg commented Sep 7, 2022 via email

@Symbiot78
Copy link

@sys1aeg - thx... sometimes it stares right back at you :)

@Symbiot78
Copy link

Symbiot78 commented Sep 7, 2022

Made the error go away.. but unfortunately I am still not receiving notifications.
I have another notification - which does work.. but not this.
I selected my phone and ran the "run actions".. but to no avail. There's nothing in the logs I can find.

alias: Frigate - Notification - Martin Mobile
description: ""
use_blueprint:
path: hunterjm/frigate_0.10_notification.yaml
input:
camera: Carport
notify_device: 4cd07a06e55a8f9322d55e0686073fd5
update_thumbnail: true

@sys1aeg
Copy link

sys1aeg commented Sep 8, 2022 via email

@Symbiot78
Copy link

@sys1aeg - I can call the notify service and I get a test message.
if I run actions in the automation I get nothing.

I cannot see.. in the blueprint.. what it does as I just select my phone .. and that translates to some long ID code in the yaml.
but I don't know if the blueprint will run the notification part on it's own.

@janstadt
Copy link

janstadt commented Oct 3, 2022

Anyone having issues seeing the snapshot in the notification on IOS 16? After updating i dont see the snapshot, just the text.

@jbuggie
Copy link

jbuggie commented Nov 20, 2022

Nice blue print. Would be nicer if it can deal with multiple cameras instead of having to set up a rule for each one.

@Heisenberg2980
Copy link

Nice Blueprint, thanks!! I may try to update it to include alarm status as would like to be notified depending of the alarm (i.e. get notified if anyone is in the garden when alarm is in night mode)

@KookyKoalaJon
Copy link

Hi
thank you for this blueprint !
looks like python maintenance has now made integers have a value - mine was not triggering needed to change blueprint to
fps: '{{ fps_value|int(0) if is_number(fps_value) or 5 }}'
giving fps_value a initial value of 0

thank you so much I was messing around for over a week with this trying to figure it out till I found your comment edited the blueprint now it’s all working.

@felipecrs
Copy link

Guys, this blueprint isn't being updated anymore. Here's the new one:

https://community.home-assistant.io/t/frigate-mobile-app-notifications/311091/662

@sys1aeg
Copy link

sys1aeg commented Jan 24, 2023 via email

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