From 8a266aac3473c0aba40a1999385bdb40705ea99b Mon Sep 17 00:00:00 2001 From: Josef Zweck <24647999+zweckj@users.noreply.github.com> Date: Fri, 27 Sep 2024 22:01:46 +0200 Subject: [PATCH] Add `translation_domain` to lamarzocco exceptions (#126959) --- homeassistant/components/lamarzocco/button.py | 2 ++ homeassistant/components/lamarzocco/number.py | 3 +++ homeassistant/components/lamarzocco/select.py | 2 ++ homeassistant/components/lamarzocco/switch.py | 4 ++++ homeassistant/components/lamarzocco/update.py | 3 +++ 5 files changed, 14 insertions(+) diff --git a/homeassistant/components/lamarzocco/button.py b/homeassistant/components/lamarzocco/button.py index 4e3052c0c0f..56fcca98cb3 100644 --- a/homeassistant/components/lamarzocco/button.py +++ b/homeassistant/components/lamarzocco/button.py @@ -13,6 +13,7 @@ from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import LaMarzoccoConfigEntry +from .const import DOMAIN from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription @@ -61,6 +62,7 @@ class LaMarzoccoButtonEntity(LaMarzoccoEntity, ButtonEntity): await self.entity_description.press_fn(self.coordinator.device) except RequestNotSuccessful as exc: raise HomeAssistantError( + translation_domain=DOMAIN, translation_key="button_error", translation_placeholders={ "key": self.entity_description.key, diff --git a/homeassistant/components/lamarzocco/number.py b/homeassistant/components/lamarzocco/number.py index 879535688d5..e607d856193 100644 --- a/homeassistant/components/lamarzocco/number.py +++ b/homeassistant/components/lamarzocco/number.py @@ -32,6 +32,7 @@ from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import LaMarzoccoConfigEntry +from .const import DOMAIN from .coordinator import LaMarzoccoUpdateCoordinator from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription @@ -228,6 +229,7 @@ class LaMarzoccoNumberEntity(LaMarzoccoEntity, NumberEntity): ) except RequestNotSuccessful as exc: raise HomeAssistantError( + translation_domain=DOMAIN, translation_key="number_exception", translation_placeholders={ "key": self.entity_description.key, @@ -277,6 +279,7 @@ class LaMarzoccoKeyNumberEntity(LaMarzoccoEntity, NumberEntity): ) except RequestNotSuccessful as exc: raise HomeAssistantError( + translation_domain=DOMAIN, translation_key="number_exception_key", translation_placeholders={ "key": self.entity_description.key, diff --git a/homeassistant/components/lamarzocco/select.py b/homeassistant/components/lamarzocco/select.py index 59dac69b35a..7a410796285 100644 --- a/homeassistant/components/lamarzocco/select.py +++ b/homeassistant/components/lamarzocco/select.py @@ -16,6 +16,7 @@ from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import LaMarzoccoConfigEntry +from .const import DOMAIN from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription STEAM_LEVEL_HA_TO_LM = { @@ -121,6 +122,7 @@ class LaMarzoccoSelectEntity(LaMarzoccoEntity, SelectEntity): ) except RequestNotSuccessful as exc: raise HomeAssistantError( + translation_domain=DOMAIN, translation_key="select_option_error", translation_placeholders={ "key": self.entity_description.key, diff --git a/homeassistant/components/lamarzocco/switch.py b/homeassistant/components/lamarzocco/switch.py index 5498b07401e..dda0f0f1d58 100644 --- a/homeassistant/components/lamarzocco/switch.py +++ b/homeassistant/components/lamarzocco/switch.py @@ -16,6 +16,7 @@ from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import LaMarzoccoConfigEntry +from .const import DOMAIN from .coordinator import LaMarzoccoUpdateCoordinator from .entity import LaMarzoccoBaseEntity, LaMarzoccoEntity, LaMarzoccoEntityDescription @@ -83,6 +84,7 @@ class LaMarzoccoSwitchEntity(LaMarzoccoEntity, SwitchEntity): await self.entity_description.control_fn(self.coordinator.device, True) except RequestNotSuccessful as exc: raise HomeAssistantError( + translation_domain=DOMAIN, translation_key="switch_on_error", translation_placeholders={"key": self.entity_description.key}, ) from exc @@ -94,6 +96,7 @@ class LaMarzoccoSwitchEntity(LaMarzoccoEntity, SwitchEntity): await self.entity_description.control_fn(self.coordinator.device, False) except RequestNotSuccessful as exc: raise HomeAssistantError( + translation_domain=DOMAIN, translation_key="switch_off_error", translation_placeholders={"name": self.entity_description.key}, ) from exc @@ -132,6 +135,7 @@ class LaMarzoccoAutoOnOffSwitchEntity(LaMarzoccoBaseEntity, SwitchEntity): await self.coordinator.device.set_wake_up_sleep(wake_up_sleep_entry) except RequestNotSuccessful as exc: raise HomeAssistantError( + translation_domain=DOMAIN, translation_key="auto_on_off_error", translation_placeholders={"id": self._identifier, "state": str(state)}, ) from exc diff --git a/homeassistant/components/lamarzocco/update.py b/homeassistant/components/lamarzocco/update.py index cbbdee68c40..0bf8ea3264f 100644 --- a/homeassistant/components/lamarzocco/update.py +++ b/homeassistant/components/lamarzocco/update.py @@ -18,6 +18,7 @@ from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import LaMarzoccoConfigEntry +from .const import DOMAIN from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription @@ -101,6 +102,7 @@ class LaMarzoccoUpdateEntity(LaMarzoccoEntity, UpdateEntity): ) except RequestNotSuccessful as exc: raise HomeAssistantError( + translation_domain=DOMAIN, translation_key="update_failed", translation_placeholders={ "key": self.entity_description.key, @@ -108,6 +110,7 @@ class LaMarzoccoUpdateEntity(LaMarzoccoEntity, UpdateEntity): ) from exc if not success: raise HomeAssistantError( + translation_domain=DOMAIN, translation_key="update_failed", translation_placeholders={ "key": self.entity_description.key,