From 926c337a9f6676b9bd2600850c15bb9a8eba4b8a Mon Sep 17 00:00:00 2001 From: starkillerOG Date: Thu, 16 Jan 2025 21:27:36 +0100 Subject: [PATCH] logout before eabling privacy mode again --- reolink_aio/api.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/reolink_aio/api.py b/reolink_aio/api.py index 652f468..53c52f5 100644 --- a/reolink_aio/api.py +++ b/reolink_aio/api.py @@ -2462,6 +2462,10 @@ def check_command_exists(cmd: str) -> int: await self.get_rtsp_stream_source(channel, "main", check) if privacy_mode_enabled: + try: + await self.logout() + except ReolinkError: + pass await self.baichuan.set_privacy_mode(0, True) self._startup = False @@ -2755,8 +2759,10 @@ async def check_new_firmware(self, ch_list: list[None | int] | None = None) -> d raise InvalidContentTypeError(f"Check current firmware: {str(err)}") from err except NoDataError as err: raise NoDataError(f"Host: {self._host}:{self._port}: error obtaining current firmware response") from err - - self.map_channels_json_response(json_data, channels) + except LoginPrivacyModeError: + _LOGGER.debug("Host: %s: could not check current firmware because privacy mode is enabled", self._host) + else: + self.map_channels_json_response(json_data, channels) # check for host update using API if None in ch_list and self.supported(None, "update"): @@ -2766,7 +2772,7 @@ async def check_new_firmware(self, ch_list: list[None | int] | None = None) -> d async with asyncio.timeout(15): json_data = await self.send(body, expected_response_type="json") new_firmware = json_data[0].get("value", {}).get("newFirmware", 0) - except InvalidContentTypeError as err: + except (InvalidContentTypeError, LoginPrivacyModeError) as err: _LOGGER.debug("CheckFirmware: %s", str(err)) except NoDataError: _LOGGER.debug("Host: %s: error obtaining CheckFirmware response", self._host)