mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 00:07:10 +00:00
update renew logic to work better with cameras responding with invalid termination times by extending the duration (#36393)
This commit is contained in:
parent
660265fe50
commit
eb95c5cd2e
@ -100,16 +100,6 @@ class ONVIFDevice:
|
|||||||
if self.capabilities.ptz:
|
if self.capabilities.ptz:
|
||||||
self.device.create_ptz_service()
|
self.device.create_ptz_service()
|
||||||
|
|
||||||
if self._dt_diff_seconds > 300 and self.capabilities.events:
|
|
||||||
self.capabilities.events = False
|
|
||||||
LOGGER.warning(
|
|
||||||
"The system clock on '%s' is more than 5 minutes off. "
|
|
||||||
"Although this device supports events, they will be "
|
|
||||||
"disabled until the device clock is fixed as we will "
|
|
||||||
"not be able to renew the subscription.",
|
|
||||||
self.name,
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.capabilities.events:
|
if self.capabilities.events:
|
||||||
self.events = EventManager(
|
self.events = EventManager(
|
||||||
self.hass, self.device, self.config_entry.unique_id
|
self.hass, self.device, self.config_entry.unique_id
|
||||||
|
@ -107,7 +107,9 @@ class EventManager:
|
|||||||
if not self._subscription:
|
if not self._subscription:
|
||||||
return
|
return
|
||||||
|
|
||||||
termination_time = (dt_util.utcnow() + dt.timedelta(minutes=30)).isoformat()
|
termination_time = (
|
||||||
|
(dt_util.utcnow() + dt.timedelta(days=1)).replace(microsecond=0).isoformat()
|
||||||
|
)
|
||||||
await self._subscription.Renew(termination_time)
|
await self._subscription.Renew(termination_time)
|
||||||
|
|
||||||
async def async_pull_messages(self, _now: dt = None) -> None:
|
async def async_pull_messages(self, _now: dt = None) -> None:
|
||||||
@ -119,8 +121,10 @@ class EventManager:
|
|||||||
req.Timeout = dt.timedelta(seconds=60)
|
req.Timeout = dt.timedelta(seconds=60)
|
||||||
response = await pullpoint.PullMessages(req)
|
response = await pullpoint.PullMessages(req)
|
||||||
|
|
||||||
# Renew subscription if less than 60 seconds left
|
# Renew subscription if less than two hours is left
|
||||||
if (response.TerminationTime - dt_util.utcnow()).total_seconds() < 60:
|
if (
|
||||||
|
dt_util.as_utc(response.TerminationTime) - dt_util.utcnow()
|
||||||
|
).total_seconds() < 7200:
|
||||||
await self.async_renew()
|
await self.async_renew()
|
||||||
|
|
||||||
# Parse response
|
# Parse response
|
||||||
|
Loading…
x
Reference in New Issue
Block a user