Frigate Mobile App Notifications

Interesting I will have to check mine since it has basically stopped functioning at all.

For those running Frigate on an external server like me, you need to modify this Blueprint:

Old:
clickAction: ā€˜{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4ā€™

New:
clickAction: ā€™ {{base_url}}/api/events/{{id}}/clip.mp4ā€™

Thereā€™s multiple entries in the Blueprint that are similar to this. Note the removal of the ā€œcameraā€ tag.

2 Likes

Looking at the trace timeline, the first block is skipped due to the payload['after']['entered_zone'] (aka initial_entered_zones) not having any items in common with the zones list:

alias: Notify on new object
choose:
  - conditions:
      - '{{ not zone_only or initial_entered_zones|length > 0 }}'
      - >-
        {{ not zones|length or zones|select('in',
        initial_entered_zones)|list|length > 0 }}
      - '{{ not initial_home }}'

But then the following logic that runs in a 2 minute timeout repeat loop will notify without checking against zones.

The variables at the point in the trace are:

loitering: 0
new_snapshot: true
home: false
presence_changed: false
last_zones:
  - street
entered_zones:
  - street
zone_filter: true
stationary_moved: false
zone_only_changed: false
entered_zones_changed: false

which makes the condition true due to new_snapshot and results in notification.

alias: Notify on loitering or significant change
choose:
  - conditions: >-
      {{ loitering or (not home and zone_filter and (new_snapshot or
      presence_changed or stationary_moved or zone_only_changed or
      entered_zones_changed)) }}
    sequence:
      - choose:
          - conditions: '{{ not group_target }}'
            sequence:
              - device_id: 7d13f6066dbff052277a1f0b377cc186
                domain: mobile_app
                type: notify
                message: >-
                  A {{ label }} {{ 'is loitering' if loitering else 'was
                  detected' }} on the {{ camera_name }} camera.

This is the trace timeline graphic showing the first notification was skipped, but then the notification in the repeat loop happened.

Has anyone managed to get this working correctly with Frigate 0.11.0? Iā€™m currently on 0.11.0-rc1, but Iā€™ve also tried 0.11.0-beta7; no dice either way.

I have a feeling Iā€™m doing something wrong, but wanted to see if itā€™s possible to get this configured with the latest version of Frigate.

Iā€™m running Frigate, Home Assistant, and Mosquitto in Docker.

Mine will occasionally work properly on my one camera but its like once in a blue moon that it does. Diving into the code to figure out whatā€™s wrong is beyond me, buts its whatā€™s holding me back from really liking frigate so far.

I really need to just do my own notification but I always find those to be a pain to set up.

I cannot get the notification to work. I run Frigate NVR 3.1 freshly installed.
I downloaded the blueprint, added, added the name (same name as Frigate config) and mobile device but I do not get any notification.

When I do test run automation this is the trace.

choose:
  - alias: Silence New Object Notifications
    conditions:
      - condition: trigger
        id: silence
    sequence:
      - service: automation.turn_off
        target:
          entity_id: '{{ this.entity_id }}'
        data:
          stop_actions: false
      - delay:
          minutes: 30
      - service: automation.turn_on
        target:
          entity_id: '{{ this.entity_id }}'
  - alias: Frigate Event
    conditions:
      - condition: trigger
        id: frigate-event
      - '{{ is_state(this.entity_id, ''on'') }}'
      - >-
        {{ not this.attributes.last_triggered or (now() -
        this.attributes.last_triggered).seconds > cooldown }}
    sequence:
      - variables:
          id: '{{ trigger.payload_json[''after''][''id''] }}'
          object: '{{ trigger.payload_json[''after''][''label''] }}'
          label: '{{ object | title }}'
          initial_home: '{{ presence_entity != '''' and is_state(presence_entity, ''home'') }}'
          initial_entered_zones: '{{ trigger.payload_json[''after''][''entered_zones''] }}'
      - alias: Notifications enabled for object label
        condition: template
        value_template: '{{ not labels|length or object in labels }}'
      - alias: Notify on new object
        choose:
          - conditions:
              - '{{ not zone_only or initial_entered_zones|length > 0 }}'
              - >-
                {{ not zones|length or zones|select('in',
                initial_entered_zones)|list|length > 0 }}
              - '{{ not initial_home }}'
            sequence:
              - choose:
                  - conditions: '{{ not group_target }}'
                    sequence:
                      - device_id: 8114859d871ac9fe2e3c68be6c46804c
                        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
                          clickAction: >-
                            {{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4
                          ttl: '{{ iif(critical, 0, 3600000) }}'
                          priority: '{{ iif(critical, ''high'', ''normal'') }}'
                          url: >-
                            {{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4
                          attachment:
                            url: /api/frigate/notifications/{{id}}/thumbnail.jpg
                          push:
                            interruption-level: '{{ iif(critical, ''critical'', ''active'') }}'
                          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 New Notifications
                              destructive: true
                default:
                  - service: notify.{{ group_target }}
                    data:
                      message: >-

I solved it finally, after many hours and alot of coffee.
The issue was that I put 8123 as MQTT port and it should have been 1883. Now I get my notices, I almost was about to sell my Coral :smile:

Just tried adding that to my config as I previously had nothing there for port. Fingers crossed it works for me.

1 Like

If your running the test from the the Automation functions in HA - you wonā€™t get anything. The automation created by the blueprint uses data that is sent from Frigate to HA in the MQTT message and in test mode, there is nothing there. Itā€™s just easier to walk past the camera and not be wondering if you have successful ran the automation the right way or not.

1 Like

Yes working for me after trials. My MQTT config in HA was unsubscribed somehow. Giving it a tickle fired it right back up

1 Like

I decided to have a go at the blueprints again today. I ran into exactly the same issue. In addition, the notifications would stop if I didnā€™t specify a label. Those are supposed to be optional but the automation always returns false and stops if I donā€™t put something in the labels section. Not a biggie since I only want person notifications anyway. However, the bigger issue is the no attribute error.

image

So no change. The only thing different now than before is Iā€™m running Frigate rc11 instead of 10. I was hoping that would help but it didnā€™t.

Thanks for the update.
I really need to sit down and just do my own notification but I am not at all familiar with mqtt so I will need to muddle through the trigger bit and I have been procrastinating it.

Edit to add* Interestingly enough the camera that will at times fire notifications properly had a label specified. So I just added labels to the other to see if it starts working.

Well on a whim I tried setting up the notifications for frigate using the docs.

For anyone looking at the wall of templates and worrying about figuring it out donā€™t.
All you need to do is copy and paste in you remote access url into the spot in the automation.

Thatā€™s it they are now working fine.

Have you found a solution to this? i am experiencing exactly the same issue.

Hi @Keltere ,
Iā€™m a total beginner with HA and Frigate. Iā€™m interested in your improvement and having the possibility to send notification during a period of time. I looked at your blueprint and I donā€™t understand why you wrote the conditions as you did. Wouldnā€™t it be simpler to write it like this :

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'') }}'
  - condition: sun
    after: sunset
    after_offset: !input sunset_offset
  - condition: sun
    before: sunrise
    before_offset: !input sunrise_offset

Thx for your work anyway !

I am using an external frigate server as well.
Did you have to replace any other lines or only the ones that start with clickAction?

From my recollection, any line with:

{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}

in it.

It appears that the Cooldown period includes non-Trigger objects also, i.e. my Frigate is setup to track person and car objects, however in the Blueprint I only want to be notified about person objects. Yesterday a car and then a person event were sent within the Cooldown period. I didnā€™t get the car notification (which is what Iā€™d expect), but I then didnā€™t get the person notification either as it was within Cooldown period. I would have expected the car notifications to be excluded from the Cooldown.

This is a long thread, apologies if this has come up already - Iā€™ve tried a scroll / search with no luckā€¦

Using iOS with a base URL set - I got a notification via this Blueprint, clicked on ā€œview snapshotā€, it took me to said snapshot but I now cannot exit out of the snapshot from the HA Companion App! Iā€™ve force closed the app, changed the URL so that it fails to connect (to try and refresh) but nothing is working :sob: Am I going to have to delete the app & reinstall to fix this?

EDIT: I didnā€™t search well enough, tried again and found the solution here

I have a camera with zones 1 and 2 (named doorbell and street) configured. So I used this blueprint to notify me whenever a person object entered zone doorbellā€¦ but unfortunately it doesnā€™t work as expected. It sends me notifications about any event in any of the zones :confused:

Iā€™m not sure if itā€™s a problem with my configuration (although events are accurately detected in the frigate), or if itā€™s a problem with the blueprint itselfā€¦

Can anyone check if my settings are correct?

  • Home Assistant Version: 2022.08.3
  • Frigate Version: 0.10.1
  • Frigate Integration Version: 2.3
alias: Frigate Notification (0.10.0)
description: ""
use_blueprint:
  path: hunterjm/frigate_0.10_notification.yaml
  input:
    camera: Entrada
    notify_device: f38bc80XXXXXXX1e50
    base_url: https://XXXXXXX.tk
    zones:
      - doorbell
    critical: true

My frigate.yml:

################################################################
mqtt:
  host: 192.168.0.100
  topic_prefix: frigate
  client_id: frigate
  user: XXXXXX
  password: XXXXXX
################################################################
detectors:
  cpu1:
    type: cpu
  cpu2:
    type: cpu
################################################################

cameras:
  Entrada:
    ffmpeg:
      inputs:
        - path: rtsp://USER:[email protected]:554/user=USER_password=PW_channel=1_stream=0.sdp?real_stream
          roles:
            - snapshots
            - record
            - detect
    detect:
      width: 1280
      height: 960
      fps: 5
    objects:
      track:
        - person
        - car
        - motorcycle   
        - bicycle
        - dog
        - cat
    record:
      enabled: True
      events:
        retain:
          default: 1
        max_seconds: 10 
        pre_capture: 2
        required_zones:
          - doorbell
          - street
    zones:
      doorbell:
        coordinates: 38,458,211,960,1061,960,791,741,534,515,412,426
        objects:
          - person
      street:
        coordinates: 1058,960,1280,960,1280,462,580,172,540,155,429,168,243,41,206,162,270,254,428,417,586,560
        objects:
          - person
          - car
          - motorcycle   
          - bicycle
          - dog
          - cat


snapshots:
  enabled: true
  timestamp: true
  bounding_box: true
  crop: False
  height: 800
  retain:
    default: 3
    objects:
      person: 3
      car: 3
      motorcycle: 3
  required_zones:
    - doorbell
    - street

Update :warning:: The problem was in the blueprint code, unfortunately it has some problematic lines!

The solution was to use this Fork with some corrections and optimizations: Frigate 0.10 Notifications Ā· GitHub

2 Likes