Hi there, I'm trying to create an automation where Frigate integration detects a motion and once it finishes detection, export the recording. 'Export Recording' action is available to use but it needs a device or entity id. I'm using the mqtt trigger to build the automation. Mqtt payload has 'camera name'. How do i use the camera name to search for the associated device or entity id?
Thanks!
#Get device_id or entity_id
1 messages · Page 1 of 1 (latest)
yes, sure. Here's my current automation where it notifies me on Discord:
alias: Frigate Discord
description: ""
triggers:
- topic: frigate/events
trigger: mqtt
conditions:
- condition: template
value_template: "{{ trigger.payload_json[\"type\"] == \"end\" }}"
enabled: true
actions:
- data:
message: >-
A {{trigger.payload_json["after"]["label"]}} was detected in cam
{{trigger.payload_json["after"]["camera"]}} in e-zones
{{trigger.payload_json["after"]["entered_zones"]}} with id
{{trigger.payload_json["after"]["id"]}} and type is
{{trigger.payload_json["type"]}} between
{{trigger.payload_json["after"]["start_time"] |
timestamp_custom("%Y-%m-%d %H:%M:%S") }} e-dt
{{trigger.payload_json["after"]["end_time"] | timestamp_custom("%Y-%m-%d
%H:%M:%S") }}.
target: "1110608"
data:
urls: >-
https://ha.com/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg
embed:
title: "{{trigger.payload_json[\"after\"][\"camera\"]}}"
images:
- >-
/media/frigate/clips/{{trigger.payload_json["after"]["camera"]}}-{{trigger.payload_json["after"]["id"]}}.jpg
action: notify.me
And here's the action available to export Frigate recordings:
action: frigate.export_recording
data:
playback_factor: realtime
start_time: "2025-09-04 14:00:07"
end_time: "2025-09-04 14:00:27"
target:
entity_id: camera.tbc_5
The target: in above action can also take device_id (which is a number). My question is, How do I get entity_id or device_id based on mqtt payload (above yaml script) to choose the correct camera for which the automation is triggered?
and what in that gets you the device_id?
Hi, i don't know, that's what im trying to understand that how do i find device or entity id based on friendly name.
Well in order to help, we need to see the full payload_json
if that doesn't have the device_id in it, we'd need to create a map that points a camera id or camera name to a device_id in home assistant
As far as I can tell, it's not in frigate/events payload. It's payload_json is at this link (sorry, discord doesn't allow me to paste long text): https://docs.frigate.video/integrations/mqtt/#frigateevents