diff --git a/homeassistant/components/enphase_envoy/__init__.py b/homeassistant/components/enphase_envoy/__init__.py index db36cab1288..f4fe4aff2cb 100644 --- a/homeassistant/components/enphase_envoy/__init__.py +++ b/homeassistant/components/enphase_envoy/__init__.py @@ -51,8 +51,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: EnphaseConfigEntry) -> b # wait for the next discovery to find the device at its new address # and update the config entry so we do not mix up devices. raise ConfigEntryNotReady( - f"Unexpected device found at {host}; expected {entry.unique_id}, " - f"found {envoy.serial_number}" + translation_domain=DOMAIN, + translation_key="unexpected_device", + translation_placeholders={ + "host": host, + "expected_serial": str(entry.unique_id), + "actual_serial": str(envoy.serial_number), + }, ) entry.runtime_data = coordinator diff --git a/homeassistant/components/enphase_envoy/coordinator.py b/homeassistant/components/enphase_envoy/coordinator.py index 00bc7666f78..386661402de 100644 --- a/homeassistant/components/enphase_envoy/coordinator.py +++ b/homeassistant/components/enphase_envoy/coordinator.py @@ -18,7 +18,7 @@ from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed import homeassistant.util.dt as dt_util -from .const import INVALID_AUTH_ERRORS +from .const import DOMAIN, INVALID_AUTH_ERRORS SCAN_INTERVAL = timedelta(seconds=60) @@ -158,9 +158,23 @@ class EnphaseUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]): # token likely expired or firmware changed, try to re-authenticate self._setup_complete = False continue - raise ConfigEntryAuthFailed from err + raise ConfigEntryAuthFailed( + translation_domain=DOMAIN, + translation_key="authentication_error", + translation_placeholders={ + "host": envoy.host, + "args": err.args[0], + }, + ) from err except EnvoyError as err: - raise UpdateFailed(f"Error communicating with API: {err}") from err + raise UpdateFailed( + translation_domain=DOMAIN, + translation_key="envoy_error", + translation_placeholders={ + "host": envoy.host, + "args": err.args[0], + }, + ) from err # if we have a firmware version from previous setup, compare to current one # when envoy gets new firmware there will be an authentication failure diff --git a/homeassistant/components/enphase_envoy/quality_scale.yaml b/homeassistant/components/enphase_envoy/quality_scale.yaml index c4077b8df67..4b83c2886f7 100644 --- a/homeassistant/components/enphase_envoy/quality_scale.yaml +++ b/homeassistant/components/enphase_envoy/quality_scale.yaml @@ -108,9 +108,7 @@ rules: entity-device-class: done entity-disabled-by-default: done entity-translations: done - exception-translations: - status: todo - comment: pending https://github.com/home-assistant/core/pull/132483 + exception-translations: done icon-translations: todo reconfiguration-flow: done repair-issues: diff --git a/homeassistant/components/enphase_envoy/strings.json b/homeassistant/components/enphase_envoy/strings.json index a338deb9638..a78d0bc032a 100644 --- a/homeassistant/components/enphase_envoy/strings.json +++ b/homeassistant/components/enphase_envoy/strings.json @@ -371,5 +371,16 @@ "name": "Grid enabled" } } + }, + "exceptions": { + "unexpected_device": { + "message": "Unexpected Envoy serial-number found at {host}; expected {expected_serial}, found {actual_serial}" + }, + "authentication_error": { + "message": "Envoy authentication failure on {host}: {args}" + }, + "envoy_error": { + "message": "Error communicating with Envoy API on {host}: {args}" + } } }