mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
Use translated errors in Russound RIO (#129820)
This commit is contained in:
parent
9c8d8fef16
commit
0278735dbf
@ -11,7 +11,7 @@ from homeassistant.const import CONF_HOST, CONF_PORT, Platform
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
|
|
||||||
from .const import CONNECT_TIMEOUT, RUSSOUND_RIO_EXCEPTIONS
|
from .const import CONNECT_TIMEOUT, DOMAIN, RUSSOUND_RIO_EXCEPTIONS
|
||||||
|
|
||||||
PLATFORMS = [Platform.MEDIA_PLAYER]
|
PLATFORMS = [Platform.MEDIA_PLAYER]
|
||||||
|
|
||||||
@ -43,7 +43,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: RussoundConfigEntry) ->
|
|||||||
async with asyncio.timeout(CONNECT_TIMEOUT):
|
async with asyncio.timeout(CONNECT_TIMEOUT):
|
||||||
await client.connect()
|
await client.connect()
|
||||||
except RUSSOUND_RIO_EXCEPTIONS as err:
|
except RUSSOUND_RIO_EXCEPTIONS as err:
|
||||||
raise ConfigEntryNotReady(f"Error while connecting to {host}:{port}") from err
|
raise ConfigEntryNotReady(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="entry_cannot_connect",
|
||||||
|
translation_placeholders={
|
||||||
|
"host": host,
|
||||||
|
"port": port,
|
||||||
|
},
|
||||||
|
) from err
|
||||||
entry.runtime_data = client
|
entry.runtime_data = client
|
||||||
|
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
|
@ -26,7 +26,12 @@ def command[_EntityT: RussoundBaseEntity, **_P](
|
|||||||
await func(self, *args, **kwargs)
|
await func(self, *args, **kwargs)
|
||||||
except RUSSOUND_RIO_EXCEPTIONS as exc:
|
except RUSSOUND_RIO_EXCEPTIONS as exc:
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
f"Error executing {func.__name__} on entity {self.entity_id},"
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="command_error",
|
||||||
|
translation_placeholders={
|
||||||
|
"function_name": func.__name__,
|
||||||
|
"entity_id": self.entity_id,
|
||||||
|
},
|
||||||
) from exc
|
) from exc
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
@ -33,5 +33,13 @@
|
|||||||
"title": "[%key:component::russound_rio::issues::deprecated_yaml_import_issue_cannot_connect::title%]",
|
"title": "[%key:component::russound_rio::issues::deprecated_yaml_import_issue_cannot_connect::title%]",
|
||||||
"description": "[%key:component::russound_rio::issues::deprecated_yaml_import_issue_cannot_connect::description%]"
|
"description": "[%key:component::russound_rio::issues::deprecated_yaml_import_issue_cannot_connect::description%]"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"exceptions": {
|
||||||
|
"entry_cannot_connect": {
|
||||||
|
"message": "Error while connecting to {host}:{port}"
|
||||||
|
},
|
||||||
|
"command_error": {
|
||||||
|
"message": "Error executing {function_name} on entity {entity_id}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user