diff --git a/homeassistant/components/cloud/__init__.py b/homeassistant/components/cloud/__init__.py index 97210b4197c..2c7c6f80d49 100644 --- a/homeassistant/components/cloud/__init__.py +++ b/homeassistant/components/cloud/__init__.py @@ -61,7 +61,6 @@ from .const import ( CONF_RELAYER_SERVER, CONF_REMOTESTATE_SERVER, CONF_SERVICEHANDLERS_SERVER, - CONF_THINGTALK_SERVER, CONF_USER_POOL_ID, DATA_CLOUD, DATA_CLOUD_LOG_HANDLER, @@ -134,7 +133,6 @@ CONFIG_SCHEMA = vol.Schema( vol.Optional(CONF_CLOUDHOOK_SERVER): str, vol.Optional(CONF_RELAYER_SERVER): str, vol.Optional(CONF_REMOTESTATE_SERVER): str, - vol.Optional(CONF_THINGTALK_SERVER): str, vol.Optional(CONF_SERVICEHANDLERS_SERVER): str, } ) diff --git a/homeassistant/components/cloud/const.py b/homeassistant/components/cloud/const.py index 9a977d2a5b9..1f154832ef9 100644 --- a/homeassistant/components/cloud/const.py +++ b/homeassistant/components/cloud/const.py @@ -81,7 +81,6 @@ CONF_ACME_SERVER = "acme_server" CONF_CLOUDHOOK_SERVER = "cloudhook_server" CONF_RELAYER_SERVER = "relayer_server" CONF_REMOTESTATE_SERVER = "remotestate_server" -CONF_THINGTALK_SERVER = "thingtalk_server" CONF_SERVICEHANDLERS_SERVER = "servicehandlers_server" MODE_DEV = "development" diff --git a/homeassistant/components/cloud/http_api.py b/homeassistant/components/cloud/http_api.py index 7c7cb925e4f..998f3fcd5bc 100644 --- a/homeassistant/components/cloud/http_api.py +++ b/homeassistant/components/cloud/http_api.py @@ -16,7 +16,7 @@ from typing import Any, Concatenate, cast import aiohttp from aiohttp import web import attr -from hass_nabucasa import AlreadyConnectedError, Cloud, auth, thingtalk +from hass_nabucasa import AlreadyConnectedError, Cloud, auth from hass_nabucasa.const import STATE_DISCONNECTED from hass_nabucasa.voice_data import TTS_VOICES import voluptuous as vol @@ -104,7 +104,6 @@ def async_setup(hass: HomeAssistant) -> None: websocket_api.async_register_command(hass, alexa_list) websocket_api.async_register_command(hass, alexa_sync) - websocket_api.async_register_command(hass, thingtalk_convert) websocket_api.async_register_command(hass, tts_info) hass.http.register_view(GoogleActionsSyncView) @@ -998,25 +997,6 @@ async def alexa_sync( ) -@websocket_api.websocket_command({"type": "cloud/thingtalk/convert", "query": str}) -@websocket_api.async_response -async def thingtalk_convert( - hass: HomeAssistant, - connection: websocket_api.ActiveConnection, - msg: dict[str, Any], -) -> None: - """Convert a query.""" - cloud = hass.data[DATA_CLOUD] - - async with asyncio.timeout(10): - try: - connection.send_result( - msg["id"], await thingtalk.async_convert(cloud, msg["query"]) - ) - except thingtalk.ThingTalkConversionError as err: - connection.send_error(msg["id"], websocket_api.ERR_UNKNOWN_ERROR, str(err)) - - @websocket_api.websocket_command({"type": "cloud/tts/info"}) def tts_info( hass: HomeAssistant, diff --git a/tests/components/cloud/test_http_api.py b/tests/components/cloud/test_http_api.py index 2722445445e..b5cce286ba2 100644 --- a/tests/components/cloud/test_http_api.py +++ b/tests/components/cloud/test_http_api.py @@ -10,7 +10,7 @@ from unittest.mock import AsyncMock, MagicMock, Mock, PropertyMock, patch import aiohttp from freezegun.api import FrozenDateTimeFactory -from hass_nabucasa import AlreadyConnectedError, thingtalk +from hass_nabucasa import AlreadyConnectedError from hass_nabucasa.auth import ( InvalidTotpCode, MFARequired, @@ -1745,70 +1745,6 @@ async def test_enable_alexa_state_report_fail( assert response["error"]["code"] == "alexa_relink" -async def test_thingtalk_convert( - hass: HomeAssistant, - hass_ws_client: WebSocketGenerator, - setup_cloud: None, -) -> None: - """Test that we can convert a query.""" - client = await hass_ws_client(hass) - - with patch( - "homeassistant.components.cloud.http_api.thingtalk.async_convert", - return_value={"hello": "world"}, - ): - await client.send_json( - {"id": 5, "type": "cloud/thingtalk/convert", "query": "some-data"} - ) - response = await client.receive_json() - - assert response["success"] - assert response["result"] == {"hello": "world"} - - -async def test_thingtalk_convert_timeout( - hass: HomeAssistant, - hass_ws_client: WebSocketGenerator, - setup_cloud: None, -) -> None: - """Test that we can convert a query.""" - client = await hass_ws_client(hass) - - with patch( - "homeassistant.components.cloud.http_api.thingtalk.async_convert", - side_effect=TimeoutError, - ): - await client.send_json( - {"id": 5, "type": "cloud/thingtalk/convert", "query": "some-data"} - ) - response = await client.receive_json() - - assert not response["success"] - assert response["error"]["code"] == "timeout" - - -async def test_thingtalk_convert_internal( - hass: HomeAssistant, - hass_ws_client: WebSocketGenerator, - setup_cloud: None, -) -> None: - """Test that we can convert a query.""" - client = await hass_ws_client(hass) - - with patch( - "homeassistant.components.cloud.http_api.thingtalk.async_convert", - side_effect=thingtalk.ThingTalkConversionError("Did not understand"), - ): - await client.send_json( - {"id": 5, "type": "cloud/thingtalk/convert", "query": "some-data"} - ) - response = await client.receive_json() - - assert not response["success"] - assert response["error"]["code"] == "unknown_error" - assert response["error"]["message"] == "Did not understand" - - async def test_tts_info( hass: HomeAssistant, hass_ws_client: WebSocketGenerator,