From cba8d3db5daa7a2a4e4ce767875762e26b8b28c1 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sat, 29 Aug 2026 15:19:37 +0200 Subject: [PATCH] Translate the update install and skip errors (#180615) --- homeassistant/components/update/__init__.py | 40 ++++++++++++++++---- homeassistant/components/update/strings.json | 26 +++++++++++++ 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/update/__init__.py b/homeassistant/components/update/__init__.py index f4e0a5312bba..58761ff95ddc 100644 --- a/homeassistant/components/update/__init__.py +++ b/homeassistant/components/update/__init__.py @@ -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() diff --git a/homeassistant/components/update/strings.json b/homeassistant/components/update/strings.json index fe27e41434b8..306223b84419 100644 --- a/homeassistant/components/update/strings.json +++ b/homeassistant/components/update/strings.json @@ -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.",