From ea9a0f4bf546f9ae441f97dd79f413f4c44ef602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Strandberg?= Date: Thu, 1 May 2025 16:06:49 +0200 Subject: [PATCH] Use action property defined in MieleEntity (#144052) --- homeassistant/components/miele/button.py | 3 +-- homeassistant/components/miele/climate.py | 8 ++------ homeassistant/components/miele/entity.py | 2 +- homeassistant/components/miele/switch.py | 13 ++++--------- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/homeassistant/components/miele/button.py b/homeassistant/components/miele/button.py index e4aacc5124c..70d4489e9be 100644 --- a/homeassistant/components/miele/button.py +++ b/homeassistant/components/miele/button.py @@ -131,8 +131,7 @@ class MieleButton(MieleEntity, ButtonEntity): return ( super().available - and self.entity_description.press_data - in self.coordinator.data.actions[self._device_id].process_actions + and self.entity_description.press_data in self.action.process_actions ) async def async_press(self) -> None: diff --git a/homeassistant/components/miele/climate.py b/homeassistant/components/miele/climate.py index 3b591965d2f..054ab227ca6 100644 --- a/homeassistant/components/miele/climate.py +++ b/homeassistant/components/miele/climate.py @@ -201,9 +201,7 @@ class MieleClimate(MieleEntity, ClimateEntity): """Return the maximum target temperature.""" return cast( float, - self.coordinator.data.actions[self._device_id] - .target_temperature[self.entity_description.zone - 1] - .max, + self.action.target_temperature[self.entity_description.zone - 1].max, ) @property @@ -211,9 +209,7 @@ class MieleClimate(MieleEntity, ClimateEntity): """Return the minimum target temperature.""" return cast( float, - self.coordinator.data.actions[self._device_id] - .target_temperature[self.entity_description.zone - 1] - .min, + self.action.target_temperature[self.entity_description.zone - 1].min, ) async def async_set_temperature(self, **kwargs: Any) -> None: diff --git a/homeassistant/components/miele/entity.py b/homeassistant/components/miele/entity.py index a84c1f1108b..f9ed4f0bf48 100644 --- a/homeassistant/components/miele/entity.py +++ b/homeassistant/components/miele/entity.py @@ -47,7 +47,7 @@ class MieleEntity(CoordinatorEntity[MieleDataUpdateCoordinator]): return self.coordinator.data.devices[self._device_id] @property - def actions(self) -> MieleAction: + def action(self) -> MieleAction: """Return the actions object.""" return self.coordinator.data.actions[self._device_id] diff --git a/homeassistant/components/miele/switch.py b/homeassistant/components/miele/switch.py index 74a9f0c4785..427d90968b7 100644 --- a/homeassistant/components/miele/switch.py +++ b/homeassistant/components/miele/switch.py @@ -169,15 +169,14 @@ class MielePowerSwitch(MieleSwitch): @property def is_on(self) -> bool | None: """Return the state of the switch.""" - return self.coordinator.data.actions[self._device_id].power_off_enabled + return self.action.power_off_enabled @property def available(self) -> bool: """Return the availability of the entity.""" return ( - self.coordinator.data.actions[self._device_id].power_off_enabled - or self.coordinator.data.actions[self._device_id].power_on_enabled + self.action.power_off_enabled or self.action.power_on_enabled ) and super().available async def async_turn_switch(self, mode: dict[str, str | int | bool]) -> None: @@ -192,12 +191,8 @@ class MielePowerSwitch(MieleSwitch): "entity": self.entity_id, }, ) from err - self.coordinator.data.actions[self._device_id].power_on_enabled = cast( - bool, mode - ) - self.coordinator.data.actions[self._device_id].power_off_enabled = not cast( - bool, mode - ) + self.action.power_on_enabled = cast(bool, mode) + self.action.power_off_enabled = not cast(bool, mode) self.async_write_ha_state()