mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Bump reolink-aio to 0.3.2 (#87121)
This commit is contained in:
parent
7643f98d20
commit
d017214d8b
@ -9,14 +9,7 @@ import logging
|
|||||||
|
|
||||||
from aiohttp import ClientConnectorError
|
from aiohttp import ClientConnectorError
|
||||||
import async_timeout
|
import async_timeout
|
||||||
from reolink_aio.exceptions import (
|
from reolink_aio.exceptions import CredentialsInvalidError, ReolinkError
|
||||||
ApiError,
|
|
||||||
InvalidContentTypeError,
|
|
||||||
LoginError,
|
|
||||||
NoDataError,
|
|
||||||
ReolinkError,
|
|
||||||
UnexpectedDataError,
|
|
||||||
)
|
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, Platform
|
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, Platform
|
||||||
@ -48,17 +41,14 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
await host.async_init()
|
await host.async_init()
|
||||||
except UserNotAdmin as err:
|
except (UserNotAdmin, CredentialsInvalidError) as err:
|
||||||
|
await host.stop()
|
||||||
raise ConfigEntryAuthFailed(err) from err
|
raise ConfigEntryAuthFailed(err) from err
|
||||||
except (
|
except (
|
||||||
ClientConnectorError,
|
ClientConnectorError,
|
||||||
asyncio.TimeoutError,
|
asyncio.TimeoutError,
|
||||||
ApiError,
|
|
||||||
InvalidContentTypeError,
|
|
||||||
LoginError,
|
|
||||||
NoDataError,
|
|
||||||
ReolinkException,
|
ReolinkException,
|
||||||
UnexpectedDataError,
|
ReolinkError,
|
||||||
) as err:
|
) as err:
|
||||||
await host.stop()
|
await host.stop()
|
||||||
raise ConfigEntryNotReady(
|
raise ConfigEntryNotReady(
|
||||||
|
@ -9,7 +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.exceptions import ReolinkError
|
from reolink_aio.exceptions import ReolinkError, SubscriptionError
|
||||||
|
|
||||||
from homeassistant.components import webhook
|
from homeassistant.components import webhook
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
|
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")
|
raise ReolinkSetupException("Could not get mac address")
|
||||||
|
|
||||||
if not self._api.is_admin:
|
if not self._api.is_admin:
|
||||||
await self.stop()
|
|
||||||
raise UserNotAdmin(
|
raise UserNotAdmin(
|
||||||
f"User '{self._api.username}' has authorization level "
|
f"User '{self._api.username}' has authorization level "
|
||||||
f"'{self._api.user_level}', only admin users can change camera settings"
|
f"'{self._api.user_level}', only admin users can change camera settings"
|
||||||
@ -182,22 +181,19 @@ class ReolinkHost:
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
if await self._api.subscribe(self._webhook_url):
|
await self._api.subscribe(self._webhook_url)
|
||||||
_LOGGER.debug(
|
|
||||||
"Host %s: subscribed successfully to webhook %s",
|
_LOGGER.debug(
|
||||||
self._api.host,
|
"Host %s: subscribed successfully to webhook %s",
|
||||||
self._webhook_url,
|
self._api.host,
|
||||||
)
|
self._webhook_url,
|
||||||
else:
|
)
|
||||||
raise ReolinkWebhookException(
|
|
||||||
f"Host {self._api.host}: webhook subscription failed"
|
|
||||||
)
|
|
||||||
|
|
||||||
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()
|
||||||
except ReolinkWebhookException as err:
|
except SubscriptionError as err:
|
||||||
if not self._lost_subscription:
|
if not self._lost_subscription:
|
||||||
self._lost_subscription = True
|
self._lost_subscription = True
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
@ -220,25 +216,33 @@ class ReolinkHost:
|
|||||||
return
|
return
|
||||||
|
|
||||||
timer = self._api.renewtimer
|
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:
|
if timer > SUBSCRIPTION_RENEW_THRESHOLD:
|
||||||
return
|
return
|
||||||
|
|
||||||
if timer > 0:
|
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(
|
_LOGGER.debug(
|
||||||
"Host %s successfully renewed Reolink subscription", self._api.host
|
"Host %s successfully renewed Reolink subscription", self._api.host
|
||||||
)
|
)
|
||||||
return
|
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):
|
await self._api.subscribe(self._webhook_url)
|
||||||
raise ReolinkWebhookException(
|
|
||||||
f"Host {self._api.host}: webhook re-subscription failed"
|
|
||||||
)
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Host %s: Reolink re-subscription successful after it was expired",
|
"Host %s: Reolink re-subscription successful after it was expired",
|
||||||
self._api.host,
|
self._api.host,
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"name": "Reolink IP NVR/camera",
|
"name": "Reolink IP NVR/camera",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/reolink",
|
"documentation": "https://www.home-assistant.io/integrations/reolink",
|
||||||
"requirements": ["reolink-aio==0.3.1"],
|
"requirements": ["reolink-aio==0.3.2"],
|
||||||
"dependencies": ["webhook"],
|
"dependencies": ["webhook"],
|
||||||
"codeowners": ["@starkillerOG"],
|
"codeowners": ["@starkillerOG"],
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
|
@ -2227,7 +2227,7 @@ regenmaschine==2022.11.0
|
|||||||
renault-api==0.1.11
|
renault-api==0.1.11
|
||||||
|
|
||||||
# homeassistant.components.reolink
|
# homeassistant.components.reolink
|
||||||
reolink-aio==0.3.1
|
reolink-aio==0.3.2
|
||||||
|
|
||||||
# homeassistant.components.python_script
|
# homeassistant.components.python_script
|
||||||
restrictedpython==6.0
|
restrictedpython==6.0
|
||||||
|
@ -1572,7 +1572,7 @@ regenmaschine==2022.11.0
|
|||||||
renault-api==0.1.11
|
renault-api==0.1.11
|
||||||
|
|
||||||
# homeassistant.components.reolink
|
# homeassistant.components.reolink
|
||||||
reolink-aio==0.3.1
|
reolink-aio==0.3.2
|
||||||
|
|
||||||
# homeassistant.components.python_script
|
# homeassistant.components.python_script
|
||||||
restrictedpython==6.0
|
restrictedpython==6.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user