From 2b025ac6a884b3f5d88c2f49e49116ee55165d78 Mon Sep 17 00:00:00 2001 From: override80 Date: Sun, 7 Jul 2024 11:03:22 +0200 Subject: [PATCH 1/3] Fix Home Assistant 2024.01 deprecations (#245) --- custom_components/xiaomi_miio_fan/fan.py | 43 +++++++++++------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/custom_components/xiaomi_miio_fan/fan.py b/custom_components/xiaomi_miio_fan/fan.py index 28b750b..c47b5f1 100644 --- a/custom_components/xiaomi_miio_fan/fan.py +++ b/custom_components/xiaomi_miio_fan/fan.py @@ -14,12 +14,10 @@ import voluptuous as vol from homeassistant.components.fan import ( PLATFORM_SCHEMA, - SUPPORT_DIRECTION, - SUPPORT_OSCILLATE, - SUPPORT_PRESET_MODE, - SUPPORT_SET_SPEED, FanEntity, + FanEntityFeature, ) + from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_MODE, @@ -725,15 +723,14 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid self._state_attrs.update( {attribute: None for attribute in self._available_attributes} ) - @property def supported_features(self) -> int: """Supported features.""" return ( - SUPPORT_SET_SPEED - | SUPPORT_PRESET_MODE - | SUPPORT_OSCILLATE - | SUPPORT_DIRECTION + FanEntityFeature.SET_SPEED + | FanEntityFeature.PRESET_MODE + | FanEntityFeature.OSCILLATE + | FanEntityFeature.DIRECTION ) async def async_update(self): @@ -1102,7 +1099,7 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid @property def supported_features(self) -> int: """Supported features.""" - return SUPPORT_SET_SPEED | SUPPORT_PRESET_MODE | SUPPORT_OSCILLATE + return FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE | FanEntityFeature.OSCILLATE async def async_update(self): """Fetch state from the device.""" @@ -1240,7 +1237,7 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid @property def supported_features(self) -> int: """Supported features.""" - return SUPPORT_SET_SPEED | SUPPORT_PRESET_MODE | SUPPORT_OSCILLATE + return FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE | FanEntityFeature.OSCILLATE async def async_update(self): """Fetch state from the device.""" @@ -1416,10 +1413,10 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid @property def supported_features(self) -> int: return ( - SUPPORT_DIRECTION - | SUPPORT_OSCILLATE - | SUPPORT_PRESET_MODE - | SUPPORT_SET_SPEED + FanEntityFeature.DIRECTION + | FanEntityFeature.OSCILLATE + | FanEntityFeature.PRESET_MODE + | FanEntityFeature.SET_SPEED ) async def async_update(self): @@ -1857,10 +1854,10 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid @property def supported_features(self) -> int: return ( - SUPPORT_DIRECTION - | SUPPORT_OSCILLATE - | SUPPORT_PRESET_MODE - | SUPPORT_SET_SPEED + FanEntityFeature.DIRECTION + | FanEntityFeature.OSCILLATE + | FanEntityFeature.PRESET_MODE + | FanEntityFeature.SET_SPEED ) """ @@ -2164,10 +2161,10 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid @property def supported_features(self) -> int: return ( - SUPPORT_DIRECTION - | SUPPORT_OSCILLATE - | SUPPORT_PRESET_MODE - | SUPPORT_SET_SPEED + FanEntityFeature.DIRECTION + | FanEntityFeature.OSCILLATE + | FanEntityFeature.PRESET_MODE + | FanEntityFeature.SET_SPEED ) async def async_update(self): From 1460b0173379fd76facc5184e01a9c03aa55277a Mon Sep 17 00:00:00 2001 From: Reece King Date: Sun, 7 Jul 2024 10:05:08 +0100 Subject: [PATCH 2/3] Add dmaker.fan.p30 (Mi Smart Standing Fan 2 P30) support (#248) --- README.md | 41 ++++++++++++------------ custom_components/xiaomi_miio_fan/fan.py | 8 +++-- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index f54bce5..48cbb96 100644 --- a/README.md +++ b/README.md @@ -14,26 +14,27 @@ Credits: Thanks to [Rytilahti](https://github.com/rytilahti/python-miio) for all ## Supported devices -| Name | Model | Model no. | Specs | -| ----------------------- | ---------------------- | --------- | ----- | -| Pedestal Fan Fan V2 | zhimi.fan.v2 | | | -| Pedestal Fan Fan V3 | zhimi.fan.v3 | | | -| Pedestal Fan Fan SA1 | zhimi.fan.sa1 | | | -| Pedestal Fan Fan ZA1 | zhimi.fan.za1 | | | -| Pedestal Fan Fan ZA3 | zhimi.fan.za3 | | | -| Pedestal Fan Fan ZA4 | zhimi.fan.za4 | ZLBPLDS04ZM | | -| Smartmi Standing Fan 3 | zhimi.fan.za5 | | | -| Pedestal Fan Fan 1C | dmaker.fan.1c | | | -| Pedestal Fan Fan P5 | dmaker.fan.p5 | | | -| Pedestal Fan Fan P8 | dmaker.fan.p8 | | | -| Pedestal Fan Fan P9 | dmaker.fan.p9 | | | -| Pedestal Fan Fan P10 | dmaker.fan.p10 | | | -| Mijia Pedestal Fan | dmaker.fan.p11 | BPLDS03DM | 2800mAh, 24W, <=58dB | -| Smart Standing Fan 2 Pro| dmaker.fan.p33 | BPLDS03DM | 2800mAh, 24W, <=58dB | -| Pedestal Fan Fan P15 | dmaker.fan.p15 | | | -| Mi Smart Standing Fan 2 | dmaker.fan.p18 | BPLDS02DM | AC, 15W, 30.2-55.8bB | -| Rosou SS4 Ventilator | leshow.fan.ss4 | | | -| Xiaomi Smart Tower Fan | dmaker.fan.p39 | BPTS01DM | 22W, <=63dB | +| Name | Model | Model no. | Specs | +| ----------------------------| ---------------------- | --------- | ----- | +| Pedestal Fan Fan V2 | zhimi.fan.v2 | | | +| Pedestal Fan Fan V3 | zhimi.fan.v3 | | | +| Pedestal Fan Fan SA1 | zhimi.fan.sa1 | | | +| Pedestal Fan Fan ZA1 | zhimi.fan.za1 | | | +| Pedestal Fan Fan ZA3 | zhimi.fan.za3 | | | +| Pedestal Fan Fan ZA4 | zhimi.fan.za4 | ZLBPLDS04ZM | | +| Smartmi Standing Fan 3 | zhimi.fan.za5 | | | +| Pedestal Fan Fan 1C | dmaker.fan.1c | | | +| Pedestal Fan Fan P5 | dmaker.fan.p5 | | | +| Pedestal Fan Fan P8 | dmaker.fan.p8 | | | +| Pedestal Fan Fan P9 | dmaker.fan.p9 | | | +| Pedestal Fan Fan P10 | dmaker.fan.p10 | | | +| Mijia Pedestal Fan | dmaker.fan.p11 | BPLDS03DM | 2800mAh, 24W, <=58dB | +| Smart Standing Fan 2 Pro | dmaker.fan.p33 | BPLDS03DM | 2800mAh, 24W, <=58dB | +| Pedestal Fan Fan P15 | dmaker.fan.p15 | | | +| Mi Smart Standing Fan 2 P18 | dmaker.fan.p18 | BPLDS02DM | AC, 15W, 30.2-55.8bB | +| Mi Smart Standing Fan 2 P30 | dmaker.fan.p30 | BPLDS02DM | AC, 15W, 30.2-55.8bB | +| Rosou SS4 Ventilator | leshow.fan.ss4 | | | +| Xiaomi Smart Tower Fan | dmaker.fan.p39 | BPTS01DM | 22W, <=63dB | ## Features diff --git a/custom_components/xiaomi_miio_fan/fan.py b/custom_components/xiaomi_miio_fan/fan.py index c47b5f1..c1ada7e 100644 --- a/custom_components/xiaomi_miio_fan/fan.py +++ b/custom_components/xiaomi_miio_fan/fan.py @@ -74,7 +74,8 @@ MODEL_FAN_P10 = "dmaker.fan.p10" # Pedestal Fan Fan P10 MODEL_FAN_P11 = "dmaker.fan.p11" # Mijia Pedestal Fan MODEL_FAN_P15 = "dmaker.fan.p15" # Pedestal Fan Fan P15 -MODEL_FAN_P18 = "dmaker.fan.p18" # Mi Smart Standing Fan 2 +MODEL_FAN_P18 = "dmaker.fan.p18" # Mi Smart Standing Fan 2 P18 +MODEL_FAN_P30 = "dmaker.fan.p30" # Mi Smart Standing Fan 2 P30 MODEL_FAN_P33 = "dmaker.fan.p33" # Mi Smart Standing Fan Pro 2 MODEL_FAN_P39 = "dmaker.fan.p39" # Smart Tower Fan MODEL_FAN_LESHOW_SS4 = "leshow.fan.ss4" @@ -101,6 +102,7 @@ MODEL_FAN_P11, MODEL_FAN_P15, MODEL_FAN_P18, + MODEL_FAN_P30, MODEL_FAN_P33, MODEL_FAN_P39, MODEL_FAN_LESHOW_SS4, @@ -478,7 +480,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= device = XiaomiFanMiot( name, fan, model, unique_id, retries, preset_modes_override ) - elif model in [MODEL_FAN_P10, MODEL_FAN_P18]: + elif model in [MODEL_FAN_P10, MODEL_FAN_P18, MODEL_FAN_P30]: fan = FanMiot(host, token, model=MODEL_FAN_P10) device = XiaomiFanMiot( name, fan, model, unique_id, retries, preset_modes_override @@ -1072,7 +1074,7 @@ async def async_set_delay_off(self, delay_off_countdown: int) -> None: class XiaomiFanMiot(XiaomiFanP5): - """Representation of a Xiaomi Pedestal Fan P9, P10, P11, P18.""" + """Representation of a Xiaomi Pedestal Fan P9, P10, P11, P18, P30.""" pass From 22944a5c219c71e0db21dd8c47cbb472fb720e49 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Mon, 8 Jul 2024 13:13:36 +0200 Subject: [PATCH 3/3] Bump component version --- custom_components/xiaomi_miio_fan/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/xiaomi_miio_fan/manifest.json b/custom_components/xiaomi_miio_fan/manifest.json index 9826adf..dc928be 100644 --- a/custom_components/xiaomi_miio_fan/manifest.json +++ b/custom_components/xiaomi_miio_fan/manifest.json @@ -12,5 +12,5 @@ "construct==2.10.68", "python-miio>=0.5.12" ], - "version": "2023.12.0.0" + "version": "2024.7.0.0" }