Defer module updates for less volatile modules (pick 1052) (#1056)

Pick commit 7fd5c213e6 from 1052

Addresses stability issues on older hw device versions

 - Handles module timeout errors better by querying modules individually on errors and disabling problematic modules like Firmware that go out to the internet to get updates.
- Addresses an issue with the Led module on P100 hardware version 1.0 which appears to have a memory leak and will cause the device to crash after approximately 500 calls.
- Delays updates of modules that do not have regular changes like LightPreset and LightEffect and enables them to be updated on the next update cycle only if required values have changed.
This commit is contained in:
Steven B
2024-07-11 16:54:15 +01:00
committed by GitHub
parent 407cedf781
commit 5dac092227
16 changed files with 364 additions and 56 deletions

View File

@@ -144,7 +144,9 @@ class AesTransport(BaseTransport):
try:
error_code = SmartErrorCode.from_int(error_code_raw)
except ValueError:
_LOGGER.warning("Received unknown error code: %s", error_code_raw)
_LOGGER.warning(
"Device %s received unknown error code: %s", self._host, error_code_raw
)
error_code = SmartErrorCode.INTERNAL_UNKNOWN_ERROR
if error_code is SmartErrorCode.SUCCESS:
return
@@ -214,10 +216,18 @@ class AesTransport(BaseTransport):
"""Login to the device."""
try:
await self.try_login(self._login_params)
_LOGGER.debug(
"%s: logged in with provided credentials",
self._host,
)
except AuthenticationError as aex:
try:
if aex.error_code is not SmartErrorCode.LOGIN_ERROR:
raise aex
_LOGGER.debug(
"%s: trying login with default TAPO credentials",
self._host,
)
if self._default_credentials is None:
self._default_credentials = get_default_credentials(
DEFAULT_CREDENTIALS["TAPO"]
@@ -225,7 +235,7 @@ class AesTransport(BaseTransport):
await self.perform_handshake()
await self.try_login(self._get_login_params(self._default_credentials))
_LOGGER.debug(
"%s: logged in with default credentials",
"%s: logged in with default TAPO credentials",
self._host,
)
except (AuthenticationError, _ConnectionError, TimeoutError):