mirror of
https://github.com/home-assistant/core.git
synced 2026-09-10 23:51:49 +01:00
Translate the update install and skip errors (#180615)
This commit is contained in:
@@ -139,7 +139,11 @@ async def async_install(entity: UpdateEntity, service_call: ServiceCall) -> None
|
||||
entity.installed_version == entity.latest_version
|
||||
or entity.latest_version is None
|
||||
):
|
||||
raise HomeAssistantError(f"No update available for {entity.entity_id}")
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="no_update_available",
|
||||
translation_placeholders={"entity_id": entity.entity_id},
|
||||
)
|
||||
|
||||
# If version is specified, but not supported by the entity.
|
||||
if (
|
||||
@@ -147,19 +151,27 @@ async def async_install(entity: UpdateEntity, service_call: ServiceCall) -> None
|
||||
and UpdateEntityFeature.SPECIFIC_VERSION not in entity.supported_features
|
||||
):
|
||||
raise HomeAssistantError(
|
||||
f"Installing a specific version is not supported for {entity.entity_id}"
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="specific_version_not_supported",
|
||||
translation_placeholders={"entity_id": entity.entity_id},
|
||||
)
|
||||
|
||||
# If backup is requested, but not supported by the entity.
|
||||
if (
|
||||
backup := service_call.data[ATTR_BACKUP]
|
||||
) and UpdateEntityFeature.BACKUP not in entity.supported_features:
|
||||
raise HomeAssistantError(f"Backup is not supported for {entity.entity_id}")
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="backup_not_supported",
|
||||
translation_placeholders={"entity_id": entity.entity_id},
|
||||
)
|
||||
|
||||
# Update is already in progress.
|
||||
if entity.in_progress is not False:
|
||||
raise HomeAssistantError(
|
||||
f"Update installation already in progress for {entity.entity_id}"
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="update_in_progress",
|
||||
translation_placeholders={"entity_id": entity.entity_id},
|
||||
)
|
||||
|
||||
await entity.async_install_with_progress(version, backup)
|
||||
@@ -169,7 +181,9 @@ async def async_skip(entity: UpdateEntity, service_call: ServiceCall) -> None:
|
||||
"""Service call wrapper to validate the call."""
|
||||
if entity.auto_update:
|
||||
raise HomeAssistantError(
|
||||
f"Skipping update is not supported for {entity.entity_id}"
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="skip_not_supported",
|
||||
translation_placeholders={"entity_id": entity.entity_id},
|
||||
)
|
||||
await entity.async_skip()
|
||||
|
||||
@@ -178,7 +192,9 @@ async def async_clear_skipped(entity: UpdateEntity, service_call: ServiceCall) -
|
||||
"""Service call wrapper to validate the call."""
|
||||
if entity.auto_update:
|
||||
raise HomeAssistantError(
|
||||
f"Clearing skipped update is not supported for {entity.entity_id}"
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="clear_skipped_not_supported",
|
||||
translation_placeholders={"entity_id": entity.entity_id},
|
||||
)
|
||||
await entity.async_clear_skipped()
|
||||
|
||||
@@ -362,9 +378,17 @@ class UpdateEntity(
|
||||
async def async_skip(self) -> None:
|
||||
"""Skip the current offered version to update."""
|
||||
if (latest_version := self.latest_version) is None:
|
||||
raise HomeAssistantError(f"Cannot skip an unknown version for {self.name}")
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="unknown_version_to_skip",
|
||||
translation_placeholders={"entity_id": self.entity_id},
|
||||
)
|
||||
if self.installed_version == latest_version:
|
||||
raise HomeAssistantError(f"No update available to skip for {self.name}")
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="no_update_available_to_skip",
|
||||
translation_placeholders={"entity_id": self.entity_id},
|
||||
)
|
||||
self.__skipped_version = latest_version
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
@@ -87,6 +87,32 @@
|
||||
"name": "Firmware"
|
||||
}
|
||||
},
|
||||
"exceptions": {
|
||||
"backup_not_supported": {
|
||||
"message": "Backup is not supported for {entity_id}."
|
||||
},
|
||||
"clear_skipped_not_supported": {
|
||||
"message": "Clearing skipped update is not supported for {entity_id}."
|
||||
},
|
||||
"no_update_available": {
|
||||
"message": "No update available for {entity_id}."
|
||||
},
|
||||
"no_update_available_to_skip": {
|
||||
"message": "No update available to skip for {entity_id}."
|
||||
},
|
||||
"skip_not_supported": {
|
||||
"message": "Skipping update is not supported for {entity_id}."
|
||||
},
|
||||
"specific_version_not_supported": {
|
||||
"message": "Installing a specific version is not supported for {entity_id}."
|
||||
},
|
||||
"unknown_version_to_skip": {
|
||||
"message": "Cannot skip an unknown version for {entity_id}."
|
||||
},
|
||||
"update_in_progress": {
|
||||
"message": "Update installation already in progress for {entity_id}."
|
||||
}
|
||||
},
|
||||
"services": {
|
||||
"clear_skipped": {
|
||||
"description": "Removes the skipped version marker from an update.",
|
||||
|
||||
Reference in New Issue
Block a user