diff --git a/homeassistant/components/websocket_api/commands.py b/homeassistant/components/websocket_api/commands.py index 32f59bd0c5f323a841cc50a2ff0e75d3f341530c..c088acc6e00e4481f117f1039b01cf5950c12c27 100644 --- a/homeassistant/components/websocket_api/commands.py +++ b/homeassistant/components/websocket_api/commands.py @@ -45,7 +45,7 @@ from homeassistant.helpers.json import ( JSON_DUMP, ExtendedJSONEncoder, find_paths_unserializable_data, - json_dumps, + json_bytes, ) from homeassistant.helpers.service import async_get_all_descriptions from homeassistant.helpers.typing import EventType @@ -460,7 +460,7 @@ def _send_handle_entities_init_response( ) -async def _async_get_all_descriptions_json(hass: HomeAssistant) -> str: +async def _async_get_all_descriptions_json(hass: HomeAssistant) -> bytes: """Return JSON of descriptions (i.e. user documentation) for all service calls.""" descriptions = await async_get_all_descriptions(hass) if ALL_SERVICE_DESCRIPTIONS_JSON_CACHE in hass.data: @@ -469,8 +469,8 @@ async def _async_get_all_descriptions_json(hass: HomeAssistant) -> str: ] # If the descriptions are the same, return the cached JSON payload if cached_descriptions is descriptions: - return cast(str, cached_json_payload) - json_payload = json_dumps(descriptions) + return cast(bytes, cached_json_payload) + json_payload = json_bytes(descriptions) hass.data[ALL_SERVICE_DESCRIPTIONS_JSON_CACHE] = (descriptions, json_payload) return json_payload @@ -482,7 +482,7 @@ async def handle_get_services( ) -> None: """Handle get services command.""" payload = await _async_get_all_descriptions_json(hass) - connection.send_message(construct_result_message(msg["id"], payload.encode())) + connection.send_message(construct_result_message(msg["id"], payload)) @callback