Add translation_domain to lamarzocco exceptions (#126959)

This commit is contained in:
Josef Zweck 2024-09-27 22:01:46 +02:00 committed by GitHub
parent f6ac5dab74
commit 8a266aac34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 0 deletions

View File

@ -13,6 +13,7 @@ from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import LaMarzoccoConfigEntry from . import LaMarzoccoConfigEntry
from .const import DOMAIN
from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription
@ -61,6 +62,7 @@ class LaMarzoccoButtonEntity(LaMarzoccoEntity, ButtonEntity):
await self.entity_description.press_fn(self.coordinator.device) await self.entity_description.press_fn(self.coordinator.device)
except RequestNotSuccessful as exc: except RequestNotSuccessful as exc:
raise HomeAssistantError( raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="button_error", translation_key="button_error",
translation_placeholders={ translation_placeholders={
"key": self.entity_description.key, "key": self.entity_description.key,

View File

@ -32,6 +32,7 @@ from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import LaMarzoccoConfigEntry from . import LaMarzoccoConfigEntry
from .const import DOMAIN
from .coordinator import LaMarzoccoUpdateCoordinator from .coordinator import LaMarzoccoUpdateCoordinator
from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription
@ -228,6 +229,7 @@ class LaMarzoccoNumberEntity(LaMarzoccoEntity, NumberEntity):
) )
except RequestNotSuccessful as exc: except RequestNotSuccessful as exc:
raise HomeAssistantError( raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="number_exception", translation_key="number_exception",
translation_placeholders={ translation_placeholders={
"key": self.entity_description.key, "key": self.entity_description.key,
@ -277,6 +279,7 @@ class LaMarzoccoKeyNumberEntity(LaMarzoccoEntity, NumberEntity):
) )
except RequestNotSuccessful as exc: except RequestNotSuccessful as exc:
raise HomeAssistantError( raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="number_exception_key", translation_key="number_exception_key",
translation_placeholders={ translation_placeholders={
"key": self.entity_description.key, "key": self.entity_description.key,

View File

@ -16,6 +16,7 @@ from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import LaMarzoccoConfigEntry from . import LaMarzoccoConfigEntry
from .const import DOMAIN
from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription
STEAM_LEVEL_HA_TO_LM = { STEAM_LEVEL_HA_TO_LM = {
@ -121,6 +122,7 @@ class LaMarzoccoSelectEntity(LaMarzoccoEntity, SelectEntity):
) )
except RequestNotSuccessful as exc: except RequestNotSuccessful as exc:
raise HomeAssistantError( raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="select_option_error", translation_key="select_option_error",
translation_placeholders={ translation_placeholders={
"key": self.entity_description.key, "key": self.entity_description.key,

View File

@ -16,6 +16,7 @@ from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import LaMarzoccoConfigEntry from . import LaMarzoccoConfigEntry
from .const import DOMAIN
from .coordinator import LaMarzoccoUpdateCoordinator from .coordinator import LaMarzoccoUpdateCoordinator
from .entity import LaMarzoccoBaseEntity, LaMarzoccoEntity, LaMarzoccoEntityDescription from .entity import LaMarzoccoBaseEntity, LaMarzoccoEntity, LaMarzoccoEntityDescription
@ -83,6 +84,7 @@ class LaMarzoccoSwitchEntity(LaMarzoccoEntity, SwitchEntity):
await self.entity_description.control_fn(self.coordinator.device, True) await self.entity_description.control_fn(self.coordinator.device, True)
except RequestNotSuccessful as exc: except RequestNotSuccessful as exc:
raise HomeAssistantError( raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="switch_on_error", translation_key="switch_on_error",
translation_placeholders={"key": self.entity_description.key}, translation_placeholders={"key": self.entity_description.key},
) from exc ) from exc
@ -94,6 +96,7 @@ class LaMarzoccoSwitchEntity(LaMarzoccoEntity, SwitchEntity):
await self.entity_description.control_fn(self.coordinator.device, False) await self.entity_description.control_fn(self.coordinator.device, False)
except RequestNotSuccessful as exc: except RequestNotSuccessful as exc:
raise HomeAssistantError( raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="switch_off_error", translation_key="switch_off_error",
translation_placeholders={"name": self.entity_description.key}, translation_placeholders={"name": self.entity_description.key},
) from exc ) from exc
@ -132,6 +135,7 @@ class LaMarzoccoAutoOnOffSwitchEntity(LaMarzoccoBaseEntity, SwitchEntity):
await self.coordinator.device.set_wake_up_sleep(wake_up_sleep_entry) await self.coordinator.device.set_wake_up_sleep(wake_up_sleep_entry)
except RequestNotSuccessful as exc: except RequestNotSuccessful as exc:
raise HomeAssistantError( raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="auto_on_off_error", translation_key="auto_on_off_error",
translation_placeholders={"id": self._identifier, "state": str(state)}, translation_placeholders={"id": self._identifier, "state": str(state)},
) from exc ) from exc

View File

@ -18,6 +18,7 @@ from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import LaMarzoccoConfigEntry from . import LaMarzoccoConfigEntry
from .const import DOMAIN
from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription
@ -101,6 +102,7 @@ class LaMarzoccoUpdateEntity(LaMarzoccoEntity, UpdateEntity):
) )
except RequestNotSuccessful as exc: except RequestNotSuccessful as exc:
raise HomeAssistantError( raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="update_failed", translation_key="update_failed",
translation_placeholders={ translation_placeholders={
"key": self.entity_description.key, "key": self.entity_description.key,
@ -108,6 +110,7 @@ class LaMarzoccoUpdateEntity(LaMarzoccoEntity, UpdateEntity):
) from exc ) from exc
if not success: if not success:
raise HomeAssistantError( raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="update_failed", translation_key="update_failed",
translation_placeholders={ translation_placeholders={
"key": self.entity_description.key, "key": self.entity_description.key,