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 (
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:

View File

@ -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:

View File

@ -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]

View File

@ -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()