Handle invalid datetime in onvif (#136014)

This commit is contained in:
J. Nick Koston 2025-01-19 09:16:40 -10:00 committed by Franck Nijhof
parent b1445e5926
commit 5d1e2d17da
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3

View File

@ -263,6 +263,7 @@ class ONVIFDevice:
LOGGER.warning("%s: Could not retrieve date/time on this camera", self.name) LOGGER.warning("%s: Could not retrieve date/time on this camera", self.name)
return return
try:
cam_date = dt.datetime( cam_date = dt.datetime(
cdate.Date.Year, cdate.Date.Year,
cdate.Date.Month, cdate.Date.Month,
@ -273,6 +274,11 @@ class ONVIFDevice:
0, 0,
tzone, tzone,
) )
except ValueError as err:
LOGGER.warning(
"%s: Could not parse date/time from camera: %s", self.name, err
)
return
cam_date_utc = cam_date.astimezone(dt_util.UTC) cam_date_utc = cam_date.astimezone(dt_util.UTC)