From e244121a689f3a50e9bc53a25e3f30b8f159d962 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Tue, 6 May 2025 17:56:37 -0500 Subject: [PATCH] fix calibration --- frigate/ptz/autotrack.py | 8 ++++---- frigate/ptz/onvif.py | 7 +------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/frigate/ptz/autotrack.py b/frigate/ptz/autotrack.py index e7a2b7045..709165c24 100644 --- a/frigate/ptz/autotrack.py +++ b/frigate/ptz/autotrack.py @@ -334,7 +334,7 @@ class PtzAutoTracker: ) if camera_config.onvif.autotracking.calibrate_on_startup: - self._calibrate_camera(camera) + await self._calibrate_camera(camera) self.ptz_metrics[camera].tracking_active.clear() self.dispatcher.publish(f"{camera}/ptz_autotracker/active", "OFF", retain=False) @@ -377,7 +377,7 @@ class PtzAutoTracker: for i in range(2): # absolute move to 0 - fully zoomed out - self.onvif._zoom_absolute( + await self.onvif._zoom_absolute( camera, self.onvif.cams[camera]["absolute_zoom_range"]["XRange"]["Min"], 1, @@ -388,7 +388,7 @@ class PtzAutoTracker: zoom_out_values.append(self.ptz_metrics[camera].zoom_level.value) - self.onvif._zoom_absolute( + await self.onvif._zoom_absolute( camera, self.onvif.cams[camera]["absolute_zoom_range"]["XRange"]["Max"], 1, @@ -475,7 +475,7 @@ class PtzAutoTracker: self.ptz_metrics[camera].max_zoom.value = 1 self.ptz_metrics[camera].min_zoom.value = 0 - self.onvif._move_to_preset( + await self.onvif._move_to_preset( camera, self.config.cameras[camera].onvif.autotracking.return_preset.lower(), ) diff --git a/frigate/ptz/onvif.py b/frigate/ptz/onvif.py index 25ff44cf8..c5c1b96b1 100644 --- a/frigate/ptz/onvif.py +++ b/frigate/ptz/onvif.py @@ -107,6 +107,7 @@ class OnvifController: return True except (Fault, ONVIFError, TransportError, Exception) as e: logger.error(f"Failed to create ONVIF camera instance for {cam_name}: {e}") + # track initial failures self.failed_cams[cam_name] = { "retry_attempts": 0, "last_error": str(e), @@ -595,12 +596,6 @@ class OnvifController: self, camera_name: str, command: OnvifCommandEnum, param: str = "" ) -> None: """Handle ONVIF commands asynchronously""" - current_loop = asyncio.get_running_loop() - expected_loop = self.loop - if current_loop is not expected_loop: - logger.error( - f"Wrong event loop in _move! Expected {expected_loop}, got {current_loop}" - ) if camera_name not in self.cams.keys(): logger.error(f"ONVIF is not configured for {camera_name}") return