diff --git a/homeassistant/components/websocket_api/commands.py b/homeassistant/components/websocket_api/commands.py index cef9e7bb706..aa4daa1a7bf 100644 --- a/homeassistant/components/websocket_api/commands.py +++ b/homeassistant/components/websocket_api/commands.py @@ -240,7 +240,9 @@ async def handle_call_service( except vol.Invalid as err: connection.send_error(msg["id"], const.ERR_INVALID_FORMAT, str(err)) except HomeAssistantError as err: - connection.logger.exception(err) + connection.logger.error( + "Error calling service %s.%s: %s", msg["domain"], msg["service"], err + ) connection.send_error(msg["id"], const.ERR_HOME_ASSISTANT_ERROR, str(err)) except Exception as err: # pylint: disable=broad-except connection.logger.exception(err) diff --git a/tests/components/websocket_api/test_commands.py b/tests/components/websocket_api/test_commands.py index f200c44acca..a7bef4eba3c 100644 --- a/tests/components/websocket_api/test_commands.py +++ b/tests/components/websocket_api/test_commands.py @@ -444,7 +444,9 @@ async def test_call_service_schema_validation_error( async def test_call_service_error( - hass: HomeAssistant, websocket_client: MockHAClientWebSocket + hass: HomeAssistant, + websocket_client: MockHAClientWebSocket, + caplog: pytest.LogCaptureFixture, ) -> None: """Test call service command with error.""" @@ -474,6 +476,7 @@ async def test_call_service_error( assert msg["success"] is False assert msg["error"]["code"] == "home_assistant_error" assert msg["error"]["message"] == "error_message" + assert "Error calling service domain_test.ha_error: error_message" in caplog.text await websocket_client.send_json( {