Frigate Mobile App Notifications

Does anyone else get 404 errors when opening attachments? They open with in the HA app. my HA instance is behind Nginx Proxy Manager. The notification displays an image fine.

Edit: Seems that it might be related to the fact the default option in the list is to view clip. I dont have clips enabled hence the 404. If i view snapshot it opens the image but it still shows it in the app and i have no UI other than just an image.

2 Likes

I skimmed through this thread and didnā€™t see someone post this issue.

On iOS. When I click on the notification, takes me to the snapshot but I canā€™t seem to exit out of the image and cannot access rest of the app. Anyone else figure out how to exit out of just seeing the screenshot?

4 Likes

Literally posted that above your comment :smiley:

Many thanks for this awesome blueprint.
Also having the same issue as above, when clicking on and loading the screenshot I am then unable to exit it and or get back in to the HA app (ios).

I note when getting stuck like this, if I exit the app (although being ios it never actually refreshes anything) and reopen the app I get the yellow cog bottom right of app screen (connection) and the only way I can solve this is to switch from wifi to 4g or vice versa to get the connection and therefore the app back

1 Like

One Question, i want to get notified between 11pm and 8am. How to configure this condition into the blueprint?

I see the same thing, its not just you :smiley: Not a fix, but slightly easier than toggling wifi. Go into the IOS HA App > App Configuration > General > Turn off ā€œRemember Last Pageā€. Now when you kill the app and re-open it, you will land on the main page.

4 Likes

Thanks Chris your a star, never thought of that, it actually makes my life easier as I often lock the app up testing things I have created that donā€™t work :+1:t2:

I added a channel to this but did not work, any suggest?

    ttl: 0
    priority: high
    channel: alarm_stream

Just wanted to bump this, love this blueprint hi but this clip-escape issue is really strange

The reason it opens in Home Assistant on iOS instead of Safari is because the iOS app tries to be ā€œhelpfulā€ and opens any links with the same external URL as your HA instance inside the app.

I solved this by creating a new subdomain and proxying it to my HA instance, then setting the new DIFFERENT domain as the ā€œbase URLā€ in this blueprint. That will force the links to open in Safari. This obviously only works if you arenā€™t using Nabu Casa remote access.

You can also force the app to open the main dashboard every time in App Configuration ā†’ General ā†’ Uncheck ā€œRemember Last Pageā€

I love the blueprint. However, I have zones setup and I still get alerts even though I tell the automation to only alert inside the zone. When viewing the trace, this section

'{{ not zone_only or entered_zones|length > 0 }}'

Shows this result:

" This node was not executed and so no further trace information is available. "

Is it not getting any zone information from the integration?

This blueprint is awesome! Thank you.

Do anyone know if it is possible to internationalize blueprints?

Here is the payload when it alerts:

 payload: >-
      {"before": {"id": "1630108494.379011-pohik5", "camera": "driveway",
      "frame_time": 1630108494.575657, "label": "person", "top_score":
      0.68359375, "false_positive": false, "start_time": 1630108494.379011,
      "end_time": null, "score": 0.68359375, "box": [485, 67, 511, 151], "area":
      2184, "region": [340, 0, 640, 300], "current_zones": [], "entered_zones":
      [], "thumbnail": null}, "after": {"id": "1630108494.379011-pohik5",
      "camera": "driveway", "frame_time": 1630108498.981612, "label": "person",
      "top_score": 0.689453125, "false_positive": false, "start_time":
      1630108494.379011, "end_time": null, "score": 0.67578125, "box": [484, 67,
      508, 156], "area": 2136, "region": [340, 0, 640, 300], "current_zones":
      [], "entered_zones": [], "thumbnail": null}, "type": "update"}

The entered zones is empty yet I have a setting for it not to alert unless entering the zone.

This is the automation config:

description: ''
use_blueprint:
  path: hunterjm/frigate_notification.yaml
  input:
    camera: driveway
    notify_device: f4dfb8...c24c6c
    zone_filter: true
    zones:
      - drivewayclosein
    labels:
      - person
    cooldown: 60

Great BluePrint. Thanks for your job.

I donā€™t know why itā€™s not working for meā€¦ My setup is simple as could beā€¦ All running on Home Assistant Blue.

alias: Driveway Motorcycle Notification
description: ''
use_blueprint:
  path: hunterjm/frigate_notification.yaml
  input:
    camera: Driveway
    notify_device: bc7363883226ffdc36652f57524aff37
    labels:
      - motorcycle

camera.driveway_motorcycle contains a snapshot of when the last motorcycle was detected.

Any help appreciated. Thanks in advance.

Case matters. Is your camera in Frigate defined as Driveway or driveway

cameras:
  Driveway:
    ffmpeg:
      inputs:
        - path: rtsp://admin:[email protected]/cam/realmonitor?channel=1&subtype=0
          roles:
            # - rtmp
            - clips
        - path: rtsp://admin:[email protected]/cam/realmonitor?channel=1&subtype=2
          roles:
            - detect
    width: 1920
    height: 1080
    fps: 5
    objects:
      track:
        - person
        - car
        - motorcycle
        - truck
        - cat
        - dog
    rtmp:
      enabled: False
    clips:
      enabled: True
      pre_capture: 5
      post_capture: 5
      retain:
        default: 3

Edit: Figured it out - canā€™t have a trailing slash when you enter the Base URL.

Anyone get this working using a Nabu Casa external URL? I added my Nabu Casa URL to the (Optional) Base URL section as such: https://redacted.ui.nabu.casa/

When testing the automation, I just see an error in my HA logs:

Logger: homeassistant.components.automation.notify_person_in_backyard
Source: components/automation/__init__.py:454
Integration: Automation ([documentation](https://www.home-assistant.io/integrations/automation), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+automation%22))
First occurred: 5:41:32 PM (1 occurrences)
Last logged: 5:41:32 PM

Error rendering variables: UndefinedError: 'dict object' has no attribute 'payload_json'

@hunterjm Iā€™m trying to use the Blueprint with Microsoft Teams. I do get the text message but, canā€™t seem to get the image into the message as well.

According to the Notify help for Teams there should be the option:

title: Title of the message.
message: Message that will be added.
data:
  image_url: URL_OF_IMAGE

How should I adjust the template to get this to function :slight_smile:

please can you explain better how to and where exactly put code, to have android notification without delay?

with this one, i have delay

blueprint:
  name: Frigate Notification
  description: "## Frigate Mobile App Notification\n\nThis 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.\n\nWith this\
    \ blueprint, you may send the notification to multiple devices by leaving \"Device\"\
    \ blank and instead use a [notification group][1].\n\n### Required entities:\n\
    \  - Frigate Camera Name\n  - Mobile App Device **or** the name of a Notification\
    \ Group\n\n### Optional features:\n  - You can limit notifications to objects\
    \ entering **any** pre-defined [zones][2] in Frigate.\n  - You can specify which\
    \ [zones][2] to be notified about. This must be a list (e.g.):\n    ```yaml\n\
    \    - backyard\n    ```\n  - You can specify what type of [objects][3] to be\
    \ notified about. This must be a list (e.g.):\n    ```yaml\n    - person\n   \
    \ - car\n    ```\n  - You can disable notifications if a presence entity or group\
    \ is \"home\".\n  - You can configure a cooldown for the camera to reduce the\
    \ number of notifications when back-to-back events occur.\n  - 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.\n\n\
    [1]: https://companion.home-assistant.io/docs/notifications/notifications-basic#sending-notifications-to-multiple-devices\n\
    [2]: https://blakeblackshear.github.io/frigate/configuration/cameras#zones\n[3]:\
    \ https://blakeblackshear.github.io/frigate/configuration/objects\n"
  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.0
          min: 0.0
          unit_of_measurement: seconds
          mode: slider
          step: 1.0
    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.0
          min: 0.0
          unit_of_measurement: minutes
          mode: slider
          step: 1.0
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
        attachment:
          url: /api/frigate/notifications/{{id}}/thumbnail.jpg
          data:
            priority: high
            ttl: 0          
  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
        attachment:
          url: /api/frigate/notifications/{{id}}/thumbnail.jpg
          data:
            priority: high
            ttl: 0 
- 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'
            clickAction: '{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4'
            image: /api/frigate/notifications/{{id}}/thumbnail.jpg?format=android
            data:
              priority: high
              ttl: 0 
            sound: none
            attachment:
              url: /api/frigate/notifications/{{id}}/thumbnail.jpg
            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'
            clickAction: '{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4'
            image: /api/frigate/notifications/{{id}}/thumbnail.jpg?format=android
            data:
              priority: high
              ttl: 0 
            sound: none
            attachment:
              url: /api/frigate/notifications/{{id}}/thumbnail.jpg
            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'