You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I got into the weeds setting up notifications through Home Assistant, using Nick's helpful guide for 0.14 as a starting point, I did some tweaking of text and actions. I'm not completely satisfied just yet so will keep iterating, but let me know your ideas for improvements.
My thoughts:
I find it useful to mark an alert as reviewed from a notification action, where you see a family member/neighbour in the thumbnail. This is implemented below.
I'm not sure what I prefer to see in the notification attachment, but I'm leaning towards a simple thumbnail of the object detected.
It would be useful if we could associate event IDs with objects to prioritise showing the thumbnail of a person over a car for example. This doesn't seem to be possible with the current MQTT payload.
I'd like to try using a notification action to toggle between the gif preview/thumbnail/video within the notification itself. I think all the necessary data is included in the notification action event so should be possible.
I'm a bit torn between keeping the user in HA or linking to the Frigate app.
I'm no Jinja Ninja but I'm starting to get the hang of it.
Here's my notification automation:
alias: Frigate Notification Reviewdescription: A notification for an alert created in Frigate for reviewtriggers:
- alias: topic published to /reviewstrigger: mqtttopic: frigate/reviewsid: frigate-reviewpayload: alertvalue_template: "{{ value_json['after']['severity'] }}"variables:
zones: "{{ trigger.payload_json['after']['data']['zones'] }}"camera: "{{ trigger.payload_json['after']['camera'] }}"id: "{{ trigger.payload_json['after']['id'] }}"event_id: "{{ trigger.payload_json['after']['data']['detections'][0] }}"before_objects: "{{ trigger.payload_json['before']['data']['objects'] }}"objects: "{{ trigger.payload_json['after']['data']['objects'] }}"sub_labels: "{{ trigger.payload_json['after']['data']['sub_labels'] }}"events: "{{ trigger.payload_json['after']['data']['detections'] }}"type: "{{ trigger.payload_json['type'] }}"before_severity: "{{ trigger.payload_json['before']['severity'] }}"
- alias: custom event for testing purposestrigger: eventid: frigate-reviewevent_type: test_frigate_review_payloadvariables:
zones: "{{ trigger.event.data.payload_json['after']['data']['zones'] }}"camera: "{{ trigger.event.data.payload_json['after']['camera'] }}"id: "{{ trigger.event.data.payload_json['after']['id'] }}"event_id: "{{ trigger.event.data.payload_json['after']['data']['detections'][0] }}"before_objects: "{{ trigger.event.data.payload_json['before']['data']['objects'] }}"objects: "{{ trigger.event.data.payload_json['after']['data']['objects'] }}"sub_labels: "{{ trigger.event.data.payload_json['after']['data']['sub_labels'] }}"events: "{{ trigger.event.data.payload_json['after']['data']['detections'] }}"type: "{{ trigger.event.data.payload_json['type'] }}"before_severity: "{{ trigger.event.data.payload_json['before']['severity'] }}"conditions:
- alias: Skip alert updates unless zones addedcondition: templatevalue_template: >- {{ type != "update" or before_zones | length < after_zones | length or before_severity != "alert" }}actions:
- choose:
- conditions:
- condition: triggerid: frigate-reviewsequence:
- variables:
in_progress: "{{ type != 'end' }}"ha_domain: https://ha.mydomain.comfrigate_domain: https://nvr.mydomain.comfrigate_review_url: "{{ frigate_domain }}/review?id={{ id }}"frigate_camera_url: "{{ frigate_domain }}/#{{ camera }}"review_preview_path: /api/frigate/notifications/{{ id }}/review_preview.gif?format=tsevent_clip_path: /api/frigate/notifications/{{ event_id }}/{{ camera }}/clip.mp4event_snapshot_path: /api/frigate/notifications/{{ event_id }}/snapshot.jpgevent_thumbnail_path: /api/frigate/notifications/{{ event_id }}/thumbnail.jpgobject_icon: >- {% if 'person' in objects and in_progress -%} mdi:account-clock-outline {%- elif 'person' in objects %} mdi:account-outline {%- elif 'person-verified' in objects %} mdi:account-check-outline {%- elif 'package' in objects %} mdi:package-variant-closed-check {%- elif 'amazon' in objects or 'fedex' in objects or 'ups' in objects %} mdi:truck-delivery-outline {%- elif 'dog' in objects %} mdi:dog-service {%- elif 'cat' in objects %} mdi:cat {%- elif 'car' in objects or 'car-verified' in objects %} mdi:car-outline {%- else -%} mdi:cctv {%- endif %}labels: >- {% set data = namespace(labels=[]) %} {% for obj in objects %} {% if "-verified" in obj %} {% else %} {% set data.labels = data.labels + [obj] %} {% endif %} {% endfor %} {% set data.labels = data.labels + sub_labels %} {{ data.labels | unique | list }}labels_sanitised: "{{ labels | map('replace', '_', ' ') | map('title') | list }}"labels_formatted: >- {% set count = labels_sanitised | length %} {% set last = labels_sanitised[count - 1] %} {% if count > 1 %} {{ labels_sanitised[:count - 1] | join(", ") }} and {{ last }} {% else %} {{ last }} {% endif %}zones_sanitised: "{{ zones | map('replace', '_', ' ') | map('title') | list }}"zones_formatted: >- {% set count = zones_sanitised | length %} {% set last = zones_sanitised[count - 1] %} {% if count > 1 %} {{ zones_sanitised[:count - 1] | join(", ") }} and {{ last }} {% else %} {{ last }} {% endif %}detect_formatted: |- {% if in_progress -%} {{ labels_formatted }} detected {%- else -%} A {{ labels_formatted }} {{ 'was' if labels | length == 1 else 'were' }} {%- endif %}action_view_snapshot:
action: URItitle: View Snapshoturi: "{{ ha_domain }}{{ event_snapshot_path }}"icon: sfsymbols:photoaction_view_live:
action: URItitle: View Liveuri: entityId:camera.{{ camera }}icon: sfsymbols:livephotoaction_review:
action: URItitle: Reviewuri: "{{ frigate_review_url }}"icon: sfsymbols:play.circleaction_preview:
action: URItitle: Previewuri: "{{ review_preview_path }}"icon: sfsymbols:play.circleaction_set_reviewed:
action: FRIGATE_REVIEWEDtitle: Mark as Reviewedactions: |- {% if in_progress %} {{ [action_view_snapshot, action_view_live] }} {% else %} {{ [action_preview, action_review, action_set_reviewed] }} {% endif %}
- action: notify.our_phonesmetadata: {}data:
title: "{{ camera | title }} Alert"message: "{{ detect_formatted }} on {{ zones_formatted }}"data:
tag: "{{ id }}"group: frigate-{{ camera }}channel: Frigate Alertsimportance: "{{ 'high' if in_progress else 'default' }}"priority: highttl: 0visibility: publicalert_once: truenotification_icon: "{{ object_icon }}"url: "{{ review_preview_path }}"clickAction: "{{ event_clip_path }}"entity_id: |- {% if in_progress -%} camera.{{ camera }} {%- else -%} {{ undefined }} {%- endif %}image: "{{ ha_domain }}{{ event_thumbnail_path }}"attachment:
url: |- {% if in_progress -%} {{undefined}} {%- else -%} {{ ha_domain }}{{ event_thumbnail_path }} {%- endif %}actions: "{{ actions }}"action_data:
review_id: "{{ id }}"default: []mode: parallelmax: 10
And here's an automation to handle the Mark as Reviewed notification action:
alias: Frigate Set Revieweddescription: Action handler for Frigate review notification to set a review as viewedtriggers:
- alias: FRIGATE_REVIEWED notification action receivedtrigger: eventevent_type: mobile_app_notification_actionevent_data:
action: FRIGATE_REVIEWEDvariables:
tag_id: |- {% if trigger.event.data.tag is defined %} {{ trigger.event.data.tag }} {% else %} {{ undefined }} {% endif %}action_data_id: |- {% if trigger.event.data.action_data is defined %} {{ trigger.event.data.action_data.review_id }} {% else %} {{ undefined}} {% endif %}conditions: []actions:
- choose:
- conditions:
- alias: An id is suppliedcondition: orconditions:
- alias: Android tag is suppliedcondition: templatevalue_template: "{{ tag_id is defined }}"
- alias: iOS action_data is supplied with review_idcondition: templatevalue_template: "{{ action_data_id is defined }}"sequence:
- variables:
review_id: >- {{ tag_id if (tag_id is defined and tag_id) else action_data_id }}
- alias: Call Frigate REST API to mark review as watchedaction: rest_command.frigate_set_reviewedmetadata: {}data:
id: "{{ review_id }}"response_variable: reviewed_resultdefault: []mode: parallelmax: 10
And here's the RESTful action to call the Frigate API with an id parameter:
frigate_set_reviewed:
url: "http://x.x.x.x:5000/api/reviews/viewed"method: POSTcontent_type: 'application/json; charset=utf-8'payload: '{"ids":["{{ id }}"]}'
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I got into the weeds setting up notifications through Home Assistant, using Nick's helpful guide for 0.14 as a starting point, I did some tweaking of text and actions. I'm not completely satisfied just yet so will keep iterating, but let me know your ideas for improvements.
My thoughts:
Here's my notification automation:
And here's an automation to handle the Mark as Reviewed notification action:
And here's the RESTful action to call the Frigate API with an
id
parameter:Beta Was this translation helpful? Give feedback.
All reactions