Skip to content

NVR with realtime local object detection for IP cameras

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

Nicolas Mowen58c6ef1e1244
diff --git a/frigate/events/audio.py b/frigate/events/audio.py
index 164c9c62d1..b34deb315f 100644
--- a/frigate/events/audio.py
+++ b/frigate/events/audio.py
@@ -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:
diff --git a/frigate/events/external.py b/frigate/events/external.py
index 25ba289f25..20456b9cb6 100644
--- a/frigate/events/external.py
+++ b/frigate/events/external.py
@@ -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,
},
)
)
diff --git a/frigate/events/maintainer.py b/frigate/events/maintainer.py
index d688f7dfeb..34cb012611 100644
--- a/frigate/events/maintainer.py
+++ b/frigate/events/maintainer.py
@@ -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"],
diff --git a/frigate/http.py b/frigate/http.py
index f3632a0cf1..57b2103e71 100644
--- a/frigate/http.py
+++ b/frigate/http.py
@@ -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),