diff --git a/aioshelly/json.py b/aioshelly/json.py index 3b8b815a..96f79e28 100644 --- a/aioshelly/json.py +++ b/aioshelly/json.py @@ -22,3 +22,12 @@ def json_dumps(data: Any) -> str: option=orjson.OPT_NON_STR_KEYS, default=json_encoder_default, ).decode("utf-8") + + +def json_bytes(data: Any) -> bytes: + """Dump json bytes.""" + return orjson.dumps( + data, + option=orjson.OPT_NON_STR_KEYS, + default=json_encoder_default, + ) diff --git a/aioshelly/rpc_device/wsrpc.py b/aioshelly/rpc_device/wsrpc.py index 18f85490..f3e24ba3 100644 --- a/aioshelly/rpc_device/wsrpc.py +++ b/aioshelly/rpc_device/wsrpc.py @@ -48,7 +48,7 @@ InvalidMessage, RpcCallError, ) -from ..json import json_dumps, json_loads +from ..json import json_bytes, json_loads _LOGGER = logging.getLogger(__name__) @@ -531,7 +531,7 @@ async def _send_json(self, data: dict[str, Any]) -> None: if TYPE_CHECKING: assert self._client - await self._client.send_str(json_dumps(data)) + await self._client.send_frame(json_bytes(data), WSMsgType.TEXT) class WsServer(WsBase): diff --git a/requirements.txt b/requirements.txt index 481c6d22..bb90c31b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ bluetooth-data-tools>=1.19.0 -aiohttp +aiohttp>=3.11.1 habluetooth>=2.1.0 yarl orjson>=3.8.1