mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Make exceptions translatable in inexogy integration (#148865)
This commit is contained in:
parent
38e4e18f60
commit
57e4270b7b
@ -11,6 +11,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
from homeassistant.helpers.httpx_client import create_async_httpx_client
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import DiscovergyConfigEntry, DiscovergyUpdateCoordinator
|
||||
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
@ -30,10 +31,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: DiscovergyConfigEntry) -
|
||||
# if no exception is raised everything is fine to go
|
||||
meters = await client.meters()
|
||||
except discovergyError.InvalidLogin as err:
|
||||
raise ConfigEntryAuthFailed("Invalid email or password") from err
|
||||
raise ConfigEntryAuthFailed(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="invalid_auth",
|
||||
) from err
|
||||
except Exception as err:
|
||||
raise ConfigEntryNotReady(
|
||||
"Unexpected error while while getting meters"
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="cannot_connect_meters_setup",
|
||||
) from err
|
||||
|
||||
# Init coordinators for meters
|
||||
|
@ -14,6 +14,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
type DiscovergyConfigEntry = ConfigEntry[list[DiscovergyUpdateCoordinator]]
|
||||
@ -51,7 +53,12 @@ class DiscovergyUpdateCoordinator(DataUpdateCoordinator[Reading]):
|
||||
)
|
||||
except InvalidLogin as err:
|
||||
raise ConfigEntryAuthFailed(
|
||||
"Auth expired while fetching last reading"
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="invalid_auth",
|
||||
) from err
|
||||
except (HTTPError, DiscovergyClientError) as err:
|
||||
raise UpdateFailed(f"Error while fetching last reading: {err}") from err
|
||||
raise UpdateFailed(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="reading_update_failed",
|
||||
translation_placeholders={"meter_id": self.meter.meter_id},
|
||||
) from err
|
||||
|
@ -72,12 +72,16 @@ rules:
|
||||
entity-device-class: done
|
||||
entity-disabled-by-default: done
|
||||
entity-translations: done
|
||||
exception-translations: todo
|
||||
exception-translations: done
|
||||
icon-translations:
|
||||
status: exempt
|
||||
comment: |
|
||||
The integration does not provide any additional icons.
|
||||
reconfiguration-flow: todo
|
||||
reconfiguration-flow:
|
||||
status: exempt
|
||||
comment: |
|
||||
No configuration besides credentials.
|
||||
New credentials will create a new config entry.
|
||||
repair-issues:
|
||||
status: exempt
|
||||
comment: |
|
||||
|
@ -23,6 +23,17 @@
|
||||
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
|
||||
}
|
||||
},
|
||||
"exceptions": {
|
||||
"invalid_auth": {
|
||||
"message": "Authentication failed. Please check your inexogy email and password."
|
||||
},
|
||||
"cannot_connect_meters_setup": {
|
||||
"message": "Failed to connect and retrieve meters from inexogy during setup. Please ensure the service is reachable and try again."
|
||||
},
|
||||
"reading_update_failed": {
|
||||
"message": "Error fetching the latest reading for meter {meter_id} from inexogy. The service might be temporarily unavailable or there's a connection issue. Check logs for more details."
|
||||
}
|
||||
},
|
||||
"system_health": {
|
||||
"info": {
|
||||
"api_endpoint_reachable": "inexogy API endpoint reachable"
|
||||
|
Loading…
x
Reference in New Issue
Block a user