mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Add exception translations for Airly integration (#140864)
* Add exception translations * Improve error strings
This commit is contained in:
parent
07302ea178
commit
3ce9d47d7d
@ -105,7 +105,14 @@ class AirlyDataUpdateCoordinator(DataUpdateCoordinator[dict[str, str | float | i
|
|||||||
try:
|
try:
|
||||||
await measurements.update()
|
await measurements.update()
|
||||||
except (AirlyError, ClientConnectorError) as error:
|
except (AirlyError, ClientConnectorError) as error:
|
||||||
raise UpdateFailed(error) from error
|
raise UpdateFailed(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="update_error",
|
||||||
|
translation_placeholders={
|
||||||
|
"entry": self.config_entry.title,
|
||||||
|
"error": repr(error),
|
||||||
|
},
|
||||||
|
) from error
|
||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Requests remaining: %s/%s",
|
"Requests remaining: %s/%s",
|
||||||
@ -126,7 +133,11 @@ class AirlyDataUpdateCoordinator(DataUpdateCoordinator[dict[str, str | float | i
|
|||||||
standards = measurements.current["standards"]
|
standards = measurements.current["standards"]
|
||||||
|
|
||||||
if index["description"] == NO_AIRLY_SENSORS:
|
if index["description"] == NO_AIRLY_SENSORS:
|
||||||
raise UpdateFailed("Can't retrieve data: no Airly sensors in this area")
|
raise UpdateFailed(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="no_station",
|
||||||
|
translation_placeholders={"entry": self.config_entry.title},
|
||||||
|
)
|
||||||
for value in values:
|
for value in values:
|
||||||
data[value["name"]] = value["value"]
|
data[value["name"]] = value["value"]
|
||||||
for standard in standards:
|
for standard in standards:
|
||||||
|
@ -36,5 +36,13 @@
|
|||||||
"name": "[%key:component::sensor::entity_component::carbon_monoxide::name%]"
|
"name": "[%key:component::sensor::entity_component::carbon_monoxide::name%]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"exceptions": {
|
||||||
|
"update_error": {
|
||||||
|
"message": "An error occurred while retrieving data from the Airly API for {entry}: {error}"
|
||||||
|
},
|
||||||
|
"no_station": {
|
||||||
|
"message": "An error occurred while retrieving data from the Airly API for {entry}: no measuring stations in this area"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user