Skip to content

Commit

Permalink
Filter SSLErrors by code (#1185)
Browse files Browse the repository at this point in the history
* Reduce log level for exceptions in fetch_paramset_description

* Filter SSLErrors by code
  • Loading branch information
SukramJ authored Sep 6, 2023
1 parent 4b9b9d6 commit cc40ea5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion hahomematic/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion hahomematic/xml_rpc_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)}"
Expand Down

0 comments on commit cc40ea5

Please sign in to comment.