Skip to content

Commit

Permalink
Bump reolink_aio to 0.7.6 + Timeout (home-assistant#97464)
Browse files Browse the repository at this point in the history
  • Loading branch information
starkillerOG authored Jul 31, 2023
1 parent 094f2cb commit 121fc77
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
11 changes: 5 additions & 6 deletions homeassistant/components/reolink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Literal

import async_timeout
from reolink_aio.api import RETRY_ATTEMPTS
from reolink_aio.exceptions import CredentialsInvalidError, ReolinkError

from homeassistant.config_entries import ConfigEntry
Expand Down Expand Up @@ -77,23 +78,21 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b

async def async_device_config_update() -> None:
"""Update the host state cache and renew the ONVIF-subscription."""
async with async_timeout.timeout(host.api.timeout):
async with async_timeout.timeout(host.api.timeout * (RETRY_ATTEMPTS + 2)):
try:
await host.update_states()
except ReolinkError as err:
raise UpdateFailed(
f"Error updating Reolink {host.api.nvr_name}"
) from err
raise UpdateFailed(str(err)) from err

async with async_timeout.timeout(host.api.timeout):
async with async_timeout.timeout(host.api.timeout * (RETRY_ATTEMPTS + 2)):
await host.renew()

async def async_check_firmware_update() -> str | Literal[False]:
"""Check for firmware updates."""
if not host.api.supported(None, "update"):
return False

async with async_timeout.timeout(host.api.timeout):
async with async_timeout.timeout(host.api.timeout * (RETRY_ATTEMPTS + 2)):
try:
return await host.api.check_new_firmware()
except (ReolinkError, asyncio.exceptions.CancelledError) as err:
Expand Down
6 changes: 4 additions & 2 deletions homeassistant/components/reolink/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .const import CONF_PROTOCOL, CONF_USE_HTTPS, DOMAIN
from .exceptions import ReolinkSetupException, ReolinkWebhookException, UserNotAdmin

DEFAULT_TIMEOUT = 60
DEFAULT_TIMEOUT = 30
FIRST_ONVIF_TIMEOUT = 10
FIRST_ONVIF_LONG_POLL_TIMEOUT = 90
SUBSCRIPTION_RENEW_THRESHOLD = 300
Expand Down Expand Up @@ -470,7 +470,9 @@ async def _async_long_polling(self, *_) -> None:
await asyncio.sleep(LONG_POLL_ERROR_COOLDOWN)
continue
except Exception as ex:
_LOGGER.exception("Error while requesting ONVIF pull point: %s", ex)
_LOGGER.exception(
"Unexpected exception while requesting ONVIF pull point: %s", ex
)
await self._api.unsubscribe(sub_type=SubType.long_poll)
raise ex

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/reolink/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"documentation": "https://www.home-assistant.io/integrations/reolink",
"iot_class": "local_push",
"loggers": ["reolink_aio"],
"requirements": ["reolink-aio==0.7.5"]
"requirements": ["reolink-aio==0.7.6"]
}
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2281,7 +2281,7 @@ renault-api==0.1.13
renson-endura-delta==1.5.0

# homeassistant.components.reolink
reolink-aio==0.7.5
reolink-aio==0.7.6

# homeassistant.components.idteck_prox
rfk101py==0.0.1
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,7 @@ renault-api==0.1.13
renson-endura-delta==1.5.0

# homeassistant.components.reolink
reolink-aio==0.7.5
reolink-aio==0.7.6

# homeassistant.components.rflink
rflink==0.0.65
Expand Down

0 comments on commit 121fc77

Please sign in to comment.