Fix ONVIF cameras that change the xaddr for the pull point service (#93104)

This commit is contained in:
J. Nick Koston 2023-05-17 06:14:31 -05:00 committed by GitHub
parent fb7c579216
commit 00b600bfa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,7 @@ import datetime as dt
from aiohttp.web import Request from aiohttp.web import Request
from httpx import RemoteProtocolError, RequestError, TransportError from httpx import RemoteProtocolError, RequestError, TransportError
from onvif import ONVIFCamera, ONVIFService from onvif import ONVIFCamera
from onvif.client import ( from onvif.client import (
NotificationManager, NotificationManager,
PullPointManager as ONVIFPullPointManager, PullPointManager as ONVIFPullPointManager,
@ -240,7 +240,6 @@ class PullPointManager:
self._hass = event_manager.hass self._hass = event_manager.hass
self._name = event_manager.name self._name = event_manager.name
self._pullpoint_service: ONVIFService = None
self._pullpoint_manager: ONVIFPullPointManager | None = None self._pullpoint_manager: ONVIFPullPointManager | None = None
self._cancel_pull_messages: CALLBACK_TYPE | None = None self._cancel_pull_messages: CALLBACK_TYPE | None = None
@ -317,7 +316,6 @@ class PullPointManager:
self._pullpoint_manager = await self._device.create_pullpoint_manager( self._pullpoint_manager = await self._device.create_pullpoint_manager(
SUBSCRIPTION_TIME, self._event_manager.async_mark_events_stale SUBSCRIPTION_TIME, self._event_manager.async_mark_events_stale
) )
self._pullpoint_service = self._pullpoint_manager.get_service()
await self._pullpoint_manager.set_synchronization_point() await self._pullpoint_manager.set_synchronization_point()
async def _async_unsubscribe_pullpoint(self) -> None: async def _async_unsubscribe_pullpoint(self) -> None:
@ -342,7 +340,7 @@ class PullPointManager:
"""Pull messages from device.""" """Pull messages from device."""
if self._pullpoint_manager is None: if self._pullpoint_manager is None:
return return
assert self._pullpoint_service is not None, "PullPoint service does not exist" service = self._pullpoint_manager.get_service()
LOGGER.debug( LOGGER.debug(
"%s: Pulling PullPoint messages timeout=%s limit=%s", "%s: Pulling PullPoint messages timeout=%s limit=%s",
self._name, self._name,
@ -353,7 +351,7 @@ class PullPointManager:
response = None response = None
try: try:
if self._hass.is_running: if self._hass.is_running:
response = await self._pullpoint_service.PullMessages( response = await service.PullMessages(
{ {
"MessageLimit": PULLPOINT_MESSAGE_LIMIT, "MessageLimit": PULLPOINT_MESSAGE_LIMIT,
"Timeout": PULLPOINT_POLL_TIME, "Timeout": PULLPOINT_POLL_TIME,
@ -445,7 +443,7 @@ class PullPointManager:
self.async_cancel_pull_messages() self.async_cancel_pull_messages()
if self.state != PullPointManagerState.STARTED: if self.state != PullPointManagerState.STARTED:
return return
if self._pullpoint_service: if self._pullpoint_manager:
when = delay if delay is not None else PULLPOINT_COOLDOWN_TIME when = delay if delay is not None else PULLPOINT_COOLDOWN_TIME
self._cancel_pull_messages = async_call_later( self._cancel_pull_messages = async_call_later(
self._hass, when, self._pull_messages_job self._hass, when, self._pull_messages_job