Frigate Automations - Where is the "event ID" needed for "end event" actions in HA GUI?

Hello,

New user to HA and Frigate. A bit of a threshold :wink:
Running both as VE:s in Proxmox and generally working very well.

Something I am unable to build:
We want to be able to start and stop recording from the HA GUI of each camera manually.
Start recording /create event is working fine via the “Frigate create event” action.

However to stop recording we need to create an “Frigate:end an event” action in HA GUI
and it is asking for an “event ID” to stop recording:

Does anyone know how to get that “event id” to put into the “end event” action in HA GUI?

Many thanks for any hints or examples.

I don’t use Frigate, but a look through their docs suggests that the creating the event will return the event_id in the response. If you have no way of capturing that, try calling get events - that should give you a list of open events with their IDs

Thanks for reply, very kind of you.
I have done the /api/events and searched for the names of the automations and the variables in there but not finding anything and the word “event” is not in there either. Not sure what I am looking for…

edit: found the responses in the api/events payloads as described below.

Frigate Documentation pages might help and
blakeblackshear/frigate · Discussions · GitHub is the official Frigate support hub and is another good place to get help with Frigate if you don’t get an answer here.

In comes in as the response for the create event call.

@crzynik wrote: “It comes in as the response for the create event call.”

I have understood that, but how and where can we see and capture that response please?

You’re looking for id from what I can tell. It should be the first row in the payload according to their example:

[
  {
    "id": "string",
    "label": "string",
    "sub_label": "string",
    "camera": "string",
    "start_time": 0,
    "end_time": 0,
    "false_positive": true,
    "zones": [
      "string"
    ],
    "thumbnail": "string",
    "has_clip": true,
    "has_snapshot": true,
    "retain_indefinitely": true,
    "plus_id": "string",
    "model_hash": "string",
    "detector_type": "string",
    "model_type": "string",
    "data": {}
  }
]

EDIT: Or try adding a response variable to your create event to fetch the ID from the response immediately.

yes, this is what you need to do

Thanksfor this suggestion @ShadowFist it seems the correct path so I need to find a way to do precisely this.

So I experimented a little and realised by naming the label of the “create event/start rec” I can find the ID using the /api/events method, but it appears to change and give each new created event a new ID, so I guess the “end event/stop rec” command needs to contain each new ID as a variable that can be known by the response command directly. This is a little tricky for my skillset on these things.
Anybody out there that has done this and can add an example?
In my examples below the event ID is just the latest one as placeholders for the examples.

Edit: Examples are incorrect and deleted.

Run the service in the service checker if they offer any responses, otherwise I’d wager the event comes through the event topic.

According to @ShadowFist they reply with

{
  "success": true,
  "message": "string",
  "event_id": "string"
}

WIth that being said, if you use this:

alias: start rec front
description: ''
triggers:
  - trigger: switch.turned_on
    target:
      entity_id: input_boolean.switch_rec_front
    options:
      behavior: each
      for: '00:00:00'
conditions: []
actions:
  - action: frigate.create_event
    metadata: {}
    target:
      device_id: 3ccf051234cc93b6143e255f36ed6323
    data:
      label: on demand front
      duration: 0
      include_recording: true
    response_variable: start_stop_rec_front
  - action: input_text.set_value
    target:
      entity_id: input_text.your_text # YOU WILL HAVE TO CREATE THIS HELPER
    data:
      value: "{{ start_stop_rec_front['event_id'] }}"

Then

alias: stop rec framsida
description: ''
triggers:
  - trigger: switch.turned_off
    target:
      entity_id: input_boolean.switch_rec_front
    options:
      behavior: each
      for: '00:00:00'
conditions: []
actions:
  - action: frigate.end_event
    metadata: {}
    data:
      event_id: "{{ states('input_text.your_text') }}"
    target:
      device_id: 3ccf051234cc93b6143e255f36ed6323
mode: single

    

Thanks @petro I will try this asap!
Just one follow-up if you have a minute?
What type should the helper you suggest be and what should go into it?

    target:
      entity_id: input_text.your_text *# YOU WILL HAVE TO CREATE THIS HELPER*

an input_text

Sorry for being obtuse, but what text would that be? What is the function?
A regex holder?

Thanks for your patience @petro ! You have been most helpful and I very much appreciate it.
Your suggestions starts the event but does not end it so far and I still have to restart Frigate to end the event/recording. Will start debugging tomorrow. Thanks again so far!

I did something like this a while ago:

action:
  - service: frigate.set_camera_settings
    data:
      camera: driveway
      settings:
        record:
          enabled: true

enabled: true or enabled: false.

But I commented it out because my computer running Frigate has gobs of disk space, so I just let it record on any detection activity.

Thanks @steve. I have something like that working too for all cameras for automations and manual switching but have some other manual needs also for various reasons.

I see no errors in the log when testing these by @petro but still can’t stop the recording/create event.
Any chance anyone else here can test them and report here if you can get it working or if I have errors in there that don’t trigger errors?
Obviously using the GUI initially to get your own device_id. Many thanks!

Provide traces for the automations posted above.

deleted for integrity reasons