catch exceptions for unsupported cameras

This commit is contained in:
Josh Hawkins 2024-02-01 09:48:57 -06:00
parent d77e225bf6
commit 73dfdad4c7

View File

@ -528,24 +528,25 @@ class OnvifController:
except Exception: except Exception:
pass # We're unsupported, that'll be reported in the next check. pass # We're unsupported, that'll be reported in the next check.
# there doesn't seem to be an onvif standard with this optional parameter try:
# some cameras can report MoveStatus with or without PanTilt or Zoom attributes pan_tilt_status = getattr(status.MoveStatus, "PanTilt", None)
pan_tilt_status = getattr(status.MoveStatus, "PanTilt", None) zoom_status = getattr(status.MoveStatus, "Zoom", None)
zoom_status = getattr(status.MoveStatus, "Zoom", None)
# if it's not an attribute, see if MoveStatus even exists in the status result # if it's not an attribute, see if MoveStatus even exists in the status result
if pan_tilt_status is None: if pan_tilt_status is None:
pan_tilt_status = getattr(status, "MoveStatus", None) pan_tilt_status = getattr(status, "MoveStatus", None)
# we're unsupported # we're unsupported
if pan_tilt_status is None or pan_tilt_status not in [ if pan_tilt_status is None or pan_tilt_status not in [
"IDLE", "IDLE",
"MOVING", "MOVING",
]: ]:
logger.error( raise Exception
f"Camera {camera_name} does not support the ONVIF GetStatus method. Autotracking will not function correctly and must be disabled in your config." except Exception:
) logger.warning(
return f"Camera {camera_name} does not support the ONVIF GetStatus method. Autotracking will not function correctly and must be disabled in your config."
)
return
if pan_tilt_status == "IDLE" and (zoom_status is None or zoom_status == "IDLE"): if pan_tilt_status == "IDLE" and (zoom_status is None or zoom_status == "IDLE"):
self.cams[camera_name]["active"] = False self.cams[camera_name]["active"] = False