diff --git a/frigate/api/event.py b/frigate/api/event.py index c8f423b5d..fb2212d52 100644 --- a/frigate/api/event.py +++ b/frigate/api/event.py @@ -1094,7 +1094,7 @@ def set_sub_label( new_score = None request.app.event_metadata_updater.publish( - EventMetadataTypeEnum.sub_label, (event_id, new_sub_label, new_score) + (event_id, new_sub_label, new_score), EventMetadataTypeEnum.sub_label.value ) return JSONResponse( @@ -1148,8 +1148,8 @@ def set_plate( new_score = None request.app.event_metadata_updater.publish( - EventMetadataTypeEnum.attribute, (event_id, "recognized_license_plate", new_plate, new_score), + EventMetadataTypeEnum.attribute, ) return JSONResponse( @@ -1232,8 +1232,8 @@ def regenerate_description( if camera_config.genai.enabled or params.force: request.app.event_metadata_updater.publish( - EventMetadataTypeEnum.regenerate_description, (event.id, params.source, params.force), + EventMetadataTypeEnum.regenerate_description.value, ) return JSONResponse( @@ -1390,7 +1390,6 @@ def create_event( event_id = f"{now}-{rand_id}" request.app.event_metadata_updater.publish( - EventMetadataTypeEnum.manual_event_create, ( now, camera_name, @@ -1403,6 +1402,7 @@ def create_event( body.source_type, body.draw, ), + EventMetadataTypeEnum.manual_event_create.value, ) return JSONResponse( @@ -1426,7 +1426,7 @@ def end_event(request: Request, event_id: str, body: EventsEndBody): try: end_time = body.end_time or datetime.datetime.now().timestamp() request.app.event_metadata_updater.publish( - EventMetadataTypeEnum.manual_event_end, (event_id, end_time) + (event_id, end_time), EventMetadataTypeEnum.manual_event_end.value ) except Exception: return JSONResponse( diff --git a/frigate/comms/event_metadata_updater.py b/frigate/comms/event_metadata_updater.py index 5a2d6104d..69dc84efa 100644 --- a/frigate/comms/event_metadata_updater.py +++ b/frigate/comms/event_metadata_updater.py @@ -28,8 +28,8 @@ class EventMetadataPublisher(Publisher): def __init__(self) -> None: super().__init__() - def publish(self, topic: EventMetadataTypeEnum, payload: Any) -> None: - super().publish(payload, topic.value) + def publish(self, payload: Any, sub_topic: str) -> None: + super().publish(payload, sub_topic) class EventMetadataSubscriber(Subscriber): diff --git a/frigate/data_processing/common/license_plate/mixin.py b/frigate/data_processing/common/license_plate/mixin.py index c88fbc982..f78c1a111 100644 --- a/frigate/data_processing/common/license_plate/mixin.py +++ b/frigate/data_processing/common/license_plate/mixin.py @@ -1170,7 +1170,6 @@ class LicensePlateProcessingMixin: event_id = f"{now}-{rand_id}" self.event_metadata_publisher.publish( - EventMetadataTypeEnum.lpr_event_create, ( now, camera, @@ -1181,6 +1180,7 @@ class LicensePlateProcessingMixin: None, plate, ), + EventMetadataTypeEnum.lpr_event_create.value, ) return event_id @@ -1518,7 +1518,7 @@ class LicensePlateProcessingMixin: # If it's a known plate, publish to sub_label if sub_label is not None: self.sub_label_publisher.publish( - EventMetadataTypeEnum.sub_label, (id, sub_label, avg_confidence) + (id, sub_label, avg_confidence), EventMetadataTypeEnum.sub_label.value ) # always publish to recognized_license_plate field @@ -1537,8 +1537,8 @@ class LicensePlateProcessingMixin: ), ) self.sub_label_publisher.publish( - EventMetadataTypeEnum.attribute, (id, "recognized_license_plate", top_plate, avg_confidence), + EventMetadataTypeEnum.attribute, ) # save the best snapshot for dedicated lpr cams not using frigate+ @@ -1552,8 +1552,8 @@ class LicensePlateProcessingMixin: frame_bgr = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420) _, encoded_img = cv2.imencode(".jpg", frame_bgr) self.sub_label_publisher.publish( - EventMetadataTypeEnum.save_lpr_snapshot, (base64.b64encode(encoded_img).decode("ASCII"), id, camera), + EventMetadataTypeEnum.save_lpr_snapshot.value, ) if id not in self.detected_license_plates: diff --git a/frigate/data_processing/real_time/bird.py b/frigate/data_processing/real_time/bird.py index f400f17ce..597399a76 100644 --- a/frigate/data_processing/real_time/bird.py +++ b/frigate/data_processing/real_time/bird.py @@ -147,8 +147,8 @@ class BirdRealTimeProcessor(RealTimeProcessorApi): return self.sub_label_publisher.publish( - EventMetadataTypeEnum.sub_label, (obj_data["id"], self.labelmap[best_id], score), + EventMetadataTypeEnum.sub_label.value, ) self.detected_birds[obj_data["id"]] = score diff --git a/frigate/data_processing/real_time/custom_classification.py b/frigate/data_processing/real_time/custom_classification.py index 71eb1cd87..d6cde8fb9 100644 --- a/frigate/data_processing/real_time/custom_classification.py +++ b/frigate/data_processing/real_time/custom_classification.py @@ -294,16 +294,16 @@ class CustomObjectClassificationProcessor(RealTimeProcessorApi): ): if sub_label != "none": self.sub_label_publisher.publish( - EventMetadataTypeEnum.sub_label, (obj_data["id"], sub_label, score), + EventMetadataTypeEnum.sub_label, ) elif ( self.model_config.object_config.classification_type == ObjectClassificationType.attribute ): self.sub_label_publisher.publish( - EventMetadataTypeEnum.attribute, (obj_data["id"], self.model_config.name, sub_label, score), + EventMetadataTypeEnum.attribute, ) def handle_request(self, topic, request_data): diff --git a/frigate/data_processing/real_time/face.py b/frigate/data_processing/real_time/face.py index 963a3e73a..e5c04763e 100644 --- a/frigate/data_processing/real_time/face.py +++ b/frigate/data_processing/real_time/face.py @@ -321,8 +321,8 @@ class FaceRealTimeProcessor(RealTimeProcessorApi): if weighted_score >= self.face_config.recognition_threshold: self.sub_label_publisher.publish( - EventMetadataTypeEnum.sub_label, (id, weighted_sub_label, weighted_score), + EventMetadataTypeEnum.sub_label.value, ) self.__update_metrics(datetime.datetime.now().timestamp() - start) diff --git a/frigate/embeddings/maintainer.py b/frigate/embeddings/maintainer.py index 1f6558221..66c87dc5f 100644 --- a/frigate/embeddings/maintainer.py +++ b/frigate/embeddings/maintainer.py @@ -500,8 +500,8 @@ class EmbeddingMaintainer(threading.Thread): to_remove.append(id) for id in to_remove: self.event_metadata_publisher.publish( - EventMetadataTypeEnum.manual_event_end, (id, now), + EventMetadataTypeEnum.manual_event_end.value, ) self.detected_license_plates.pop(id) diff --git a/frigate/events/audio.py b/frigate/events/audio.py index 8446ca48d..36b5a9ccd 100644 --- a/frigate/events/audio.py +++ b/frigate/events/audio.py @@ -293,7 +293,6 @@ class AudioEventMaintainer(threading.Thread): self.requestor.send_data(f"{self.camera_config.name}/audio/{label}", "ON") self.event_metadata_publisher.publish( - EventMetadataTypeEnum.manual_event_create, ( now, self.camera_config.name, @@ -306,6 +305,7 @@ class AudioEventMaintainer(threading.Thread): "audio", {}, ), + EventMetadataTypeEnum.manual_event_create.value, ) self.detections[label] = { "id": event_id, @@ -329,8 +329,8 @@ class AudioEventMaintainer(threading.Thread): ) self.event_metadata_publisher.publish( - EventMetadataTypeEnum.manual_event_end, (detection["id"], detection["last_detection"]), + EventMetadataTypeEnum.manual_event_end.value, ) self.detections[detection["label"]] = None @@ -343,8 +343,8 @@ class AudioEventMaintainer(threading.Thread): f"{self.camera_config.name}/audio/{label}", "OFF" ) self.event_metadata_publisher.publish( - EventMetadataTypeEnum.manual_event_end, (detection["id"], now), + EventMetadataTypeEnum.manual_event_end.value, ) self.detections[label] = None