Unable to pull specific event snapshot based on event ID for display in notification
See original GitHub issueDescribe the bug Tried the automation shown in the docs in order to get notifications to show the snapshot which refers to the event that happened rather than just the latest event like the camera feed for the events does, but it ended up also showing just the latest event just like the snapshot camera feed gives
Here is the automation I tried:
- id: someone_through_gate
alias: someone_through_gate
initial_state: 'true'
trigger:
platform: mqtt
topic: frigate/events
condition:
- "{{ trigger.payload_json['after']['label'] == 'person' }}"
- "{{ 'inside_gate' in trigger.payload_json['after']['entered_zones'] }}"
action:
- choose:
- conditions:
- condition: and
conditions:
- condition: template
value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.person_in_front.attributes.last_triggered | default(0)) | int > 600)}}'
- condition: state
entity_id: device_tracker.sean_s_iphone_12
state: 'home'
sequence:
service: notify.mobile_app_sean_s_iphone_12
data_template:
title: "Person Coming Through Gate"
message: "Looks like someone is going to or coming from the front gate to the front door"
data:
attachment:
url: "http://192.168.2.23:5000/api/frigate/notifications/{{trigger.payload_json['after']['id']}}/thumbnail.jpg"
content-type: jpg
hide-thumbnail: false
push:
category: camera
thread-id: "security"
clickAction: 8
entity_id: camera.front_person
- choose:
- conditions:
- condition: and
conditions:
- condition: template
value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.person_in_front.attributes.last_triggered | default(0)) | int > 600)}}'
- condition: state
entity_id: device_tracker.alena_s_iphone
state: 'home'
sequence:
service: notify.mobile_app_alena_s_iphone
data_template:
title: "Person Coming Through Gate"
message: "Looks like someone is going to or coming from the front gate to the front door"
data:
attachment:
url: "http://192.168.2.23:5000/api/frigate/notifications/{{trigger.payload_json['after']['id']}}/thumbnail.jpg"
content-type: jpg
hide-thumbnail: false
push:
category: camera
thread-id: "security"
clickAction: 8
it produces exactly the same result as just using the camera entity for the person tracker (ie, only the latest event regardless of how far back the actual event was in the notification).
- id: someone_through_gate
alias: someone_through_gate
initial_state: 'true'
trigger:
platform: numeric_state
entity_id: sensor.inside_gate_person
above: 0
action:
- choose:
- conditions:
- condition: and
conditions:
- condition: template
value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.person_in_front.attributes.last_triggered | default(0)) | int > 600)}}'
- condition: state
entity_id: device_tracker.sean_s_iphone_12
state: 'home'
sequence:
service: notify.mobile_app_sean_s_iphone_12
data:
title: "Person Coming Through Gate"
message: "Looks like someone is going to or coming from the front gate to the front door"
data:
push:
category: camera
thread-id: "security"
clickAction: 8
entity_id: camera.front_person
- choose:
- conditions:
- condition: and
conditions:
- condition: template
value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.person_in_front.attributes.last_triggered | default(0)) | int > 600)}}'
- condition: state
entity_id: device_tracker.alena_s_iphone
state: 'home'
sequence:
service: notify.mobile_app_alena_s_iphone
data:
title: "Person Coming Through Gate"
message: "Looks like someone is going to or coming from the front gate to the front door"
data:
push:
category: camera
thread-id: "security"
clickAction: 8
entity_id: camera.front_person
Version of frigate
Output from /api/version
0.8.3-d771726
Config file Include your full config file wrapped in triple back ticks.
mqtt:
host: 192.168.2.29
user: ralphmaccio
password: '{FRIGATE_MQTT_PASSWORD}'
objects:
track:
- person
- cat
- dog
- bird
filters:
person:
min_area: 4000
min_score: 0.5
threshold: 0.72
cat:
threshold: 0.72
dog:
threshold: 0.72
bird:
threshold: 0.72
clips:
retain:
# Required: Default retention days (default: shown below)
default: 100
detectors:
coral:
type: edgetpu
device: usb
ffmpeg:
hwaccel_args:
- -hwaccel
- vaapi
- -hwaccel_device
- /dev/dri/renderD128
- -hwaccel_output_format
- yuv420px
cameras:
right:
width: 1080
height: 1920
fps: 4
ffmpeg:
inputs:
- path: rtsp://scstraus:{FRIGATE_RTSP_PASSWORD}@192.168.2.89:554/Streaming/channels/1
roles:
- detect
- rtmp
- clips
objects:
filters:
person:
min_area: 9000
snapshots:
enabled: True
timestamp: False
bounding_box: True
clips:
enabled: True
motion:
mask:
- 961,218,933,0,1080,0,1080,1527,1004,1920,1080,1920,1080,948,994,392,623,129,505,376,383,672,140,1353,0,1866,0,0,687,0,678,30
left:
width: 1080
height: 1920
fps: 4
ffmpeg:
inputs:
- path: rtsp://scstraus:{FRIGATE_RTSP_PASSWORD}@192.168.2.90:554/Streaming/Channels/101?transportmode=multicast&profile=Profile_1
roles:
- detect
- rtmp
- clips
objects:
filters:
person:
min_area: 14000
snapshots:
enabled: True
timestamp: False
bounding_box: True
clips:
enabled: True
motion:
mask:
- 653,128,654,179,886,169,872,176,905,0,0,0,0,406,335,144
- 1080,0,1080,205,952,178,945,101,987,0
- 1080,952,1031,917,1047,817,1014,796,1059,768,1080,667
- 813,368,948,368,951,292,808,298
front:
width: 1920
height: 1080
fps: 4
ffmpeg:
inputs:
- path: rtsp://scstraus:{FRIGATE_RTSP_PASSWORD}@192.168.2.91:554/Streaming/Channels/101?transportmode=multicast&profile=Profile_1
roles:
- detect
- rtmp
- clips
snapshots:
enabled: True
timestamp: False
bounding_box: True
clips:
enabled: True
objects:
track:
- car
- truck
- person
- cat
- dog
- bird
zones:
# Coordinates can be generated at https://www.image-map.net/
on_property:
coordinates: 552,0,581,60,823,172,869,207,1198,443,1231,424,1736,807,1810,679,1920,768,1917,1073,3,1080,0,0
on_sidewalk:
coordinates: 570,0,863,103,1206,315,1264,314,1919,802,1919,683,1318,254,923,61,721,0
on_street:
coordinates: 573,0,855,90,862,117,1191,303,1275,317,1919,783,1919,0
at_gate:
coordinates: 598,0,682,0,780,0,987,0,871,97
inside_gate:
coordinates: 621,380,821,212,801,71,661,37,504,119
car_pulling_in:
coordinates: 871,182,1177,408,1225,391,1222,501,636,835,415,531,615,391,574,277,852,101
motion:
mask:
- 0,1080,0,0,62,0,792,1080
back:
width: 1920
height: 1080
fps: 4
ffmpeg:
inputs:
- path: rtsp://scstraus:{FRIGATE_RTSP_PASSWORD}@192.168.2.92:554/Streaming/Channels/101?transportmode=multicast&profile=Profile_1
roles:
- detect
- rtmp
- clips
objects:
filters:
person:
min_area: 9000
snapshots:
enabled: True
timestamp: False
bounding_box: True
clips:
enabled: True
motion:
mask:
- 739,0,745,54,124,56,120,0
Frigate container logs
* Starting nginx nginx
...done.
Starting migrations
peewee_migrate INFO : Starting migrations
There is nothing to migrate
peewee_migrate INFO : There is nothing to migrate
frigate.mqtt INFO : MQTT connected
frigate.app INFO : Camera processor started for right: 39
frigate.app INFO : Camera processor started for left: 40
frigate.app INFO : Camera processor started for front: 41
frigate.app INFO : Camera processor started for back: 42
frigate.app INFO : Capture process started for right: 43
frigate.app INFO : Capture process started for left: 44
frigate.app INFO : Capture process started for front: 45
frigate.app INFO : Capture process started for back: 50
detector.coral INFO : Starting detection process: 36
frigate.edgetpu INFO : Attempting to load TPU as usb
frigate.edgetpu INFO : TPU found
frigate.watchdog INFO : Detection appears to be stuck. Restarting detection process...
root INFO : Waiting for detection process to exit gracefully...
root INFO : Detection process didnt exit. Force killing...
detector.coral INFO : Starting detection process: 27145
frigate.edgetpu INFO : Attempting to load TPU as usb
frigate.edgetpu INFO : TPU found
frigate.watchdog INFO : Detection appears to be stuck. Restarting detection process...
root INFO : Waiting for detection process to exit gracefully...
root INFO : Detection process didnt exit. Force killing...
detector.coral INFO : Starting detection process: 10562
frigate.edgetpu INFO : Attempting to load TPU as usb
frigate.edgetpu INFO : TPU found
Frigate stats
Output from frigate's /api/stats endpoint
FFprobe from your camera
Run the following command and paste output below
ffprobe <stream_url>
Screenshots If applicable, add screenshots to help explain your problem.
Computer Hardware
- OS: Synology
- Install method: Docker Compose
- Virtualization: Nope
- Coral Version: USB
- Network Setup:Wired
Camera Info:
- Manufacturer:Hikvision
- Resolution: 1080p
- FPS: 4
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Make sure you are running the latest integration code. Older versions did not pass through the clip.
Those before and after params for the api are unrelated to mqtt. See the mqtt docs for an example.
Okay so my issue was that I was using the frigate API instead of the hass API for this, so now it pretty much works, with a few caveats…
Snapshots work in notifications most of the time, but occasionally they are missing. Do they time out after a while or any other idea what causes this?
I couldn’t get clips to be sent as notifications at all… I tried:
and
but both returned 404’s.
As for after, I could only find this in the documentation:
(The link at the word here doesn’t work, so maybe that’s what I’m missing)
and
As far as I can tell, it’s some kind of timestamp? I tried removing it from the notification URL but then the URL wouldn’t work any more, which seems strange because it’s supposed to only need the ID, I’m guessing this is half of the actual ID it needs?
Anyway still lost on that point, but I have something serviceable working at least. I will add an iOS example to the docs if that will be helpful as it’s quite a bit different than android.