mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Reolink onvif not supported fix (#99714)
* only subscibe to ONVIF if supported * Catch NotSupportedError when ONVIF is not supported * fix styling
This commit is contained in:
parent
98896834cd
commit
107ca83d42
@ -10,7 +10,7 @@ import aiohttp
|
||||
from aiohttp.web import Request
|
||||
from reolink_aio.api import Host
|
||||
from reolink_aio.enums import SubType
|
||||
from reolink_aio.exceptions import ReolinkError, SubscriptionError
|
||||
from reolink_aio.exceptions import NotSupportedError, ReolinkError, SubscriptionError
|
||||
|
||||
from homeassistant.components import webhook
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
|
||||
@ -61,6 +61,7 @@ class ReolinkHost:
|
||||
)
|
||||
|
||||
self.webhook_id: str | None = None
|
||||
self._onvif_supported: bool = True
|
||||
self._base_url: str = ""
|
||||
self._webhook_url: str = ""
|
||||
self._webhook_reachable: bool = False
|
||||
@ -96,6 +97,8 @@ class ReolinkHost:
|
||||
f"'{self._api.user_level}', only admin users can change camera settings"
|
||||
)
|
||||
|
||||
self._onvif_supported = self._api.supported(None, "ONVIF")
|
||||
|
||||
enable_rtsp = None
|
||||
enable_onvif = None
|
||||
enable_rtmp = None
|
||||
@ -106,7 +109,7 @@ class ReolinkHost:
|
||||
)
|
||||
enable_rtsp = True
|
||||
|
||||
if not self._api.onvif_enabled:
|
||||
if not self._api.onvif_enabled and self._onvif_supported:
|
||||
_LOGGER.debug(
|
||||
"ONVIF is disabled on %s, trying to enable it", self._api.nvr_name
|
||||
)
|
||||
@ -154,21 +157,34 @@ class ReolinkHost:
|
||||
|
||||
self._unique_id = format_mac(self._api.mac_address)
|
||||
|
||||
await self.subscribe()
|
||||
|
||||
if self._api.supported(None, "initial_ONVIF_state"):
|
||||
if self._onvif_supported:
|
||||
try:
|
||||
await self.subscribe()
|
||||
except NotSupportedError:
|
||||
self._onvif_supported = False
|
||||
self.unregister_webhook()
|
||||
await self._api.unsubscribe()
|
||||
else:
|
||||
if self._api.supported(None, "initial_ONVIF_state"):
|
||||
_LOGGER.debug(
|
||||
"Waiting for initial ONVIF state on webhook '%s'",
|
||||
self._webhook_url,
|
||||
)
|
||||
else:
|
||||
_LOGGER.debug(
|
||||
"Camera model %s most likely does not push its initial state"
|
||||
" upon ONVIF subscription, do not check",
|
||||
self._api.model,
|
||||
)
|
||||
self._cancel_onvif_check = async_call_later(
|
||||
self._hass, FIRST_ONVIF_TIMEOUT, self._async_check_onvif
|
||||
)
|
||||
if not self._onvif_supported:
|
||||
_LOGGER.debug(
|
||||
"Waiting for initial ONVIF state on webhook '%s'", self._webhook_url
|
||||
)
|
||||
else:
|
||||
_LOGGER.debug(
|
||||
"Camera model %s most likely does not push its initial state"
|
||||
" upon ONVIF subscription, do not check",
|
||||
"Camera model %s does not support ONVIF, using fast polling instead",
|
||||
self._api.model,
|
||||
)
|
||||
self._cancel_onvif_check = async_call_later(
|
||||
self._hass, FIRST_ONVIF_TIMEOUT, self._async_check_onvif
|
||||
)
|
||||
await self._async_poll_all_motion()
|
||||
|
||||
if self._api.sw_version_update_required:
|
||||
ir.async_create_issue(
|
||||
@ -365,6 +381,9 @@ class ReolinkHost:
|
||||
|
||||
async def renew(self) -> None:
|
||||
"""Renew the subscription of motion events (lease time is 15 minutes)."""
|
||||
if not self._onvif_supported:
|
||||
return
|
||||
|
||||
try:
|
||||
await self._renew(SubType.push)
|
||||
if self._long_poll_task is not None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user