From a69fa4d20e457e4fd649dbdc95c0f61af6b7179c Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Thu, 3 Mar 2022 14:40:28 +0100 Subject: [PATCH] Fix imports to be python-miio v0.5.10 compatible (#180) Closes: #179 --- custom_components/xiaomi_miio_fan/fan.py | 29 ++++++++++--------- .../xiaomi_miio_fan/manifest.json | 4 +-- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/custom_components/xiaomi_miio_fan/fan.py b/custom_components/xiaomi_miio_fan/fan.py index 170a236..98924e3 100644 --- a/custom_components/xiaomi_miio_fan/fan.py +++ b/custom_components/xiaomi_miio_fan/fan.py @@ -13,7 +13,6 @@ import homeassistant.helpers.config_validation as cv import voluptuous as vol from homeassistant.components.fan import ( - ATTR_SPEED, PLATFORM_SCHEMA, SPEED_OFF, SUPPORT_DIRECTION, @@ -46,14 +45,15 @@ FanP11, ) from miio.miot_device import MiotDevice, DeviceStatus -from miio.fan import ( +from miio.fan_common import ( LedBrightness as FanLedBrightness, # pylint: disable=import-error, import-error + MoveDirection as FanMoveDirection, + OperationMode as FanOperationMode, + FanException, ) -from miio.fan import MoveDirection as FanMoveDirection -from miio.fan_leshow import ( +from miio.integrations.fan.leshow.fan_leshow import ( OperationMode as FanLeshowOperationMode, # pylint: disable=import-error, import-error ) -from miio.fan_miot import OperationModeMiot as FanOperationModeMiot _LOGGER = logging.getLogger(__name__) @@ -902,7 +902,7 @@ async def async_update(self): self._available = True self._percentage = state.speed self._oscillate = state.oscillate - self._natural_mode = state.mode == FanOperationModeMiot.Nature + self._natural_mode = state.mode == FanOperationMode.Nature self._state = state.is_on for preset_mode, range in FAN_PRESET_MODES.items(): @@ -973,7 +973,7 @@ async def async_set_natural_mode_on(self): await self._try_command( "Turning on natural mode of the miio device failed.", self._device.set_mode, - FanOperationModeMiot.Nature, + FanOperationMode.Nature, ) async def async_set_natural_mode_off(self): @@ -984,7 +984,7 @@ async def async_set_natural_mode_off(self): await self._try_command( "Turning on natural mode of the miio device failed.", self._device.set_mode, - FanOperationModeMiot.Normal, + FanOperationMode.Normal, ) async def async_set_delay_off(self, delay_off_countdown: int) -> None: @@ -1001,6 +1001,7 @@ class XiaomiFanMiot(XiaomiFanP5): """Representation of a Xiaomi Pedestal Fan P9, P10, P11, P18.""" pass + class XiaomiFanLeshow(XiaomiGenericDevice): """Representation of a Xiaomi Fan Leshow SS4.""" @@ -1302,7 +1303,7 @@ async def async_set_natural_mode_on(self): await self._try_command( "Setting fan natural mode of the miio device failed.", self._device.set_mode, - FanOperationModeMiot.Nature, + FanOperationMode.Nature, ) async def async_set_natural_mode_off(self): @@ -1313,7 +1314,7 @@ async def async_set_natural_mode_off(self): await self._try_command( "Setting fan natural mode of the miio device failed.", self._device.set_mode, - FanOperationModeMiot.Normal, + FanOperationMode.Normal, ) @@ -1355,7 +1356,7 @@ async def async_update(self): self._available = True self._percentage = state.fan_speed self._oscillate = state.swing_mode - self._natural_mode = state.mode == FanOperationModeMiot.Nature + self._natural_mode = state.mode == FanOperationMode.Nature self._state = state.power for preset_mode, value in FAN_PRESET_MODES_ZA5.items(): @@ -1470,7 +1471,7 @@ async def async_set_natural_mode_on(self): await self._try_command( "Setting fan natural mode of the miio device failed.", self._device.set_mode, - FanOperationModeMiot.Nature, + FanOperationMode.Nature, ) async def async_set_natural_mode_off(self): @@ -1481,7 +1482,7 @@ async def async_set_natural_mode_off(self): await self._try_command( "Setting fan natural mode of the miio device failed.", self._device.set_mode, - FanOperationModeMiot.Normal, + FanOperationMode.Normal, ) async def async_set_led_brightness(self, brightness: int = 2): @@ -1736,7 +1737,7 @@ def set_light(self, light: int): return self.set_property("light", light) - def set_mode(self, mode: FanOperationModeMiot): + def set_mode(self, mode: FanOperationMode): """Set mode.""" return self.set_property("mode", OperationModeFanZA5[mode.name].value) diff --git a/custom_components/xiaomi_miio_fan/manifest.json b/custom_components/xiaomi_miio_fan/manifest.json index 5394687..090c914 100644 --- a/custom_components/xiaomi_miio_fan/manifest.json +++ b/custom_components/xiaomi_miio_fan/manifest.json @@ -1,13 +1,13 @@ { "domain": "xiaomi_miio_fan", "name": "Xiaomi Mi Smart Pedestal Fan", - "version": "0.5.4", + "version": "2022.3.0", "iot_class": "local_polling", "documentation": "https://github.com/syssi/xiaomi_fan", "issue_tracker": "https://github.com/syssi/xiaomi_fan/issues", "requirements": [ "construct==2.10.56", - "python-miio>=0.5.9.2" + "python-miio>=0.5.10" ], "dependencies": [], "codeowners": [