add exception translation to enphase_envoy (#132483)
parent
920de90603
commit
fc622e398f
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue