Bump reolink-aio to 0.3.2 (#87121)

pull/87221/head
starkillerOG 2023-02-02 11:24:06 +01:00 committed by Paulus Schoutsen
parent b24d0a86ee
commit 264b6d4f77
5 changed files with 34 additions and 40 deletions

View File

@ -9,14 +9,7 @@ import logging
from aiohttp import ClientConnectorError
import async_timeout
from reolink_aio.exceptions import (
ApiError,
InvalidContentTypeError,
LoginError,
NoDataError,
ReolinkError,
UnexpectedDataError,
)
from reolink_aio.exceptions import CredentialsInvalidError, ReolinkError
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, Platform
@ -48,17 +41,14 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
try:
await host.async_init()
except UserNotAdmin as err:
except (UserNotAdmin, CredentialsInvalidError) as err:
await host.stop()
raise ConfigEntryAuthFailed(err) from err
except (
ClientConnectorError,
asyncio.TimeoutError,
ApiError,
InvalidContentTypeError,
LoginError,
NoDataError,
ReolinkException,
UnexpectedDataError,
ReolinkError,
) as err:
await host.stop()
raise ConfigEntryNotReady(

View File

@ -9,7 +9,7 @@ from typing import Any
import aiohttp
from aiohttp.web import Request
from reolink_aio.api import Host
from reolink_aio.exceptions import ReolinkError
from reolink_aio.exceptions import ReolinkError, SubscriptionError
from homeassistant.components import webhook
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
@ -76,7 +76,6 @@ class ReolinkHost:
raise ReolinkSetupException("Could not get mac address")
if not self._api.is_admin:
await self.stop()
raise UserNotAdmin(
f"User '{self._api.username}' has authorization level "
f"'{self._api.user_level}', only admin users can change camera settings"
@ -182,22 +181,19 @@ class ReolinkHost:
)
return
if await self._api.subscribe(self._webhook_url):
_LOGGER.debug(
"Host %s: subscribed successfully to webhook %s",
self._api.host,
self._webhook_url,
)
else:
raise ReolinkWebhookException(
f"Host {self._api.host}: webhook subscription failed"
)
await self._api.subscribe(self._webhook_url)
_LOGGER.debug(
"Host %s: subscribed successfully to webhook %s",
self._api.host,
self._webhook_url,
)
async def renew(self) -> None:
"""Renew the subscription of motion events (lease time is 15 minutes)."""
try:
await self._renew()
except ReolinkWebhookException as err:
except SubscriptionError as err:
if not self._lost_subscription:
self._lost_subscription = True
_LOGGER.error(
@ -220,25 +216,33 @@ class ReolinkHost:
return
timer = self._api.renewtimer
_LOGGER.debug(
"Host %s:%s should renew subscription in: %i seconds",
self._api.host,
self._api.port,
timer,
)
if timer > SUBSCRIPTION_RENEW_THRESHOLD:
return
if timer > 0:
if await self._api.renew():
try:
await self._api.renew()
except SubscriptionError as err:
_LOGGER.debug(
"Host %s: error renewing Reolink subscription, "
"trying to subscribe again: %s",
self._api.host,
err,
)
else:
_LOGGER.debug(
"Host %s successfully renewed Reolink subscription", self._api.host
)
return
_LOGGER.debug(
"Host %s: error renewing Reolink subscription, "
"trying to subscribe again",
self._api.host,
)
if not await self._api.subscribe(self._webhook_url):
raise ReolinkWebhookException(
f"Host {self._api.host}: webhook re-subscription failed"
)
await self._api.subscribe(self._webhook_url)
_LOGGER.debug(
"Host %s: Reolink re-subscription successful after it was expired",
self._api.host,

View File

@ -3,7 +3,7 @@
"name": "Reolink IP NVR/camera",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/reolink",
"requirements": ["reolink-aio==0.3.1"],
"requirements": ["reolink-aio==0.3.2"],
"dependencies": ["webhook"],
"codeowners": ["@starkillerOG"],
"iot_class": "local_polling",

View File

@ -2227,7 +2227,7 @@ regenmaschine==2022.11.0
renault-api==0.1.11
# homeassistant.components.reolink
reolink-aio==0.3.1
reolink-aio==0.3.2
# homeassistant.components.python_script
restrictedpython==6.0

View File

@ -1572,7 +1572,7 @@ regenmaschine==2022.11.0
renault-api==0.1.11
# homeassistant.components.reolink
reolink-aio==0.3.1
reolink-aio==0.3.2
# homeassistant.components.python_script
restrictedpython==6.0