diff --git a/homeassistant/components/onvif/event.py b/homeassistant/components/onvif/event.py index 84d75bf8048..1b6ee844eec 100644 --- a/homeassistant/components/onvif/event.py +++ b/homeassistant/components/onvif/event.py @@ -34,6 +34,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.""" @@ -86,7 +95,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 @@ -173,16 +184,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.""" diff --git a/homeassistant/components/onvif/manifest.json b/homeassistant/components/onvif/manifest.json index 9095bb2620e..04e26980921 100644 --- a/homeassistant/components/onvif/manifest.json +++ b/homeassistant/components/onvif/manifest.json @@ -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"] } diff --git a/requirements_all.txt b/requirements_all.txt index b0a1e39edd3..e9d93cb9351 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 898059379ff..86521433141 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -941,7 +941,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