mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
Fix problem with cameras that don't support time (#23924)
Some onvif cameras don't support Date management. In that case None is returned and script crashes when trying to obtain date
This commit is contained in:
parent
a303f67d3b
commit
edf34eea94
@ -164,27 +164,28 @@ class ONVIFHassCamera(Camera):
|
|||||||
|
|
||||||
system_date = dt_util.utcnow()
|
system_date = dt_util.utcnow()
|
||||||
device_time = await devicemgmt.GetSystemDateAndTime()
|
device_time = await devicemgmt.GetSystemDateAndTime()
|
||||||
cdate = device_time.UTCDateTime
|
if device_time:
|
||||||
cam_date = dt.datetime(cdate.Date.Year, cdate.Date.Month,
|
cdate = device_time.UTCDateTime
|
||||||
cdate.Date.Day, cdate.Time.Hour,
|
cam_date = dt.datetime(cdate.Date.Year, cdate.Date.Month,
|
||||||
cdate.Time.Minute, cdate.Time.Second,
|
cdate.Date.Day, cdate.Time.Hour,
|
||||||
0, dt_util.UTC)
|
cdate.Time.Minute, cdate.Time.Second,
|
||||||
|
0, dt_util.UTC)
|
||||||
|
|
||||||
_LOGGER.debug("Camera date/time: %s",
|
_LOGGER.debug("Camera date/time: %s",
|
||||||
cam_date)
|
cam_date)
|
||||||
|
|
||||||
_LOGGER.debug("System date/time: %s",
|
_LOGGER.debug("System date/time: %s",
|
||||||
system_date)
|
system_date)
|
||||||
|
|
||||||
dt_diff = cam_date - system_date
|
dt_diff = cam_date - system_date
|
||||||
dt_diff_seconds = dt_diff.total_seconds()
|
dt_diff_seconds = dt_diff.total_seconds()
|
||||||
|
|
||||||
if dt_diff_seconds > 5:
|
if dt_diff_seconds > 5:
|
||||||
_LOGGER.warning("The date/time on the camera is '%s', "
|
_LOGGER.warning("The date/time on the camera is '%s', "
|
||||||
"which is different from the system '%s', "
|
"which is different from the system '%s', "
|
||||||
"this could lead to authentication issues",
|
"this could lead to authentication issues",
|
||||||
cam_date,
|
cam_date,
|
||||||
system_date)
|
system_date)
|
||||||
|
|
||||||
_LOGGER.debug("Obtaining input uri")
|
_LOGGER.debug("Obtaining input uri")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user