From a80e6a2b1afc0721ee43347ea3ff0b0f8480af15 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sun, 11 Apr 2021 10:00:15 +0200 Subject: [PATCH 1/5] Use the proper device class for dmaker.fan.p9 --- custom_components/xiaomi_miio_fan/fan.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/custom_components/xiaomi_miio_fan/fan.py b/custom_components/xiaomi_miio_fan/fan.py index 7ffea3d..0cf9ae1 100644 --- a/custom_components/xiaomi_miio_fan/fan.py +++ b/custom_components/xiaomi_miio_fan/fan.py @@ -14,8 +14,10 @@ DeviceException, Fan, FanLeshow, - FanMiot, FanP5, + FanP9, + FanP10, + FanP11, ) from miio.fan import ( # pylint: disable=import-error, import-error LedBrightness as FanLedBrightness, @@ -310,8 +312,14 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= elif model == MODEL_FAN_P5: fan = FanP5(host, token, model=model) device = XiaomiFanP5(name, fan, model, unique_id, retries) - elif model in [MODEL_FAN_P9, MODEL_FAN_P10, MODEL_FAN_P11]: - fan = FanMiot(host, token, model=model) + elif model == MODEL_FAN_P9: + fan = FanP9(host, token, model=model) + device = XiaomiFanMiot(name, fan, model, unique_id, retries) + elif model == MODEL_FAN_P10: + fan = FanP10(host, token, model=model) + device = XiaomiFanMiot(name, fan, model, unique_id, retries) + elif model == MODEL_FAN_P11: + fan = FanP11(host, token, model=model) device = XiaomiFanMiot(name, fan, model, unique_id, retries) elif model == MODEL_FAN_LESHOW_SS4: fan = FanLeshow(host, token, model=model) From 9600f5b2d1e5ef3c2e6a788631b30411ffff6437 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sun, 18 Apr 2021 10:47:05 +0200 Subject: [PATCH 2/5] Fix `set_percentage` service of the dmaker.fan.p5 --- custom_components/xiaomi_miio_fan/fan.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/custom_components/xiaomi_miio_fan/fan.py b/custom_components/xiaomi_miio_fan/fan.py index 0cf9ae1..b0745be 100644 --- a/custom_components/xiaomi_miio_fan/fan.py +++ b/custom_components/xiaomi_miio_fan/fan.py @@ -820,6 +820,20 @@ async def async_set_preset_mode(self, preset_mode: str) -> None: FAN_PRESET_MODE_VALUES_P5[preset_mode], ) + async def async_set_percentage(self, percentage: int) -> None: + """Set the speed percentage of the fan.""" + _LOGGER.debug("Setting the fan speed percentage to: %s", percentage) + + if percentage == 0: + await self.async_turn_off() + return + + await self._try_command( + "Setting fan speed percentage of the miio device failed.", + self._device.set_speed, + percentage, + ) + async def async_set_natural_mode_on(self): """Turn the natural mode on.""" if self._device_features & FEATURE_SET_NATURAL_MODE == 0: From 55a503c584f042fea105ef0b58f1d1922c7e2ecb Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sun, 18 Apr 2021 10:55:14 +0200 Subject: [PATCH 3/5] Update README --- README.md | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 07c1be6..72d1e48 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,10 @@ Credits: Thanks to [Rytilahti](https://github.com/rytilahti/python-miio) for all ### Pedestal Fan * Power (on, off) -* Speed levels (Level 1, Level 2, Level 3, Level 4) +* Preset modes (Level 1, Level 2, Level 3, Level 4) +* Speed percentage (0...100) * Oscillate (on, off) -* Oscillation angle (30, 60, 90, 120) +* Oscillation angle (30, 60, 90, 120, 140, 150) * Natural mode (on, off) * Rotate by 5 degrees (left, right) * Child lock (on, off) @@ -41,6 +42,26 @@ Credits: Thanks to [Rytilahti](https://github.com/rytilahti/python-miio) for all - battery_state (zhimi.fan.v2 only) +### Rosou SS4 Ventilator (leshow.fan.ss4) + +* Power (on, off) +* Operation modes (manual, sleep, strong, natural) +* Preset modes (Level 1, Level 2, Level 3, Level 4) +* Speed percentage (0...100) +* Oscillate (on, off) +* Buzzer (on, off) +* Delayed turn off (minutes) + +* Attributes + - `model` + - `mode` + - `speed` + - `buzzer` + - `oscillate` + - `delay_off_countdown` + - `error_detected` + + ## Install You can install this custom component by adding this repository ([https://github.com/syssi/xiaomi_fan](https://github.com/syssi/xiaomi_fan/)) to [HACS](https://hacs.xyz/) in the settings menu of HACS first. You will find the custom component in the integration menu afterwards, look for 'Xiaomi Mi Smart Pedestal Fan Integration'. Alternatively, you can install it manually by copying the custom_component folder to your Home Assistant configuration folder. @@ -66,14 +87,23 @@ Configuration variables: ## Platform services -#### Service `fan.set_speed` +#### Service `fan.set_percentage` -Set the fan speed. +Set the fan speed percentage. | Service data attribute | Optional | Description | |---------------------------|----------|----------------------------------------------------------------------------| | `entity_id` | yes | Only act on a specific fan entity. Else targets all. | -| `speed` | no | Fan speed. Valid values are `Level 1`, `Level 2`, `Level 3` and `Level 4` as well as a value between 0 and 100. | +| `percentage` | no | Percentage speed setting. Valid values are between 0 and 100. | + +#### Service `fan.set_preset_mode` + +Set a preset mode. + +| Service data attribute | Optional | Description | +|---------------------------|----------|------------------------------------------------------------------------------| +| `entity_id` | yes | Only act on a specific fan entity. Else targets all. | +| `preset_mode` | no | Preset mode. Valid values are `Level 1`, `Level 2`, `Level 3` and `Level 4`. | #### Service `fan.oscillate` From 4665012c7ff56bd5b80b170ed3350317c5e41a55 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sun, 18 Apr 2021 10:57:21 +0200 Subject: [PATCH 4/5] Add new devices to the README --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 72d1e48..95660f8 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,23 @@ Please follow the instructions on [Retrieving the Access Token](https://www.home Credits: Thanks to [Rytilahti](https://github.com/rytilahti/python-miio) for all the work. +## 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 | | | +| Pedestal Fan Fan P5 | dmaker.fan.p5 | | | +| Pedestal Fan Fan P9 | dmaker.fan.p9 | | | +| Pedestal Fan Fan P10 | dmaker.fan.p10 | | | +| Mijia Pedestal Fan | dmaker.fan.p11 | BPLDS03DM | 2800mAh, 24W, <=58dB | +| Rosou SS4 Ventilator | leshow.fan.ss4 | | | + + ## Features ### Pedestal Fan @@ -83,7 +100,7 @@ Configuration variables: - **host** (*Required*): The IP of your fan. - **token** (*Required*): The API token of your fan. - **name** (*Optional*): The name of your fan. -- **model** (*Optional*): The model of your device. Valid values are `zhimi.fan.v2`, `zhimi.fan.v3`, `zhimi.fan.sa1`, `zhimi.fan.za1`, `zhimi.fan.za3`, `zhimi.fan.za4` and `dmaker.fan.p5`. This setting can be used to bypass the device model detection and is recommended if your device isn't always available. +- **model** (*Optional*): The model of your device. This setting can be used to bypass the device model detection and is recommended if your device isn't always available. ## Platform services From 6d75d022b478db676e68a03dd1587d845224fe66 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sun, 18 Apr 2021 11:14:25 +0200 Subject: [PATCH 5/5] Add minimum required HA core version and bump version --- custom_components/xiaomi_miio_fan/manifest.json | 2 +- hacs.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/custom_components/xiaomi_miio_fan/manifest.json b/custom_components/xiaomi_miio_fan/manifest.json index 1a7e697..5691103 100644 --- a/custom_components/xiaomi_miio_fan/manifest.json +++ b/custom_components/xiaomi_miio_fan/manifest.json @@ -1,7 +1,7 @@ { "domain": "xiaomi_miio_fan", "name": "Xiaomi Mi Smart Pedestal Fan", - "version": "0.3.0", + "version": "0.3.2", "documentation": "https://github.com/syssi/xiaomi_fan", "requirements": [ "construct==2.10.56", diff --git a/hacs.json b/hacs.json index a8ff611..97911a2 100644 --- a/hacs.json +++ b/hacs.json @@ -2,5 +2,6 @@ "name": "Xiaomi Mi Smart Pedestal Fan Integration", "content_in_root": false, "render_readme": true, - "iot_class": "local_polling" + "iot_class": "local_polling", + "homeassistant": "2021.4.0" }