1
0
mirror of https://github.com/home-assistant/core.git synced 2026-07-13 01:27:57 +01:00

Add translation support for connection errors in Saunum integration (#175675)

This commit is contained in:
mettolen
2026-07-06 13:07:50 +03:00
committed by GitHub
parent e93b9e7b64
commit fd3318bb0d
3 changed files with 12 additions and 2 deletions
+5 -2
View File
@@ -39,8 +39,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: LeilSaunaConfigEntry) ->
try:
client = await SaunumClient.create(host)
except (SaunumConnectionError, SaunumTimeoutError) as exc:
# pylint: disable-next=home-assistant-exception-not-translated
raise ConfigEntryNotReady(f"Error connecting to {host}: {exc}") from exc
raise ConfigEntryNotReady(
translation_domain=DOMAIN,
translation_key="cannot_connect",
translation_placeholders={"host": host},
) from exc
entry.async_on_unload(client.async_close)
@@ -87,6 +87,9 @@
}
},
"exceptions": {
"cannot_connect": {
"message": "Error connecting to {host}"
},
"communication_error": {
"message": "Communication error with sauna control unit"
},
+4
View File
@@ -44,6 +44,10 @@ async def test_async_setup_entry_connection_failed(
assert not await hass.config_entries.async_setup(mock_config_entry.entry_id)
assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY
assert mock_config_entry.error_reason_translation_key == "cannot_connect"
assert mock_config_entry.error_reason_translation_placeholders == {
"host": mock_config_entry.data["host"],
}
@pytest.mark.usefixtures("init_integration")