Hello, I’m trying to get an automation sorted whereby a Frigate alert comes in on a specific camera with specific zones with a specific label, but am having trouble I think with the template.
The documentation states:
frigate/reviews
Message published for each changed review item. The first message is published when the detection
or alert
is initiated. When additional objects are detected or when a zone change occurs, it will publish a, update
message with the same id. When the review activity has ended a final end
message is published.
An example alert payload for my camera looks like this:
{
"type": "update",
"before": {
"id": "1734615683.394306-aekbqf",
"camera": "Driveway",
"start_time": 1734615683.394306,
"end_time": null,
"severity": "detection",
"thumb_path": "/media/frigate/clips/review/thumb-Driveway-1734615683.394306-aekbqf.webp",
"data": {
"detections": [
"1734615625.954177-2r3067"
],
"objects": [
"car"
],
"sub_labels": [],
"zones": [
"DrivewayBetweenCars",
"Driveway_General"
],
"audio": []
}
},
"after": {
"id": "1734615683.394306-aekbqf",
"camera": "Driveway",
"start_time": 1734615683.394306,
"end_time": null,
"severity": "alert",
"thumb_path": "/media/frigate/clips/review/thumb-Driveway-1734615683.394306-aekbqf.webp",
"data": {
"detections": [
"1734615698.961387-sgrp18",
"1734615625.954177-2r3067"
],
"objects": [
"person",
"car"
],
"sub_labels": [],
"zones": [
"DrivewayBetweenCars",
"Driveway_General"
],
"audio": []
}
}
}
I think it makes sense considering this is for home security purposes to have the filters for type: new or update, camera: Driveway, severity: alert, objects: person, zones: DrivewayBetweenCars or Driveway_General, as I don’t want alerts for people not on my property etc.
I’m not sure what to do about the before and after parts, but seeing above as the before is shown as a detection and the after is shown as an alert, I’m guessing I want to filter for after as well, but am unsure?
I’ve tried using Frigates Devs blueprint, but it doesn’t seem to support TTS notifications. I tried the custom action (automatic trigger) element, but it didn’t work during a test.
I’ve opened a discussion on their GitHub and have been pointed in the direction of 2 other automations, but I can’t seem to tailor them for my setup and get TTS working as well.
I initially used Home Assistant’s Frigate intergation occupancy sensors in the automation, but because these are apparently unfiltered by Frigate’s detection parameters (such as size/ratio), I’m getting annoying false positives with weird lighting etc and have been told to use the MQTT topic to make my automations.
I’ve got this so far, but it doesn’t seem to work:
trigger:
- platform: mqtt
topic: frigate/reviews
condition:
# Check if it's a new or update message
- condition: template
value_template: >-
{{ trigger.payload_json.type in ['new', 'update'] }}
# Check if it's the driveway camera
- condition: template
value_template: >-
{{ trigger.payload_json.after.camera == 'Driveway' }}
# Check if severity is alert
- condition: template
value_template: >-
{{ trigger.payload_json.after.severity == 'alert' }}
# Check if person is in the objects list
- condition: template
value_template: >-
{{ 'person' in trigger.payload_json.after.data.objects }}
# Check if either of the specified zones are in the zones list
- condition: template
value_template: >-
{% set zones = trigger.payload_json.after.data.zones | lower %}
{{ 'drivewaybetweencars' in zones or 'driveway_general' in zones }}
Any help or pointers would be much appreciated.