From cc40ea573e895e2843ff6e7e827f14379bc94b5b Mon Sep 17 00:00:00 2001 From: SukramJ Date: Wed, 6 Sep 2023 17:39:52 +0200 Subject: [PATCH] Filter SSLErrors by code (#1185) * Reduce log level for exceptions in fetch_paramset_description * Filter SSLErrors by code --- changelog.md | 2 ++ hahomematic/client.py | 2 +- hahomematic/xml_rpc_proxy.py | 9 ++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index c60876f6..a8aae174 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,8 @@ # Version 2023.9.1 (2023-09-06) - Re add channel 7 for HmIPW-WRC6 +- Reduce log level for exceptions in fetch_paramset_description +- Filter SSLErrors by code # Version 2023.9.0 (2023-09-03) diff --git a/hahomematic/client.py b/hahomematic/client.py index 3917675c..e7f39187 100644 --- a/hahomematic/client.py +++ b/hahomematic/client.py @@ -510,7 +510,7 @@ async def fetch_paramset_description( paramset_description=parameter_data, ) except BaseHomematicException as hhe: - _LOGGER.warning( + _LOGGER.debug( "FETCH_PARAMSET_DESCRIPTION failed: " "%s [%s] Unable to get paramset %s for channel_address %s", hhe.name, diff --git a/hahomematic/xml_rpc_proxy.py b/hahomematic/xml_rpc_proxy.py index ec3e890c..7d123ee7 100644 --- a/hahomematic/xml_rpc_proxy.py +++ b/hahomematic/xml_rpc_proxy.py @@ -30,6 +30,10 @@ "ping", ) +_SSL_ERROR_CODES: Final[dict[int, str]] = { + errno.ENOEXEC: "EOF occurred in violation of protocol", +} + _NO_CONNECTION_ERROR_CODES: Final[dict[int, str]] = { errno.ECONNREFUSED: "Connection refused", errno.ENETUNREACH: "Network is unreachable", @@ -99,7 +103,10 @@ async def __async_request(self, *args, **kwargs): # type: ignore[no-untyped-def raise NoConnection(f"No connection to {self.interface_id}") except SSLError as sslerr: message = f"SSLError on {self.interface_id}: {reduce_args(args=sslerr.args)}" - _LOGGER.error(message) + if sslerr.args[0] in _SSL_ERROR_CODES: + _LOGGER.debug(message) + else: + _LOGGER.error(message) raise NoConnection(message) from sslerr except OSError as ose: message = f"OSError on {self.interface_id}: {reduce_args(args=ose.args)}"