Fix creating onvif pull point subscriptions when InitialTerminationTime is required (#91470)

* Fix creating onvif pull point subscriptions when InitialTerminationTime is required

fixes #85902

* Bump again because I got it wrong the first time.. this is why retest is good
This commit is contained in:
J. Nick Koston 2023-04-15 09:34:07 -10:00 committed by Franck Nijhof
parent 89b1d5bb68
commit b06d624d43
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
4 changed files with 16 additions and 10 deletions

View File

@ -32,6 +32,15 @@ def _stringify_onvif_error(error: Exception) -> str:
return str(error)
def _get_next_termination_time() -> str:
"""Get next termination time."""
return (
(dt_util.utcnow() + dt.timedelta(days=1))
.isoformat(timespec="seconds")
.replace("+00:00", "Z")
)
class EventManager:
"""ONVIF Event Manager."""
@ -84,7 +93,9 @@ class EventManager:
async def async_start(self) -> bool:
"""Start polling events."""
if not await self.device.create_pullpoint_subscription():
if not await self.device.create_pullpoint_subscription(
{"InitialTerminationTime": _get_next_termination_time()}
):
return False
# Create subscription manager
@ -171,16 +182,11 @@ class EventManager:
if not self._subscription:
return
termination_time = (
(dt_util.utcnow() + dt.timedelta(days=1))
.isoformat(timespec="seconds")
.replace("+00:00", "Z")
)
with suppress(*SUBSCRIPTION_ERRORS):
# The first time we renew, we may get a Fault error so we
# suppress it. The subscription will be restarted in
# async_restart later.
await self._subscription.Renew(termination_time)
await self._subscription.Renew(_get_next_termination_time())
def async_schedule_pull(self) -> None:
"""Schedule async_pull_messages to run."""

View File

@ -7,5 +7,5 @@
"documentation": "https://www.home-assistant.io/integrations/onvif",
"iot_class": "local_push",
"loggers": ["onvif", "wsdiscovery", "zeep"],
"requirements": ["onvif-zeep-async==1.2.5", "WSDiscovery==2.0.0"]
"requirements": ["onvif-zeep-async==1.2.7", "WSDiscovery==2.0.0"]
}

View File

@ -1260,7 +1260,7 @@ ondilo==0.2.0
onkyo-eiscp==1.2.7
# homeassistant.components.onvif
onvif-zeep-async==1.2.5
onvif-zeep-async==1.2.7
# homeassistant.components.opengarage
open-garage==0.2.0

View File

@ -938,7 +938,7 @@ omnilogic==0.4.5
ondilo==0.2.0
# homeassistant.components.onvif
onvif-zeep-async==1.2.5
onvif-zeep-async==1.2.7
# homeassistant.components.opengarage
open-garage==0.2.0