mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +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)
|
||||
except ConnectionClosed as exc:
|
||||
raise HomeAssistantError(
|
||||
"Connection to Android TV device is closed"
|
||||
translation_domain=DOMAIN, translation_key="connection_closed"
|
||||
) from exc
|
||||
|
||||
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)
|
||||
except ConnectionClosed as exc:
|
||||
raise HomeAssistantError(
|
||||
"Connection to Android TV device is closed"
|
||||
translation_domain=DOMAIN, translation_key="connection_closed"
|
||||
) from exc
|
||||
|
@ -21,7 +21,7 @@ from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
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
|
||||
|
||||
PARALLEL_UPDATES = 0
|
||||
@ -233,5 +233,5 @@ class AndroidTVRemoteMediaPlayerEntity(AndroidTVRemoteBaseEntity, MediaPlayerEnt
|
||||
await asyncio.sleep(delay_secs)
|
||||
except ConnectionClosed as exc:
|
||||
raise HomeAssistantError(
|
||||
"Connection to Android TV device is closed"
|
||||
translation_domain=DOMAIN, translation_key="connection_closed"
|
||||
) 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
|
||||
|
||||
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(
|
||||
"media_player",
|
||||
"media_pause",
|
||||
@ -400,7 +402,9 @@ async def test_media_player_connection_closed(
|
||||
)
|
||||
|
||||
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(
|
||||
"media_player",
|
||||
"play_media",
|
||||
|
@ -183,7 +183,9 @@ async def test_remote_connection_closed(
|
||||
assert mock_config_entry.state is ConfigEntryState.LOADED
|
||||
|
||||
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(
|
||||
"remote",
|
||||
"send_command",
|
||||
@ -197,7 +199,9 @@ async def test_remote_connection_closed(
|
||||
assert mock_api.send_key_command.mock_calls == [call("DPAD_LEFT", "SHORT")]
|
||||
|
||||
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(
|
||||
"remote",
|
||||
"turn_on",
|
||||
|
Loading…
x
Reference in New Issue
Block a user