diff --git a/homeassistant/components/velbus/__init__.py b/homeassistant/components/velbus/__init__.py index f78d3655d540..ca6bad062246 100644 --- a/homeassistant/components/velbus/__init__.py +++ b/homeassistant/components/velbus/__init__.py @@ -105,7 +105,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: VelbusConfigEntry) -> bo try: await controller.connect() except VelbusConnectionFailed as error: - raise ConfigEntryNotReady("Cannot connect to Velbus") from error + raise ConfigEntryNotReady( + translation_domain=DOMAIN, + translation_key="connection_failed", + ) from error task = hass.async_create_task(velbus_scan_task(controller, hass, entry.entry_id)) entry.runtime_data = VelbusData(controller=controller, scan_task=task) diff --git a/homeassistant/components/velbus/entity.py b/homeassistant/components/velbus/entity.py index af7ea8bbcccf..aa221b3ca107 100644 --- a/homeassistant/components/velbus/entity.py +++ b/homeassistant/components/velbus/entity.py @@ -66,6 +66,7 @@ class VelbusEntity(Entity): self._channel.remove_on_status_update(self._on_update) async def _on_update(self) -> None: + """Handle status updates from the channel.""" self.async_write_ha_state() @@ -80,8 +81,13 @@ def api_call[_T: VelbusEntity, **_P]( try: await func(self, *args, **kwargs) except OSError as exc: + entity_name = self.name if isinstance(self.name, str) else "Unknown" raise HomeAssistantError( - f"Could not execute {func.__name__} service for {self.name}" + translation_domain=DOMAIN, + translation_key="api_call_failed", + translation_placeholders={ + "entity": entity_name, + }, ) from exc return cmd_wrapper diff --git a/homeassistant/components/velbus/quality_scale.yaml b/homeassistant/components/velbus/quality_scale.yaml index 83b8bce6c0c2..b0e366780296 100644 --- a/homeassistant/components/velbus/quality_scale.yaml +++ b/homeassistant/components/velbus/quality_scale.yaml @@ -56,7 +56,7 @@ rules: entity-device-class: todo entity-disabled-by-default: done entity-translations: todo - exception-translations: todo + exception-translations: done icon-translations: todo reconfiguration-flow: todo repair-issues: diff --git a/homeassistant/components/velbus/strings.json b/homeassistant/components/velbus/strings.json index ff51ad066e5a..d9432afa08e3 100644 --- a/homeassistant/components/velbus/strings.json +++ b/homeassistant/components/velbus/strings.json @@ -57,8 +57,14 @@ } }, "exceptions": { + "api_call_failed": { + "message": "Action execute for {entity} failed." + }, "clear_cache_failed": { - "message": "Could not cleat the Velbus cache: {error}" + "message": "Could not clear the Velbus cache: {error}" + }, + "connection_failed": { + "message": "Could not connect to Velbus." }, "integration_not_found": { "message": "Integration \"{target}\" not found in registry."