Bump reolink-aio to 0.7.1 (#94761)
This commit is contained in:
parent
52f49fc32d
commit
ee7f44b3da
5 changed files with 23 additions and 16 deletions
|
@ -9,6 +9,7 @@ from typing import Any
|
|||
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 homeassistant.components import webhook
|
||||
|
@ -256,7 +257,7 @@ class ReolinkHost:
|
|||
if self.webhook_id is None:
|
||||
self.register_webhook()
|
||||
|
||||
if self._api.subscribed:
|
||||
if self._api.subscribed(SubType.push):
|
||||
_LOGGER.debug(
|
||||
"Host %s: is already subscribed to webhook %s",
|
||||
self._api.host,
|
||||
|
@ -275,7 +276,7 @@ class ReolinkHost:
|
|||
async def renew(self) -> None:
|
||||
"""Renew the subscription of motion events (lease time is 15 minutes)."""
|
||||
try:
|
||||
await self._renew()
|
||||
await self._renew(SubType.push)
|
||||
except SubscriptionError as err:
|
||||
if not self._lost_subscription:
|
||||
self._lost_subscription = True
|
||||
|
@ -287,22 +288,24 @@ class ReolinkHost:
|
|||
else:
|
||||
self._lost_subscription = False
|
||||
|
||||
async def _renew(self) -> None:
|
||||
async def _renew(self, sub_type: SubType) -> None:
|
||||
"""Execute the renew of the subscription."""
|
||||
if not self._api.subscribed:
|
||||
if not self._api.subscribed(sub_type):
|
||||
_LOGGER.debug(
|
||||
"Host %s: requested to renew a non-existing Reolink subscription, "
|
||||
"Host %s: requested to renew a non-existing Reolink %s subscription, "
|
||||
"trying to subscribe from scratch",
|
||||
self._api.host,
|
||||
sub_type,
|
||||
)
|
||||
await self.subscribe()
|
||||
return
|
||||
|
||||
timer = self._api.renewtimer
|
||||
timer = self._api.renewtimer(sub_type)
|
||||
_LOGGER.debug(
|
||||
"Host %s:%s should renew subscription in: %i seconds",
|
||||
"Host %s:%s should renew %s subscription in: %i seconds",
|
||||
self._api.host,
|
||||
self._api.port,
|
||||
sub_type,
|
||||
timer,
|
||||
)
|
||||
if timer > SUBSCRIPTION_RENEW_THRESHOLD:
|
||||
|
@ -310,25 +313,29 @@ class ReolinkHost:
|
|||
|
||||
if timer > 0:
|
||||
try:
|
||||
await self._api.renew()
|
||||
await self._api.renew(sub_type)
|
||||
except SubscriptionError as err:
|
||||
_LOGGER.debug(
|
||||
"Host %s: error renewing Reolink subscription, "
|
||||
"Host %s: error renewing Reolink %s subscription, "
|
||||
"trying to subscribe again: %s",
|
||||
self._api.host,
|
||||
sub_type,
|
||||
err,
|
||||
)
|
||||
else:
|
||||
_LOGGER.debug(
|
||||
"Host %s successfully renewed Reolink subscription", self._api.host
|
||||
"Host %s successfully renewed Reolink %s subscription",
|
||||
self._api.host,
|
||||
sub_type,
|
||||
)
|
||||
return
|
||||
|
||||
await self._api.subscribe(self._webhook_url)
|
||||
await self._api.subscribe(self._webhook_url, sub_type)
|
||||
|
||||
_LOGGER.debug(
|
||||
"Host %s: Reolink re-subscription successful after it was expired",
|
||||
"Host %s: Reolink %s re-subscription successful after it was expired",
|
||||
self._api.host,
|
||||
sub_type,
|
||||
)
|
||||
|
||||
def register_webhook(self) -> None:
|
||||
|
|
|
@ -18,5 +18,5 @@
|
|||
"documentation": "https://www.home-assistant.io/integrations/reolink",
|
||||
"iot_class": "local_push",
|
||||
"loggers": ["reolink_aio"],
|
||||
"requirements": ["reolink-aio==0.6.0"]
|
||||
"requirements": ["reolink-aio==0.7.1"]
|
||||
}
|
||||
|
|
|
@ -2268,7 +2268,7 @@ renault-api==0.1.13
|
|||
renson-endura-delta==1.5.0
|
||||
|
||||
# homeassistant.components.reolink
|
||||
reolink-aio==0.6.0
|
||||
reolink-aio==0.7.1
|
||||
|
||||
# homeassistant.components.idteck_prox
|
||||
rfk101py==0.0.1
|
||||
|
|
|
@ -1655,7 +1655,7 @@ renault-api==0.1.13
|
|||
renson-endura-delta==1.5.0
|
||||
|
||||
# homeassistant.components.reolink
|
||||
reolink-aio==0.6.0
|
||||
reolink-aio==0.7.1
|
||||
|
||||
# homeassistant.components.rflink
|
||||
rflink==0.0.65
|
||||
|
|
|
@ -59,7 +59,7 @@ def reolink_connect(mock_get_source_ip: None) -> Generator[MagicMock, None, None
|
|||
host_mock.user_level = "admin"
|
||||
host_mock.sw_version_update_required = False
|
||||
host_mock.timeout = 60
|
||||
host_mock.renewtimer = 600
|
||||
host_mock.renewtimer.return_value = 600
|
||||
yield host_mock
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue