Add designator when events are from the api (#6997)

* Add designator when events are custom

* Add type field and set via API
This commit is contained in:
Nicolas Mowen 2023-07-03 08:48:00 -06:00 committed by GitHub
parent 83edf9574e
commit 58c6ef1e12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 5 deletions

View File

@ -187,7 +187,7 @@ class AudioEventMaintainer(threading.Thread):
else:
resp = requests.post(
f"{FRIGATE_LOCALHOST}/api/events/{self.config.name}/{label}/create",
json={"duration": None},
json={"duration": None, "source_type": "audio"},
)
if resp.status_code == 200:

View File

@ -29,6 +29,7 @@ class ExternalEventProcessor:
self,
camera: str,
label: str,
source_type: str,
sub_label: Optional[str],
duration: Optional[int],
include_recording: bool,
@ -61,6 +62,7 @@ class ExternalEventProcessor:
"thumbnail": thumbnail,
"has_clip": camera_config.record.enabled and include_recording,
"has_snapshot": True,
"type": source_type,
},
)
)

View File

@ -193,6 +193,7 @@ class EventProcessor(threading.Thread):
"score": score,
"top_score": event_data["top_score"],
"attributes": attributes,
"type": "object",
},
}
@ -216,8 +217,8 @@ class EventProcessor(threading.Thread):
del self.events_in_process[event_data["id"]]
self.event_processed_queue.put((event_data["id"], camera))
def handle_external_detection(self, type: str, event_data: Event) -> None:
if type == "new":
def handle_external_detection(self, event_type: str, event_data: Event) -> None:
if event_type == "new":
event = {
Event.id: event_data["id"],
Event.label: event_data["label"],
@ -229,10 +230,10 @@ class EventProcessor(threading.Thread):
Event.has_clip: event_data["has_clip"],
Event.has_snapshot: event_data["has_snapshot"],
Event.zones: [],
Event.data: {},
Event.data: {"type": event_data["type"]},
}
Event.insert(event).execute()
elif type == "end":
elif event_type == "end":
event = {
Event.id: event_data["id"],
Event.end_time: event_data["end_time"],

View File

@ -884,6 +884,7 @@ def create_event(camera_name, label):
event_id = current_app.external_processor.create_manual_event(
camera_name,
label,
json.get("source_type", "api"),
json.get("sub_label", None),
json.get("duration", 30),
json.get("include_recording", True),