mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
add exception translation to enphase_envoy (#132483)
This commit is contained in:
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
|
# 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.
|
# and update the config entry so we do not mix up devices.
|
||||||
raise ConfigEntryNotReady(
|
raise ConfigEntryNotReady(
|
||||||
f"Unexpected device found at {host}; expected {entry.unique_id}, "
|
translation_domain=DOMAIN,
|
||||||
f"found {envoy.serial_number}"
|
translation_key="unexpected_device",
|
||||||
|
translation_placeholders={
|
||||||
|
"host": host,
|
||||||
|
"expected_serial": str(entry.unique_id),
|
||||||
|
"actual_serial": str(envoy.serial_number),
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
entry.runtime_data = coordinator
|
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
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
import homeassistant.util.dt as dt_util
|
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)
|
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
|
# token likely expired or firmware changed, try to re-authenticate
|
||||||
self._setup_complete = False
|
self._setup_complete = False
|
||||||
continue
|
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:
|
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
|
# if we have a firmware version from previous setup, compare to current one
|
||||||
# when envoy gets new firmware there will be an authentication failure
|
# when envoy gets new firmware there will be an authentication failure
|
||||||
|
@ -108,9 +108,7 @@ rules:
|
|||||||
entity-device-class: done
|
entity-device-class: done
|
||||||
entity-disabled-by-default: done
|
entity-disabled-by-default: done
|
||||||
entity-translations: done
|
entity-translations: done
|
||||||
exception-translations:
|
exception-translations: done
|
||||||
status: todo
|
|
||||||
comment: pending https://github.com/home-assistant/core/pull/132483
|
|
||||||
icon-translations: todo
|
icon-translations: todo
|
||||||
reconfiguration-flow: done
|
reconfiguration-flow: done
|
||||||
repair-issues:
|
repair-issues:
|
||||||
|
@ -371,5 +371,16 @@
|
|||||||
"name": "Grid enabled"
|
"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…
x
Reference in New Issue
Block a user