Catch onvif command error

This commit is contained in:
Nicolas Mowen 2024-12-19 07:30:43 -07:00
parent b149828c9f
commit 7bf2b56ce6

View File

@ -558,22 +558,26 @@ class OnvifController:
if not self._init_onvif(camera_name): if not self._init_onvif(camera_name):
return return
if command == OnvifCommandEnum.init: try:
# already init if command == OnvifCommandEnum.init:
return # already init
elif command == OnvifCommandEnum.stop: return
self._stop(camera_name) elif command == OnvifCommandEnum.stop:
elif command == OnvifCommandEnum.preset: self._stop(camera_name)
self._move_to_preset(camera_name, param) elif command == OnvifCommandEnum.preset:
elif command == OnvifCommandEnum.move_relative: self._move_to_preset(camera_name, param)
_, pan, tilt = param.split("_") elif command == OnvifCommandEnum.move_relative:
self._move_relative(camera_name, float(pan), float(tilt), 0, 1) _, pan, tilt = param.split("_")
elif ( self._move_relative(camera_name, float(pan), float(tilt), 0, 1)
command == OnvifCommandEnum.zoom_in or command == OnvifCommandEnum.zoom_out elif (
): command == OnvifCommandEnum.zoom_in
self._zoom(camera_name, command) or command == OnvifCommandEnum.zoom_out
else: ):
self._move(camera_name, command) self._zoom(camera_name, command)
else:
self._move(camera_name, command)
except ONVIFError as e:
logger.error(f"Unable to handle onvif command: {e}")
def get_camera_info(self, camera_name: str) -> dict[str, any]: def get_camera_info(self, camera_name: str) -> dict[str, any]:
if camera_name not in self.cams.keys(): if camera_name not in self.cams.keys():