Use zoom space id in Onvif RelativeMove setup (#9859)

* use zoom space id in onvif relativemove setup

* better handle cases when zooming is disabled
This commit is contained in:
Josh Hawkins 2024-02-16 06:09:30 -06:00 committed by GitHub
parent bad80a64ef
commit 616eb5f96a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -151,7 +151,10 @@ class OnvifController:
# autoracking relative panning/tilting needs a relative zoom value set to 0
# if camera supports relative movement
if self.config.cameras[camera_name].onvif.autotracking.zooming:
if (
self.config.cameras[camera_name].onvif.autotracking.zooming
!= ZoomingModeEnum.disabled
):
zoom_space_id = next(
(
i
@ -182,23 +185,21 @@ class OnvifController:
try:
if (
self.config.cameras[camera_name].onvif.autotracking.zooming
== ZoomingModeEnum.relative
!= ZoomingModeEnum.disabled
):
if zoom_space_id is not None:
move_request.Translation.Zoom.space = ptz_config["Spaces"][
"RelativeZoomTranslationSpace"
][0]["URI"]
][zoom_space_id]["URI"]
else:
move_request.Translation.Zoom = []
except Exception:
if (
self.config.cameras[camera_name].onvif.autotracking.zooming
== ZoomingModeEnum.relative
):
self.config.cameras[
camera_name
].onvif.autotracking.zooming = ZoomingModeEnum.disabled
logger.warning(
f"Disabling autotracking zooming for {camera_name}: Relative zoom not supported"
)
self.config.cameras[
camera_name
].onvif.autotracking.zooming = ZoomingModeEnum.disabled
logger.warning(
f"Disabling autotracking zooming for {camera_name}: Relative zoom not supported"
)
if move_request.Speed is None:
move_request.Speed = configs.DefaultPTZSpeed if configs else None
@ -387,7 +388,11 @@ class OnvifController:
move_request.Translation.PanTilt.x = pan
move_request.Translation.PanTilt.y = tilt
if "zoom-r" in self.cams[camera_name]["features"]:
if (
"zoom-r" in self.cams[camera_name]["features"]
and self.config.cameras[camera_name].onvif.autotracking.zooming
== ZoomingModeEnum.relative
):
move_request.Speed = {
"PanTilt": {
"x": speed,
@ -403,7 +408,11 @@ class OnvifController:
move_request.Translation.PanTilt.x = 0
move_request.Translation.PanTilt.y = 0
if "zoom-r" in self.cams[camera_name]["features"]:
if (
"zoom-r" in self.cams[camera_name]["features"]
and self.config.cameras[camera_name].onvif.autotracking.zooming
== ZoomingModeEnum.relative
):
move_request.Translation.Zoom.x = 0
self.cams[camera_name]["active"] = False