diff --git a/frigate/review/maintainer.py b/frigate/review/maintainer.py index 917c0c5acd..35a7e1708b 100644 --- a/frigate/review/maintainer.py +++ b/frigate/review/maintainer.py @@ -464,6 +464,12 @@ def update_existing_segment( self.frame_manager.close(frame_name) except FileNotFoundError: return + # indefinite (manual) events should extend the segment until they end + if ( + segment.camera in self.indefinite_events + and len(self.indefinite_events[segment.camera]) > 0 + ): + has_activity = True if not has_activity: if not segment.has_frame: @@ -699,13 +705,25 @@ def run(self) -> None: topic == DetectionTypeEnum.api and self.config.cameras[camera].review.alerts.enabled ): - current_segment.severity = SeverityEnum.alert + if ( + self.config.cameras[camera].review.detections.enabled + and manual_info["label"].split(": ")[0] + in self.config.cameras[camera].review.detections.labels + ): + current_segment.last_detection_time = manual_info[ + "end_time" + ] + else: + current_segment.severity = SeverityEnum.alert + current_segment.last_alert_time = manual_info[ + "end_time" + ] elif ( topic == DetectionTypeEnum.lpr and self.config.cameras[camera].review.detections.enabled ): current_segment.severity = SeverityEnum.detection - current_segment.last_alert_time = manual_info["end_time"] + current_segment.last_alert_time = manual_info["end_time"] elif manual_info["state"] == ManualEventState.start: self.indefinite_events[camera][manual_info["event_id"]] = ( manual_info["label"] @@ -717,7 +735,16 @@ def run(self) -> None: topic == DetectionTypeEnum.api and self.config.cameras[camera].review.alerts.enabled ): - current_segment.severity = SeverityEnum.alert + if ( + not self.config.cameras[ + camera + ].review.detections.enabled + or manual_info["label"].split(": ")[0] + not in self.config.cameras[ + camera + ].review.detections.labels + ): + current_segment.severity = SeverityEnum.alert elif ( topic == DetectionTypeEnum.lpr and self.config.cameras[camera].review.detections.enabled @@ -789,11 +816,21 @@ def run(self) -> None: detections, ) elif topic == DetectionTypeEnum.api: - if self.config.cameras[camera].review.alerts.enabled: + severity = None + if ( + self.config.cameras[camera].review.detections.enabled + and manual_info["label"].split(": ")[0] + in self.config.cameras[camera].review.detections.labels + ): + severity = SeverityEnum.detection + elif self.config.cameras[camera].review.alerts.enabled: + severity = SeverityEnum.alert + + if severity: self.active_review_segments[camera] = PendingReviewSegment( camera, frame_time, - SeverityEnum.alert, + severity, {manual_info["event_id"]: manual_info["label"]}, {}, [], @@ -820,7 +857,7 @@ def run(self) -> None: ].last_detection_time = manual_info["end_time"] else: logger.warning( - f"Manual event API has been called for {camera}, but alerts are disabled. This manual event will not appear as an alert." + f"Manual event API has been called for {camera}, but alerts and detections are disabled. This manual event will not appear as an alert or detection." ) elif topic == DetectionTypeEnum.lpr: if self.config.cameras[camera].review.detections.enabled: diff --git a/frigate/track/object_processing.py b/frigate/track/object_processing.py index e0ee74228a..83b72d6612 100644 --- a/frigate/track/object_processing.py +++ b/frigate/track/object_processing.py @@ -536,8 +536,7 @@ def create_manual_event(self, payload: tuple) -> None: "sub_label": sub_label, "score": score, "camera": camera_name, - "start_time": frame_time - - self.config.cameras[camera_name].record.event_pre_capture, + "start_time": frame_time, "end_time": end_time, "has_clip": self.config.cameras[camera_name].record.enabled and include_recording,