Allow API Events to be Detections or Alerts, depending on the Event Label (#21923)

* - API created events will be alerts OR detections, depending on the event label, defaulting to alerts
- Indefinite API events will extend the recording segment until those events are ended
- API event start time is the actual start time, instead of having a pre-buffer of record.event_pre_capture

* Instead of checking for indefinite events on a camera before deciding if we should end the segment, only update last_detection_time and last_alert_time if frame_time is greater, which should have the same effect

* Add the ability to set a pre_capture number of seconds when creating a manual event via the API. Default behavior unchanged

* Remove unnecessary _publish_segment_start() call

* Formatting

* handle last_alert_time or last_detection_time being None when checking them against the frame_time

* comment manual_info["label"].split(": ")[0] for clarity
This commit is contained in:
nulledy
2026-02-11 17:09:26 -05:00
committed by Nicolas Mowen
parent 257114b63f
commit f49775e89a
5 changed files with 70 additions and 14 deletions

View File

@@ -515,6 +515,7 @@ class TrackedObjectProcessor(threading.Thread):
duration,
source_type,
draw,
pre_capture,
) = payload
# save the snapshot image
@@ -522,6 +523,11 @@ class TrackedObjectProcessor(threading.Thread):
None, event_id, label, draw
)
end_time = frame_time + duration if duration is not None else None
start_time = (
frame_time - self.config.cameras[camera_name].record.event_pre_capture
if pre_capture is None
else frame_time - pre_capture
)
# send event to event maintainer
self.event_sender.publish(
@@ -536,8 +542,7 @@ class TrackedObjectProcessor(threading.Thread):
"sub_label": sub_label,
"score": score,
"camera": camera_name,
"start_time": frame_time
- self.config.cameras[camera_name].record.event_pre_capture,
"start_time": start_time,
"end_time": end_time,
"has_clip": self.config.cameras[camera_name].record.enabled
and include_recording,