fix calibration

This commit is contained in:
Josh Hawkins 2025-05-06 17:56:37 -05:00
parent ffc09814fe
commit e244121a68
2 changed files with 5 additions and 10 deletions

View File

@ -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(),
)

View File

@ -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