mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Remove deprecated Xiaomi Miio fan speeds (#54182)
This commit is contained in:
parent
20b7125620
commit
07c0fc9eba
@ -420,20 +420,12 @@ class XiaomiGenericDevice(XiaomiCoordinatedMiioEntity, FanEntity):
|
|||||||
self._supported_features = 0
|
self._supported_features = 0
|
||||||
self._speed_count = 100
|
self._speed_count = 100
|
||||||
self._preset_modes = []
|
self._preset_modes = []
|
||||||
# the speed_list attribute is deprecated, support will end with release 2021.7
|
|
||||||
self._speed_list = []
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
return self._supported_features
|
return self._supported_features
|
||||||
|
|
||||||
# the speed_list attribute is deprecated, support will end with release 2021.7
|
|
||||||
@property
|
|
||||||
def speed_list(self) -> list:
|
|
||||||
"""Get the list of available speeds."""
|
|
||||||
return self._speed_list
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_count(self):
|
def speed_count(self):
|
||||||
"""Return the number of speeds of the fan supported."""
|
"""Return the number of speeds of the fan supported."""
|
||||||
@ -516,9 +508,6 @@ class XiaomiGenericDevice(XiaomiCoordinatedMiioEntity, FanEntity):
|
|||||||
"Turning the miio device on failed.", self._device.on
|
"Turning the miio device on failed.", self._device.on
|
||||||
)
|
)
|
||||||
|
|
||||||
# Remove the async_set_speed call is async_set_percentage and async_set_preset_modes have been implemented
|
|
||||||
if speed:
|
|
||||||
await self.async_set_speed(speed)
|
|
||||||
# If operation mode was set the device must not be turned on.
|
# If operation mode was set the device must not be turned on.
|
||||||
if percentage:
|
if percentage:
|
||||||
await self.async_set_percentage(percentage)
|
await self.async_set_percentage(percentage)
|
||||||
@ -610,61 +599,39 @@ class XiaomiAirPurifier(XiaomiGenericDevice):
|
|||||||
if self._model == MODEL_AIRPURIFIER_PRO:
|
if self._model == MODEL_AIRPURIFIER_PRO:
|
||||||
self._device_features = FEATURE_FLAGS_AIRPURIFIER_PRO
|
self._device_features = FEATURE_FLAGS_AIRPURIFIER_PRO
|
||||||
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_PRO
|
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_PRO
|
||||||
# SUPPORT_SET_SPEED was disabled
|
|
||||||
# the device supports preset_modes only
|
|
||||||
self._preset_modes = PRESET_MODES_AIRPURIFIER_PRO
|
self._preset_modes = PRESET_MODES_AIRPURIFIER_PRO
|
||||||
self._supported_features = SUPPORT_PRESET_MODE
|
self._supported_features = SUPPORT_PRESET_MODE
|
||||||
self._speed_count = 1
|
self._speed_count = 1
|
||||||
# the speed_list attribute is deprecated, support will end with release 2021.7
|
|
||||||
self._speed_list = OPERATION_MODES_AIRPURIFIER_PRO
|
|
||||||
elif self._model == MODEL_AIRPURIFIER_PRO_V7:
|
elif self._model == MODEL_AIRPURIFIER_PRO_V7:
|
||||||
self._device_features = FEATURE_FLAGS_AIRPURIFIER_PRO_V7
|
self._device_features = FEATURE_FLAGS_AIRPURIFIER_PRO_V7
|
||||||
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_PRO_V7
|
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_PRO_V7
|
||||||
# SUPPORT_SET_SPEED was disabled
|
|
||||||
# the device supports preset_modes only
|
|
||||||
self._preset_modes = PRESET_MODES_AIRPURIFIER_PRO_V7
|
self._preset_modes = PRESET_MODES_AIRPURIFIER_PRO_V7
|
||||||
self._supported_features = SUPPORT_PRESET_MODE
|
self._supported_features = SUPPORT_PRESET_MODE
|
||||||
self._speed_count = 1
|
self._speed_count = 1
|
||||||
# the speed_list attribute is deprecated, support will end with release 2021.7
|
|
||||||
self._speed_list = OPERATION_MODES_AIRPURIFIER_PRO_V7
|
|
||||||
elif self._model in [MODEL_AIRPURIFIER_2S, MODEL_AIRPURIFIER_2H]:
|
elif self._model in [MODEL_AIRPURIFIER_2S, MODEL_AIRPURIFIER_2H]:
|
||||||
self._device_features = FEATURE_FLAGS_AIRPURIFIER_2S
|
self._device_features = FEATURE_FLAGS_AIRPURIFIER_2S
|
||||||
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_2S
|
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_2S
|
||||||
# SUPPORT_SET_SPEED was disabled
|
|
||||||
# the device supports preset_modes only
|
|
||||||
self._preset_modes = PRESET_MODES_AIRPURIFIER_2S
|
self._preset_modes = PRESET_MODES_AIRPURIFIER_2S
|
||||||
self._supported_features = SUPPORT_PRESET_MODE
|
self._supported_features = SUPPORT_PRESET_MODE
|
||||||
self._speed_count = 1
|
self._speed_count = 1
|
||||||
# the speed_list attribute is deprecated, support will end with release 2021.7
|
|
||||||
self._speed_list = OPERATION_MODES_AIRPURIFIER_2S
|
|
||||||
elif self._model in MODELS_PURIFIER_MIOT:
|
elif self._model in MODELS_PURIFIER_MIOT:
|
||||||
self._device_features = FEATURE_FLAGS_AIRPURIFIER_3
|
self._device_features = FEATURE_FLAGS_AIRPURIFIER_3
|
||||||
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_3
|
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_3
|
||||||
# SUPPORT_SET_SPEED was disabled
|
|
||||||
# the device supports preset_modes only
|
|
||||||
self._preset_modes = PRESET_MODES_AIRPURIFIER_3
|
self._preset_modes = PRESET_MODES_AIRPURIFIER_3
|
||||||
self._supported_features = SUPPORT_SET_SPEED | SUPPORT_PRESET_MODE
|
self._supported_features = SUPPORT_SET_SPEED | SUPPORT_PRESET_MODE
|
||||||
self._speed_count = 3
|
self._speed_count = 3
|
||||||
# the speed_list attribute is deprecated, support will end with release 2021.7
|
|
||||||
self._speed_list = OPERATION_MODES_AIRPURIFIER_3
|
|
||||||
elif self._model == MODEL_AIRPURIFIER_V3:
|
elif self._model == MODEL_AIRPURIFIER_V3:
|
||||||
self._device_features = FEATURE_FLAGS_AIRPURIFIER_V3
|
self._device_features = FEATURE_FLAGS_AIRPURIFIER_V3
|
||||||
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_V3
|
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_V3
|
||||||
# SUPPORT_SET_SPEED was disabled
|
|
||||||
# the device supports preset_modes only
|
|
||||||
self._preset_modes = PRESET_MODES_AIRPURIFIER_V3
|
self._preset_modes = PRESET_MODES_AIRPURIFIER_V3
|
||||||
self._supported_features = SUPPORT_PRESET_MODE
|
self._supported_features = SUPPORT_PRESET_MODE
|
||||||
self._speed_count = 1
|
self._speed_count = 1
|
||||||
# the speed_list attribute is deprecated, support will end with release 2021.7
|
|
||||||
self._speed_list = OPERATION_MODES_AIRPURIFIER_V3
|
|
||||||
else:
|
else:
|
||||||
self._device_features = FEATURE_FLAGS_AIRPURIFIER
|
self._device_features = FEATURE_FLAGS_AIRPURIFIER
|
||||||
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER
|
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER
|
||||||
self._preset_modes = PRESET_MODES_AIRPURIFIER
|
self._preset_modes = PRESET_MODES_AIRPURIFIER
|
||||||
self._supported_features = SUPPORT_PRESET_MODE
|
self._supported_features = SUPPORT_PRESET_MODE
|
||||||
self._speed_count = 1
|
self._speed_count = 1
|
||||||
# the speed_list attribute is deprecated, support will end with release 2021.7
|
|
||||||
self._speed_list = []
|
|
||||||
|
|
||||||
self._state_attrs.update(
|
self._state_attrs.update(
|
||||||
{attribute: None for attribute in self._available_attributes}
|
{attribute: None for attribute in self._available_attributes}
|
||||||
@ -693,15 +660,6 @@ class XiaomiAirPurifier(XiaomiGenericDevice):
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# the speed attribute is deprecated, support will end with release 2021.7
|
|
||||||
@property
|
|
||||||
def speed(self):
|
|
||||||
"""Return the current speed."""
|
|
||||||
if self._state:
|
|
||||||
return AirpurifierOperationMode(self._state_attrs[ATTR_MODE]).name
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
async def async_set_percentage(self, percentage: int) -> None:
|
async def async_set_percentage(self, percentage: int) -> None:
|
||||||
"""Set the percentage of the fan.
|
"""Set the percentage of the fan.
|
||||||
|
|
||||||
@ -731,21 +689,6 @@ class XiaomiAirPurifier(XiaomiGenericDevice):
|
|||||||
self.PRESET_MODE_MAPPING[preset_mode],
|
self.PRESET_MODE_MAPPING[preset_mode],
|
||||||
)
|
)
|
||||||
|
|
||||||
# the async_set_speed function is deprecated, support will end with release 2021.7
|
|
||||||
# it is added here only for compatibility with legacy speeds
|
|
||||||
async def async_set_speed(self, speed: str) -> None:
|
|
||||||
"""Set the speed of the fan."""
|
|
||||||
if self.supported_features & SUPPORT_SET_SPEED == 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
_LOGGER.debug("Setting the operation mode to: %s", speed)
|
|
||||||
|
|
||||||
await self._try_command(
|
|
||||||
"Setting operation mode of the miio device failed.",
|
|
||||||
self._device.set_mode,
|
|
||||||
AirpurifierOperationMode[speed.title()],
|
|
||||||
)
|
|
||||||
|
|
||||||
async def async_set_led_on(self):
|
async def async_set_led_on(self):
|
||||||
"""Turn the led on."""
|
"""Turn the led on."""
|
||||||
if self._device_features & FEATURE_SET_LED == 0:
|
if self._device_features & FEATURE_SET_LED == 0:
|
||||||
@ -892,15 +835,6 @@ class XiaomiAirPurifierMiot(XiaomiAirPurifier):
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# the speed attribute is deprecated, support will end with release 2021.7
|
|
||||||
@property
|
|
||||||
def speed(self):
|
|
||||||
"""Return the current speed."""
|
|
||||||
if self._state:
|
|
||||||
return AirpurifierMiotOperationMode(self._mode).name
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
async def async_set_percentage(self, percentage: int) -> None:
|
async def async_set_percentage(self, percentage: int) -> None:
|
||||||
"""Set the percentage of the fan.
|
"""Set the percentage of the fan.
|
||||||
|
|
||||||
@ -933,23 +867,6 @@ class XiaomiAirPurifierMiot(XiaomiAirPurifier):
|
|||||||
self._mode = self.PRESET_MODE_MAPPING[preset_mode].value
|
self._mode = self.PRESET_MODE_MAPPING[preset_mode].value
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
# the async_set_speed function is deprecated, support will end with release 2021.7
|
|
||||||
# it is added here only for compatibility with legacy speeds
|
|
||||||
async def async_set_speed(self, speed: str) -> None:
|
|
||||||
"""Set the speed of the fan."""
|
|
||||||
if self.supported_features & SUPPORT_SET_SPEED == 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
_LOGGER.debug("Setting the operation mode to: %s", speed)
|
|
||||||
|
|
||||||
if await self._try_command(
|
|
||||||
"Setting operation mode of the miio device failed.",
|
|
||||||
self._device.set_mode,
|
|
||||||
AirpurifierMiotOperationMode[speed.title()],
|
|
||||||
):
|
|
||||||
self._mode = AirpurifierMiotOperationMode[speed.title()].value
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
|
||||||
|
|
||||||
class XiaomiAirFresh(XiaomiGenericDevice):
|
class XiaomiAirFresh(XiaomiGenericDevice):
|
||||||
"""Representation of a Xiaomi Air Fresh."""
|
"""Representation of a Xiaomi Air Fresh."""
|
||||||
@ -974,8 +891,6 @@ class XiaomiAirFresh(XiaomiGenericDevice):
|
|||||||
|
|
||||||
self._device_features = FEATURE_FLAGS_AIRFRESH
|
self._device_features = FEATURE_FLAGS_AIRFRESH
|
||||||
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRFRESH
|
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRFRESH
|
||||||
# the speed_list attribute is deprecated, support will end with release 2021.7
|
|
||||||
self._speed_list = OPERATION_MODES_AIRFRESH
|
|
||||||
self._speed_count = 4
|
self._speed_count = 4
|
||||||
self._preset_modes = PRESET_MODES_AIRFRESH
|
self._preset_modes = PRESET_MODES_AIRFRESH
|
||||||
self._supported_features = SUPPORT_SET_SPEED | SUPPORT_PRESET_MODE
|
self._supported_features = SUPPORT_SET_SPEED | SUPPORT_PRESET_MODE
|
||||||
@ -1005,15 +920,6 @@ class XiaomiAirFresh(XiaomiGenericDevice):
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# the speed attribute is deprecated, support will end with release 2021.7
|
|
||||||
@property
|
|
||||||
def speed(self):
|
|
||||||
"""Return the current speed."""
|
|
||||||
if self._state:
|
|
||||||
return AirfreshOperationMode(self._mode).name
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
async def async_set_percentage(self, percentage: int) -> None:
|
async def async_set_percentage(self, percentage: int) -> None:
|
||||||
"""Set the percentage of the fan.
|
"""Set the percentage of the fan.
|
||||||
|
|
||||||
@ -1049,23 +955,6 @@ class XiaomiAirFresh(XiaomiGenericDevice):
|
|||||||
self._mode = self.PRESET_MODE_MAPPING[preset_mode].value
|
self._mode = self.PRESET_MODE_MAPPING[preset_mode].value
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
# the async_set_speed function is deprecated, support will end with release 2021.7
|
|
||||||
# it is added here only for compatibility with legacy speeds
|
|
||||||
async def async_set_speed(self, speed: str) -> None:
|
|
||||||
"""Set the speed of the fan."""
|
|
||||||
if self.supported_features & SUPPORT_SET_SPEED == 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
_LOGGER.debug("Setting the operation mode to: %s", speed)
|
|
||||||
|
|
||||||
if await self._try_command(
|
|
||||||
"Setting operation mode of the miio device failed.",
|
|
||||||
self._device.set_mode,
|
|
||||||
AirfreshOperationMode[speed.title()],
|
|
||||||
):
|
|
||||||
self._mode = AirfreshOperationMode[speed.title()].value
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
|
||||||
async def async_set_led_on(self):
|
async def async_set_led_on(self):
|
||||||
"""Turn the led on."""
|
"""Turn the led on."""
|
||||||
if self._device_features & FEATURE_SET_LED == 0:
|
if self._device_features & FEATURE_SET_LED == 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user