I am trying to immediately send a notification when a person is detected by frigate and then update the notification when AI provides a summary. I have a rate limit of one notification per minute per camera
Currently I have:
alias: New AI
trigger:
- topic: frigate/reviews
trigger: mqtt
conditions:
- condition: template
value_template: '{{ trigger.payload_json[''type''] == ''end'' }}'
- condition: template
value_template: '{{ trigger.payload_json[''after''][''severity''] == ''alert''
}}'
- condition: template
value_template: "{% set camera = trigger.payload_json['after']['camera'] %} {%
set entity_id = 'input_datetime.frigate_last_alert_' + camera %} {% if states(entity_id)
is not none %}\n {% set last_run = states(entity_id) | as_timestamp(0) %}\n
\ {% set now = now().timestamp() %}\n {{ (now - last_run) > 60 }}\n{% else
%}\n true\n{% endif %}\n"
actions:
- variables:
event_id: '{{ trigger.payload_json[''after''][''id''] }}'
camera: '{{ trigger.payload_json[''after''][''camera''] }}'
label: '{{ trigger.payload_json[''after''][''data''][''objects''][0] }}'
thumb: '{{ trigger.payload_json[''after''][''thumb_path''] }}'
- target:
entity_id: '{{ ''input_datetime.frigate_last_alert_'' + camera }}'
data:
timestamp: '{{ now().timestamp() }}'
action: input_datetime.set_datetime
- data:
title: '{{ camera }} Camera'
message: A {{ label }} was detected on the {{ camera }} camera. Tap for details.
data:
push:
sound: default
interruption-level: time-sensitive
entity_id: camera.{{ camera | lower }}
tag: '{{ event_id }}'
action: notify.notify
- wait_for_trigger:
- topic: frigate/tracked_object_update
trigger: mqtt
timeout:
hours: 0
minutes: 0
seconds: 15
milliseconds: 0
continue_on_timeout: true
- data:
title: '{{ camera }} Camera1'
message: '{{ wait.trigger.payload_json[''description''] }} Tap for details.'
data:
push:
sound: default
interruption-level: time-sensitive
entity_id: camera.{{ camera | lower }}
tag: '{{ event_id }}'
action: notify.notify
mode: queued
max: 25
The automation triggers on the first trigger, then timeouts on the second. I know frigate is sending the tracked_object_update topic because I setup another automation just looking for that and it fires within seconds.
So, I have two issues. The second wait_for_trigger never fires, it just timeouts. Second is that the first action only fires after the 15 second timeout on the wait_for_trigger.
Any ideas would be appreciated. Thanks.
1 post - 1 participant