Hi,
Frigate publishes object detection event data to mqtt. I would like to use this data in a script that is called from an automation.
Is it possible?
automation
- id: '4551845461545'
alias: Frigate - Disarmed
trigger:
platform: mqtt
topic: frigate/events
condition:
- condition: state
entity_id: alarm_control_panel.alarmo
state: 'disarmed'
- "{{ trigger.payload_json['after']['label'] == 'person' }}"
# - "{{ trigger.payload_json['after']['camera'] == 'driveway' }}"
# - "{{ 'zone' in trigger.payload_json['after']['entered_zones'] }}"
# - "{{ as_timestamp(now()) - as_timestamp(states.automation.frigate_disarmed.attributes.last_triggered) | int > 120 }}"
- condition: state
entity_id: binary_sensor.hall_frontdoor
state: 'off'
for:
seconds: 10
action:
- service: script.frigate_notify
script
frigate_notify:
alias: Frigate Notify
sequence:
- service: notify.mobile_app_stephen_s20
data_template:
title: 'Frigate - {{trigger.payload_json["after"]["label"]}}'
message: A {{trigger.payload_json["after"]["label"]}} was detected in the {{trigger.payload_json['after']['camera']}} at {{now().strftime('%H:%M:%S')}}.
data:
image: 'https://xxxxxxxxxxxxxxxxxxxxxxxxxx.ui.nabu.casa/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg?format=android'
tag: '{{trigger.payload_json["after"]["id"]}}'
clickAction: 'https://rlxxxxxxxxxxxxxxxxxxxxxxxxx.ui.nabu.casa/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/snapshot.jpg'
actions:
- action: "URI"
title: "View Video"
uri: 'https://rlfxxxxxxxxxxxxxxxxxxxwrx.ui.nabu.casa/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/{{trigger.payload_json["after"]["camera"]}}/clip.mp4'
- action: "URI"
title: "View Snapshot"
uri: 'https://rlfnxxxxxxxxxxxxxxxxxxxxxxxxx.ui.nabu.casa/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/snapshot.jpg'
Frigate Event Data
{"before": {"id": "1612905525.522665-cwxvn5", "camera": "garden", "frame_time": 1612905548.485638, "label": "person", "top_score": 0.8359375, "false_positive": false, "start_time": 1612905525.522665, "end_time": null, "score": 0.83203125, "box": [148, 27, 219, 131], "area": 7384, "region": [33, 0, 333, 300], "current_zones": ["zone_back"], "entered_zones": ["zone_back"], "thumbnail": null}, "after": {"id": "1612905525.522665-cwxvn5", "camera": "garden", "frame_time": 1612905568.707045, "label": "person", "top_score": 0.84375, "false_positive": false, "start_time": 1612905525.522665, "end_time": 1612905571.633328, "score": 0.62890625, "box": [153, 0, 215, 83], "area": 5146, "region": [37, 0, 337, 300], "current_zones": ["zone_back"], "entered_zones": ["zone_back"], "thumbnail": null}, "type": "end"}