mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Add translations for connection closed errors in Android TV Remote (#142523)
This commit is contained in:
parent
08304ca5f3
commit
167e766811
@ -73,7 +73,7 @@ class AndroidTVRemoteBaseEntity(Entity):
|
|||||||
self._api.send_key_command(key_code, direction)
|
self._api.send_key_command(key_code, direction)
|
||||||
except ConnectionClosed as exc:
|
except ConnectionClosed as exc:
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
"Connection to Android TV device is closed"
|
translation_domain=DOMAIN, translation_key="connection_closed"
|
||||||
) from exc
|
) from exc
|
||||||
|
|
||||||
def _send_launch_app_command(self, app_link: str) -> None:
|
def _send_launch_app_command(self, app_link: str) -> None:
|
||||||
@ -85,5 +85,5 @@ class AndroidTVRemoteBaseEntity(Entity):
|
|||||||
self._api.send_launch_app_command(app_link)
|
self._api.send_launch_app_command(app_link)
|
||||||
except ConnectionClosed as exc:
|
except ConnectionClosed as exc:
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
"Connection to Android TV device is closed"
|
translation_domain=DOMAIN, translation_key="connection_closed"
|
||||||
) from exc
|
) from exc
|
||||||
|
@ -21,7 +21,7 @@ from homeassistant.exceptions import HomeAssistantError
|
|||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from . import AndroidTVRemoteConfigEntry
|
from . import AndroidTVRemoteConfigEntry
|
||||||
from .const import CONF_APP_ICON, CONF_APP_NAME
|
from .const import CONF_APP_ICON, CONF_APP_NAME, DOMAIN
|
||||||
from .entity import AndroidTVRemoteBaseEntity
|
from .entity import AndroidTVRemoteBaseEntity
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
@ -233,5 +233,5 @@ class AndroidTVRemoteMediaPlayerEntity(AndroidTVRemoteBaseEntity, MediaPlayerEnt
|
|||||||
await asyncio.sleep(delay_secs)
|
await asyncio.sleep(delay_secs)
|
||||||
except ConnectionClosed as exc:
|
except ConnectionClosed as exc:
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
"Connection to Android TV device is closed"
|
translation_domain=DOMAIN, translation_key="connection_closed"
|
||||||
) from exc
|
) from exc
|
||||||
|
@ -54,5 +54,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"exceptions": {
|
||||||
|
"connection_closed": {
|
||||||
|
"message": "Connection to the Android TV device is closed"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,9 @@ async def test_media_player_connection_closed(
|
|||||||
assert mock_config_entry.state is ConfigEntryState.LOADED
|
assert mock_config_entry.state is ConfigEntryState.LOADED
|
||||||
|
|
||||||
mock_api.send_key_command.side_effect = ConnectionClosed()
|
mock_api.send_key_command.side_effect = ConnectionClosed()
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(
|
||||||
|
HomeAssistantError, match="Connection to the Android TV device is closed"
|
||||||
|
):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"media_player",
|
"media_player",
|
||||||
"media_pause",
|
"media_pause",
|
||||||
@ -400,7 +402,9 @@ async def test_media_player_connection_closed(
|
|||||||
)
|
)
|
||||||
|
|
||||||
mock_api.send_launch_app_command.side_effect = ConnectionClosed()
|
mock_api.send_launch_app_command.side_effect = ConnectionClosed()
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(
|
||||||
|
HomeAssistantError, match="Connection to the Android TV device is closed"
|
||||||
|
):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"media_player",
|
"media_player",
|
||||||
"play_media",
|
"play_media",
|
||||||
|
@ -183,7 +183,9 @@ async def test_remote_connection_closed(
|
|||||||
assert mock_config_entry.state is ConfigEntryState.LOADED
|
assert mock_config_entry.state is ConfigEntryState.LOADED
|
||||||
|
|
||||||
mock_api.send_key_command.side_effect = ConnectionClosed()
|
mock_api.send_key_command.side_effect = ConnectionClosed()
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(
|
||||||
|
HomeAssistantError, match="Connection to the Android TV device is closed"
|
||||||
|
):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"remote",
|
"remote",
|
||||||
"send_command",
|
"send_command",
|
||||||
@ -197,7 +199,9 @@ async def test_remote_connection_closed(
|
|||||||
assert mock_api.send_key_command.mock_calls == [call("DPAD_LEFT", "SHORT")]
|
assert mock_api.send_key_command.mock_calls == [call("DPAD_LEFT", "SHORT")]
|
||||||
|
|
||||||
mock_api.send_launch_app_command.side_effect = ConnectionClosed()
|
mock_api.send_launch_app_command.side_effect = ConnectionClosed()
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(
|
||||||
|
HomeAssistantError, match="Connection to the Android TV device is closed"
|
||||||
|
):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"remote",
|
"remote",
|
||||||
"turn_on",
|
"turn_on",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user