diff --git a/changelog.md b/changelog.md index 244001e1..e151cc09 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,7 @@ # Version 2023.8.15 (2023-08-30) - Reduce visibility of local constants +- Convert StrEnum and IntEnum in proxy # Version 2023.8.13 (2023-08-28) diff --git a/hahomematic/xml_rpc_proxy.py b/hahomematic/xml_rpc_proxy.py index 123dfe60..b42059fa 100644 --- a/hahomematic/xml_rpc_proxy.py +++ b/hahomematic/xml_rpc_proxy.py @@ -4,6 +4,7 @@ import asyncio from collections.abc import Callable from concurrent.futures import ThreadPoolExecutor +from enum import IntEnum, StrEnum import errno import logging from ssl import SSLError @@ -85,6 +86,7 @@ async def __async_request(self, *args, **kwargs): # type: ignore[no-untyped-def ] in _VALID_XMLRPC_COMMANDS_ON_NO_CONNECTION or not self._connection_state.has_issue( # noqa: E501 issuer=self ): + args = _cleanup_args(*args) _LOGGER.debug("__ASYNC_REQUEST: %s", args) result = await self._async_add_proxy_executor_job( # pylint: disable=protected-access @@ -129,3 +131,18 @@ def stop(self) -> None: """Stop depending services.""" if self._proxy_executor: self._proxy_executor.shutdown() + + +def _cleanup_args(*args: Any) -> Any: + """Cleanup the type of args.""" + if len(args[1]) == 0: + return args + new_args: list[Any] = [] + for arg in args[1]: + if isinstance(arg, StrEnum): + new_args.append(str(arg)) + elif isinstance(arg, IntEnum): + new_args.append(int(arg)) + else: + new_args.append(arg) + return (args[0], tuple(new_args))