Frigate, How to get the detected object clip image to notifications for automation?

I have tried using the frigate notification blueprint which didn’t work for me for some reason. Currently, I have an automation to send me a message if a person is detected but I also want it to show a clip/image of what it detected (like the blueprint)
image

1 Like

You can see the example here-

automation:
  - alias: When a person enters a zone named yard
    trigger:
      platform: mqtt
      topic: frigate/events
    condition:
      - "{{ trigger.payload_json['after']['label'] == 'person' }}"
      - "{{ 'yard' in trigger.payload_json['after']['entered_zones'] }}"
    action:
      - service: notify.mobile_app_pixel_3
        data_template:
          message: "A {{trigger.payload_json['after']['label']}} has entered the yard."
          data:
            image: "https://url.com/api/frigate/notifications/{{trigger.payload_json['after']['id']}}/thumbnail.jpg"
            tag: "{{trigger.payload_json['after']['id']}}"
            when: '{{trigger.payload_json["after"]["start_time"]|int}}'
1 Like

thanks for sharing, i tried putting it in and seems like I got an error, my camera is called ‘Carport-Front’ and atm i don’t use any zones so it detects the whole camera (planning to use zones when 0.9.0 is in full release)

Syntax error because when: is misplaced.
Try this-

alias: Notify of events
trigger:
  - platform: mqtt
    topic: frigate/events
condition:
  - "{{ trigger.payload_json['after']['label'] == 'person' }}"
action:
  - service: notify.mobile_app_ming_s_s10
    data:
      message: 'A {{trigger.payload_json["after"]["label"]}} was detected.'
      data:
        # this URL should work if you use Frigate Addon.
        image: 'http://ccab4aaf-frigate:5000/api/events/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg'
1 Like

The config works, just have to head out to the carport and see if it works. I also have frigate running on docker outside of HA on ‘http://10.69.40.2:5000/’. I’m assuming we are using the frigate ip instead of HA?

Edit: Just went out to test it and its working perfectly, thank you so much, really helped out :slight_smile:

Correct! You must replace the URL if you are not using Frigate addon.

alias: Notify of events
trigger:
  - platform: mqtt
    topic: frigate/events
condition:
  - "{{ trigger.payload_json['after']['label'] == 'person' }}"
action:
  - service: notify.mobile_app_ming_s_s10
    data:
      message: 'A {{trigger.payload_json["after"]["label"]}} was detected.'
      data:
        image: "http://10.69.40.2:5000/api/frigate/notifications/{{trigger.payload_json['after']['id']}}/thumbnail.jpg"
1 Like

Yep, I have tried that and it’s all working well, I have also added ‘title: Person was detected at Carport’ above ‘message:’.

If you are still new with Frigate, its ok to just use 0.9 RC3. Because later on when you update, you will need to change your config (mentioned in the breaking changes of ver 0.9).

Have fun with Frigate! It’s awesome :clap:

1 Like

wanted to update to 0.9 to group objects in zones so I don’t keep getting spammed that there’s a car detected (parked car). I guess I can give 0.9 RC3 a try, got to read the difference in the config too, saw it had smth to do with clips as well. Was gonna wait for it to be the latest stable release so I don’t have to update docker twice.

edit: forgot that i also have to update the HA intergration for frigate if i were to update.

been a day since I used it and I notice that I keep getting the same notification/repeated notification a few times and was wondering if there’s a way to set a short delay?

You can add a condition to set a minimum time before the next automation-

  - condition: template
    value_template: >-
      {{ (as_timestamp(now())-as_timestamp(state_attr('automation.notify_of_event', 'last_triggered') | default(0)) | int > 5) }}

Change automation.notify_of_event to your automation entity_id.

I have added it into the yaml, im guessing i change int > 5 to something like int > 10 to delay it longer?

alias: Frigate Carport person motion (Duplicate test)
description: ''
trigger:
  - platform: mqtt
    topic: frigate/events
condition:
  - condition: template
    value_template: '{{ trigger.payload_json[''after''][''label''] == ''person'' }}'
  - condition: template
    value_template: >-
      {{
      (as_timestamp(now())-as_timestamp(state_attr('automation.frigate_carport_person_motion_duplicate_test',
      'last_triggered') | default(0)) | int > 5) }}
action:
  - service: notify.mobile_app_ming_s_s10
    data:
      title: Person was detected at Carport
      message: A {{trigger.payload_json["after"]["label"]}} was detected.
      data:
        image: >-
          http://10.69.40.2:5000//api/events/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg
mode: single

Yes. 5 is in seconds.
OR if you only want the “end” image-

  - condition: template
    value_template: '{{ trigger.payload_json["type"] == "end" }}'

I’ll probably need to do some testing since 5 is still sending repeated notifications. Maybe 6 or 7 should do the trick, thanks a lot :slight_smile:

Pulling my head out with this one. Keep getting:

‘Error: Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘payload_json’’

Frigate is in a lxc container and works great.
Access is through the IP:5000. Addon is using this IP and has the integration in HA.

  alias: Send Frigate snapshot
  description: ''
  trigger:
  - platform: mqtt
    topic: frigate/events
  condition:
  - condition: template
    value_template: '{{ trigger.payload_json[''after''][''label''] == ''person''}}'
  - condition: template
    value_template: '{{ ''rear'' in trigger.payload_json[''after''][''entered_zones'']}}'
  action:
  - service: notify.mobile_app_jsn_l23
    data_template:
      message: 'A {{trigger.payload_json[''after''][''label'']}} has entered the rear garden.'
      data:
        image: 'http://192.168.1.123:5000/api/events/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg'
        tag: '{{trigger.payload_json[''after''][''id'']}}'
        when: '{{trigger.payload_json["after"]["start_time"]|int}}'
  mode: single

Also tried this blueprint - same json error.

Can you help please?

1 Like

Hi,

I am struggling with a Message malformed expected a dictionary error when trying to use a person detection to trip a security light.

This is my code:

platform: mqtt
topic: frigate/events
condition: template
value_template: '{{ trigger.payload_json["after"]["label"] == "person" }}'

I have checked everything, but can’t find what I am doing wrong. Any help gratefully received

EDIT: I Fixed this single quotes needed,