diff --git a/README.md b/README.md index 07c1be6..95660f8 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,32 @@ 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 * 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 +59,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. @@ -62,18 +100,27 @@ 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 -#### 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` diff --git a/custom_components/xiaomi_miio_fan/fan.py b/custom_components/xiaomi_miio_fan/fan.py index 7ffea3d..b0745be 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) @@ -812,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: 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" }