Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A home assistant service to create manual event #747

Open
boozelclark opened this issue Oct 30, 2024 · 9 comments
Open

A home assistant service to create manual event #747

boozelclark opened this issue Oct 30, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@boozelclark
Copy link

boozelclark commented Oct 30, 2024

Is your feature request related to a problem? Please describe.
It would be great to have a home assistant service call to create a manual event like the API
POST /api/events/<camera_name>//create does

For example tag in frigate when my home alarm activates or a door opens

Describe the solution you'd like
A service call to create a manual event

Describe alternatives you've considered
Using a script to make the call

Additional context
Add any other context or screenshots about the feature request here.

@Paul-Vdp
Copy link

Paul-Vdp commented Nov 3, 2024

+1

@robinostlund
Copy link

Something like this? :)

rest_command:
  frigate_create_event:
    url: https://frigate/api/events/{{ camera_name }}/{{ label }}/create
    method: POST
    content_type: "application/json"
    timeout: 5
    payload: >-
      {
        "source_type": "{{ source_type | default('hass_source') }}",
        "sub_label": "{{ sub_label | default('external') }}",
        "score": "{{ float(score, 0.9) }}",
        "duration": "{{ int(duration, 30) }}",
        "include_recording": "{{ 'true' if bool(include_recording, True) else 'false' }}",
        "draw": {}
      }

And then use this service:

action: rest_command.frigate_create_event
data:
 camera_name: "home_road"
 label: "test_label_2"
 source_type: "hass_source"
 score: 0 9
 duration: 30
 include_recording: false

@Paul-Vdp
Copy link

Paul-Vdp commented Nov 9, 2024

@robinostlund I concocted something like that already. However :

  1. the documentation does not mention parameters like 'source_type' or 'score' for this API-call. Is that (and possibly more parameters) documented somewhere ? And if not : what are they used for ?
  2. my main problem however is that my recordings made this way never trigger a proper (mqtt) event, despite the API's name and its explanation

@NickM-27
Copy link
Collaborator

NickM-27 commented Nov 9, 2024

my main problem however is that my recordings made this way never trigger a proper (mqtt) event, despite the API's name and its explanation

because the /events topic has many fields that are not relevant for a manual event. Also, what is the point of a manual event being sent on /events when you as the user are triggering the manual event. You already know the manual event happened so you would just send a notification or whatever you expect at the same time that it is created in frigate

@Paul-Vdp
Copy link

Paul-Vdp commented Nov 10, 2024

Hi @NickM-27 , thx for chiming in.
About my first issue, the 'unknown' parameters for the API call : I finally found them mentioned in the docs for the beta version (which I am not yet using). But that's about all I can say, because there's no explanation about them and so I have no idea what they could or should be used for.

Now, about my second 'issue' : I had encountered your reply somewhere else already, and had dismissed it as 'besides the point' (sorry). Reading it now again I'm getting the impression that I'm misunderstanding the purpose and workings of this API call.
I was under the impression that this call enabled the since long and by many asked for function to just tell ('force') Frigate to start recording (AND treating this as a real 'event' - as implied by its naming), overruling any settings that would otherwise keep it from doing so. That was my interpretation of 'manual' - which led me to think I could use this in whatever automation I saw fit.
Based on your comments and my own experience however, I now think that it DOES start the recording, BUT it is processing it using all the rules and restrictions as laid out in the configuration - therefore not retaining it, not generating an mqtt event, etc. (despite its name, which I find truly misleading) - and thus being rather useless for my intended purpose.

FYI : all I want is to be able to (automatically) start an (unconditional !) recording in some cases, e.g. when I detect 'tampering' with my doorbell - which not only is situated outside my normal security perimeter, but could also happen when Frigate was basically inactive, e.g. during the day. And then be able to postprocess it as any other event/recording ...

@NickM-27
Copy link
Collaborator

All of the API fields are explained in the current docs https://docs.frigate.video/integrations/api#post-apieventscamera_namelabelcreate

This API creates an event and saves recordings assuming the recordings match your retention config which it should because you'd surely have event recording enabled.

It would make absolutely no sense to send an update on /events MQTT topic because 95% of the fields there are specific to an object, so it would be a blank message and break many automations which expect these fields to be populated.

And as I said you're triggering the manual event so it doesn't make sense for you to tell frigate about something and then wait for frigate to tell you about it. It would be faster and more direct to just send a notification directly in the automation that creates the event.

If you have some specific behavior that doesn't seem right I'd suggest going over to the Frigate repo and making a support discussion there

@Paul-Vdp
Copy link

About the parameters for the API call I can only repeat that they are merely MENTIONED in the docs for the beta, but failing to see any EXPLANATION for them I still have no idea what some of them could or should be used for.

I might even add that there is even a discrepancy between the current stable and beta versions - that or things have changed ?
E.g. the 'score' parameter : in stable it is shown as part of the 'draw' dictionary, whereas in beta it seems to exist at body level, whereas the potential 'draw' dictionay contents is no longer documented.
I was also somewhat surprised that this 'score' must be entered as a percentage, whereas everywhere else (in the configuration, not the UI) it is used in the form of a fraction ?

And the meaning or use of e.g. 'source_type' ? Anybody's guess ...
Please forgive my ignorance, but I have no real idea what effect the 'include_recording' might have, or better said: what is the result if you deny this ? Does Frigate then DO anything, and if so: what exactly, and what is the noticeable result ?

Thanks beforehand for enlightening me in all of this
And as per your request, I'll move over to the Frigate repo to sollicit your valued help for my biggest issue/problem.

@gamer06
Copy link

gamer06 commented Nov 25, 2024

Is your feature request related to a problem? Please describe. It would be great to have a home assistant service call to create a manual event like the API POST /api/events/<camera_name>//create does

For example tag in frigate when my home alarm activates or a door opens

Describe the solution you'd like A service call to create a manual event

Describe alternatives you've considered Using a script to make the call

Additional context Add any other context or screenshots about the feature request here.

Hi, did you manage to get this working? Thanks

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Dec 26, 2024
@NickM-27 NickM-27 added enhancement New feature or request and removed Stale labels Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants