Skip to content

Commit

Permalink
Reolink log fast poll errors once (home-assistant#131203)
Browse files Browse the repository at this point in the history
  • Loading branch information
starkillerOG authored and frenck committed Nov 22, 2024
1 parent 780eaa8 commit 44ad808
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions homeassistant/components/reolink/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def get_aiohttp_session() -> aiohttp.ClientSession:
self._cancel_onvif_check: CALLBACK_TYPE | None = None
self._cancel_long_poll_check: CALLBACK_TYPE | None = None
self._poll_job = HassJob(self._async_poll_all_motion, cancel_on_shutdown=True)
self._fast_poll_error: bool = False
self._long_poll_task: asyncio.Task | None = None
self._lost_subscription: bool = False

Expand Down Expand Up @@ -699,14 +700,20 @@ async def _async_poll_all_motion(self, *_) -> None:
return

try:
await self._api.get_motion_state_all_ch()
if self._api.session_active:
await self._api.get_motion_state_all_ch()
except ReolinkError as err:
_LOGGER.error(
"Reolink error while polling motion state for host %s:%s: %s",
self._api.host,
self._api.port,
err,
)
if not self._fast_poll_error:
_LOGGER.error(
"Reolink error while polling motion state for host %s:%s: %s",
self._api.host,
self._api.port,
err,
)
self._fast_poll_error = True
else:
if self._api.session_active:
self._fast_poll_error = False
finally:
# schedule next poll
if not self._hass.is_stopping:
Expand Down

0 comments on commit 44ad808

Please sign in to comment.