Frigate Mobile App Notifications

Tags: #<Tag:0x00007fc40aeaa6e8> #<Tag:0x00007fc40aeaa5f8> #<Tag:0x00007fc40aeaa508>

Frigate Mobile App Notification

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Works with both Android and iOS (>= 2021.5) mobile apps. It will even work with a notification group targeting both types of devices!

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.

The configurability for notifications is top notch. Since this blueprint is meant to used to create one automation per camera, you can specify filters limiting which zones and objects you want notifications for. Not only that, but you can disable notifications based on presence entities being “home” or not. This can be a person, device_tracker or a group combining multiple entities. You can also configure a cooldown which will limit the amount of back-to-back notifications you receive for that camera. Additionally, you can silence notifications for a particular camera for a predetermined and configurable amount of time.

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 in Frigate.
  • You can specify which zones to be notified about. This must be a list (e.g.):
        - backyard
  • You can specify what type of objects to be notified about. This must be a list (e.g.):
        - 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.

Blueprint

Frigate Notification Blueprint - GitHub

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
11 Likes

Great blueprint for Frigate.
However, is it possible to edit the blueprint for multiple cameras instead of just one?
Have 9 cams running and creating 9 identical automations seems a bit overwhelming. :slight_smile:

The automation created by this blueprint is designed to take advantage of the “single” run mode to support cool down and silence actions. You will also likely get to the point where you want to configure different options for each camera. For example, I use the presence filter on my indoor cameras but not my outdoor cameras, and the zone filter on my backyard camera but not my driveway camera.

Creating separate automations per camera increases your one time setup, but enables features you wouldn’t otherwise get and gives you greater flexibility to fine tune notifications per camera.

1 Like

Works great ! exactly what i needed! The only question. Is is possible to make the notification so that i need to actively remove the notification?

Not sure what you mean here. The notification stays in my tray until I view or dismiss it. Persistence is handled by the way notifications work on the device. Nothing that I can change in this blueprint as far as I know.

You’re properly right! Now that you mention it is seems absolutely better…
Anyway… Fantastic blueprint! :+1:

Does this blueprint require the Frigate custom component/integration to be installed?

It does. It uses the API proxy provided by the custom integration to display images and link to clips.

I’m sorry. I found the pull down button at the right of het notification to see the snapshot/ clip.

This blueprint is awesome. Thanks!

Great blueprint! Thanks!

Is it normal that if I click on the clip link as soon as I get it I get an error as if the clip is not ready yet and if I then click or refresh the browser page a few minutes later it works?

Yes. There is a known delay between when the event ends and the clip being written to disk. Should be less than 30 seconds. Frigate doesn’t tell us when it is done writing the file though.

Great blueprint!!!

Just a question: can it be adapted to use Telegram instead of App?

1 Like

I’d be interested in this as well

And PushOver… HA notify is limited to only 500/month… kinda sucks when you have cams… 9 of them :stuck_out_tongue:

Where did you get 500/month from? It’s 500/day per device. Which should be more than enough.

That being said, it should be possible to duplicate this blueprint and change the notify call to match the style of whichever service you use.

500 per day? Well that changes it… :slight_smile: Must have misunderstood the docs…

You are right, I tried to adapt for Telegram notification, but I’m able to have only snapshot, and not clips.I have this error:

2021-06-01 12:48:51 WARNING (SyncWorker_10) [homeassistant.components.telegram_bot] Status code 404 (retry #1) loading http://192.168.xxx.xxx:xxxx/api/events/1622544520.350811-oko8y8/study/clip.mp4

This looks great!
I’d love to get this working, but I run frigate on a dedicated Rpi4 (running Home Assistant OS, with frigate add-on). My main HA instance is on a NUC, would it be possible to run this blueprint from my main NUC HA instance? So far I’ve got the iOS notification working, but it needs tweaking to load the clip/ snapshot from the separate Rpi, as I get “Failed to load attachment Response status code 404”.

“silence future notifications” seem not working for me on my Iphone 6 (version 12.5.3)