Use action property defined in MieleEntity (#144052)

This commit is contained in:
Åke Strandberg 2025-05-01 16:06:49 +02:00 committed by Paulus Schoutsen
parent 1143468eb5
commit ea9a0f4bf5
4 changed files with 8 additions and 18 deletions

View File

@ -131,8 +131,7 @@ class MieleButton(MieleEntity, ButtonEntity):
return ( return (
super().available super().available
and self.entity_description.press_data and self.entity_description.press_data in self.action.process_actions
in self.coordinator.data.actions[self._device_id].process_actions
) )
async def async_press(self) -> None: async def async_press(self) -> None:

View File

@ -201,9 +201,7 @@ class MieleClimate(MieleEntity, ClimateEntity):
"""Return the maximum target temperature.""" """Return the maximum target temperature."""
return cast( return cast(
float, float,
self.coordinator.data.actions[self._device_id] self.action.target_temperature[self.entity_description.zone - 1].max,
.target_temperature[self.entity_description.zone - 1]
.max,
) )
@property @property
@ -211,9 +209,7 @@ class MieleClimate(MieleEntity, ClimateEntity):
"""Return the minimum target temperature.""" """Return the minimum target temperature."""
return cast( return cast(
float, float,
self.coordinator.data.actions[self._device_id] self.action.target_temperature[self.entity_description.zone - 1].min,
.target_temperature[self.entity_description.zone - 1]
.min,
) )
async def async_set_temperature(self, **kwargs: Any) -> None: async def async_set_temperature(self, **kwargs: Any) -> None:

View File

@ -47,7 +47,7 @@ class MieleEntity(CoordinatorEntity[MieleDataUpdateCoordinator]):
return self.coordinator.data.devices[self._device_id] return self.coordinator.data.devices[self._device_id]
@property @property
def actions(self) -> MieleAction: def action(self) -> MieleAction:
"""Return the actions object.""" """Return the actions object."""
return self.coordinator.data.actions[self._device_id] return self.coordinator.data.actions[self._device_id]

View File

@ -169,15 +169,14 @@ class MielePowerSwitch(MieleSwitch):
@property @property
def is_on(self) -> bool | None: def is_on(self) -> bool | None:
"""Return the state of the switch.""" """Return the state of the switch."""
return self.coordinator.data.actions[self._device_id].power_off_enabled return self.action.power_off_enabled
@property @property
def available(self) -> bool: def available(self) -> bool:
"""Return the availability of the entity.""" """Return the availability of the entity."""
return ( return (
self.coordinator.data.actions[self._device_id].power_off_enabled self.action.power_off_enabled or self.action.power_on_enabled
or self.coordinator.data.actions[self._device_id].power_on_enabled
) and super().available ) and super().available
async def async_turn_switch(self, mode: dict[str, str | int | bool]) -> None: async def async_turn_switch(self, mode: dict[str, str | int | bool]) -> None:
@ -192,12 +191,8 @@ class MielePowerSwitch(MieleSwitch):
"entity": self.entity_id, "entity": self.entity_id,
}, },
) from err ) from err
self.coordinator.data.actions[self._device_id].power_on_enabled = cast( self.action.power_on_enabled = cast(bool, mode)
bool, mode self.action.power_off_enabled = not cast(bool, mode)
)
self.coordinator.data.actions[self._device_id].power_off_enabled = not cast(
bool, mode
)
self.async_write_ha_state() self.async_write_ha_state()