Make exceptions translatable in Tankerkoenig integration (#149611)

This commit is contained in:
Jan-Philipp Benecke 2025-07-29 08:52:42 +02:00 committed by GitHub
parent bf568b22d7
commit 3c1aa9d9de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 28 additions and 5 deletions

View File

@ -131,19 +131,31 @@ class TankerkoenigDataUpdateCoordinator(DataUpdateCoordinator[dict[str, PriceInf
stations,
err,
)
raise ConfigEntryAuthFailed(err) from err
raise ConfigEntryAuthFailed(
translation_domain=DOMAIN,
translation_key="invalid_api_key",
) from err
except TankerkoenigRateLimitError as err:
_LOGGER.warning(
"API rate limit reached, consider to increase polling interval"
)
raise UpdateFailed(err) from err
raise UpdateFailed(
translation_domain=DOMAIN,
translation_key="rate_limit_reached",
) from err
except (TankerkoenigError, TankerkoenigConnectionError) as err:
_LOGGER.debug(
"error occur during update of stations %s %s",
stations,
err,
)
raise UpdateFailed(err) from err
raise UpdateFailed(
translation_domain=DOMAIN,
translation_key="station_update_failed",
translation_placeholders={
"station_ids": ", ".join(stations),
},
) from err
prices.update(data)

View File

@ -6,6 +6,6 @@
"documentation": "https://www.home-assistant.io/integrations/tankerkoenig",
"iot_class": "cloud_polling",
"loggers": ["aiotankerkoenig"],
"quality_scale": "silver",
"quality_scale": "platinum",
"requirements": ["aiotankerkoenig==0.4.2"]
}

View File

@ -62,7 +62,7 @@ rules:
entity-device-class: done
entity-disabled-by-default: done
entity-translations: done
exception-translations: todo
exception-translations: done
icon-translations: done
reconfiguration-flow:
status: exempt

View File

@ -180,5 +180,16 @@
}
}
}
},
"exceptions": {
"rate_limit_reached": {
"message": "You have reached the rate limit for the Tankerkoenig API. Please try to increase the poll interval and reduce the requests."
},
"invalid_api_key": {
"message": "The provided API key is invalid. Please check your API key."
},
"station_update_failed": {
"message": "Failed to update station data for station(s) {station_ids}. Please check your network connection."
}
}
}