mirror of
https://github.com/home-assistant/core.git
synced 2025-04-29 19:57:52 +00:00
Bump reolink-aio to 0.7.1 (#94761)
This commit is contained in:
parent
52f49fc32d
commit
ee7f44b3da
@ -9,6 +9,7 @@ from typing import Any
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
from aiohttp.web import Request
|
from aiohttp.web import Request
|
||||||
from reolink_aio.api import Host
|
from reolink_aio.api import Host
|
||||||
|
from reolink_aio.enums import SubType
|
||||||
from reolink_aio.exceptions import ReolinkError, SubscriptionError
|
from reolink_aio.exceptions import ReolinkError, SubscriptionError
|
||||||
|
|
||||||
from homeassistant.components import webhook
|
from homeassistant.components import webhook
|
||||||
@ -256,7 +257,7 @@ class ReolinkHost:
|
|||||||
if self.webhook_id is None:
|
if self.webhook_id is None:
|
||||||
self.register_webhook()
|
self.register_webhook()
|
||||||
|
|
||||||
if self._api.subscribed:
|
if self._api.subscribed(SubType.push):
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Host %s: is already subscribed to webhook %s",
|
"Host %s: is already subscribed to webhook %s",
|
||||||
self._api.host,
|
self._api.host,
|
||||||
@ -275,7 +276,7 @@ class ReolinkHost:
|
|||||||
async def renew(self) -> None:
|
async def renew(self) -> None:
|
||||||
"""Renew the subscription of motion events (lease time is 15 minutes)."""
|
"""Renew the subscription of motion events (lease time is 15 minutes)."""
|
||||||
try:
|
try:
|
||||||
await self._renew()
|
await self._renew(SubType.push)
|
||||||
except SubscriptionError as err:
|
except SubscriptionError as err:
|
||||||
if not self._lost_subscription:
|
if not self._lost_subscription:
|
||||||
self._lost_subscription = True
|
self._lost_subscription = True
|
||||||
@ -287,22 +288,24 @@ class ReolinkHost:
|
|||||||
else:
|
else:
|
||||||
self._lost_subscription = False
|
self._lost_subscription = False
|
||||||
|
|
||||||
async def _renew(self) -> None:
|
async def _renew(self, sub_type: SubType) -> None:
|
||||||
"""Execute the renew of the subscription."""
|
"""Execute the renew of the subscription."""
|
||||||
if not self._api.subscribed:
|
if not self._api.subscribed(sub_type):
|
||||||
_LOGGER.debug(
|
_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",
|
"trying to subscribe from scratch",
|
||||||
self._api.host,
|
self._api.host,
|
||||||
|
sub_type,
|
||||||
)
|
)
|
||||||
await self.subscribe()
|
await self.subscribe()
|
||||||
return
|
return
|
||||||
|
|
||||||
timer = self._api.renewtimer
|
timer = self._api.renewtimer(sub_type)
|
||||||
_LOGGER.debug(
|
_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.host,
|
||||||
self._api.port,
|
self._api.port,
|
||||||
|
sub_type,
|
||||||
timer,
|
timer,
|
||||||
)
|
)
|
||||||
if timer > SUBSCRIPTION_RENEW_THRESHOLD:
|
if timer > SUBSCRIPTION_RENEW_THRESHOLD:
|
||||||
@ -310,25 +313,29 @@ class ReolinkHost:
|
|||||||
|
|
||||||
if timer > 0:
|
if timer > 0:
|
||||||
try:
|
try:
|
||||||
await self._api.renew()
|
await self._api.renew(sub_type)
|
||||||
except SubscriptionError as err:
|
except SubscriptionError as err:
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Host %s: error renewing Reolink subscription, "
|
"Host %s: error renewing Reolink %s subscription, "
|
||||||
"trying to subscribe again: %s",
|
"trying to subscribe again: %s",
|
||||||
self._api.host,
|
self._api.host,
|
||||||
|
sub_type,
|
||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Host %s successfully renewed Reolink subscription", self._api.host
|
"Host %s successfully renewed Reolink %s subscription",
|
||||||
|
self._api.host,
|
||||||
|
sub_type,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
await self._api.subscribe(self._webhook_url)
|
await self._api.subscribe(self._webhook_url, sub_type)
|
||||||
|
|
||||||
_LOGGER.debug(
|
_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,
|
self._api.host,
|
||||||
|
sub_type,
|
||||||
)
|
)
|
||||||
|
|
||||||
def register_webhook(self) -> None:
|
def register_webhook(self) -> None:
|
||||||
|
@ -18,5 +18,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/reolink",
|
"documentation": "https://www.home-assistant.io/integrations/reolink",
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"loggers": ["reolink_aio"],
|
"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
|
renson-endura-delta==1.5.0
|
||||||
|
|
||||||
# homeassistant.components.reolink
|
# homeassistant.components.reolink
|
||||||
reolink-aio==0.6.0
|
reolink-aio==0.7.1
|
||||||
|
|
||||||
# homeassistant.components.idteck_prox
|
# homeassistant.components.idteck_prox
|
||||||
rfk101py==0.0.1
|
rfk101py==0.0.1
|
||||||
|
@ -1655,7 +1655,7 @@ renault-api==0.1.13
|
|||||||
renson-endura-delta==1.5.0
|
renson-endura-delta==1.5.0
|
||||||
|
|
||||||
# homeassistant.components.reolink
|
# homeassistant.components.reolink
|
||||||
reolink-aio==0.6.0
|
reolink-aio==0.7.1
|
||||||
|
|
||||||
# homeassistant.components.rflink
|
# homeassistant.components.rflink
|
||||||
rflink==0.0.65
|
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.user_level = "admin"
|
||||||
host_mock.sw_version_update_required = False
|
host_mock.sw_version_update_required = False
|
||||||
host_mock.timeout = 60
|
host_mock.timeout = 60
|
||||||
host_mock.renewtimer = 600
|
host_mock.renewtimer.return_value = 600
|
||||||
yield host_mock
|
yield host_mock
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user