From 85f52bc05dacdbec3bec1dfe6cc0c8d58f9e1860 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Thu, 5 Nov 2020 07:26:11 +0100 Subject: [PATCH] Add basic dmaker.fan.p11 support (#850) --- README.rst | 2 +- miio/__init__.py | 2 +- miio/discovery.py | 3 ++- miio/fan_miot.py | 28 ++++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 6428c53c5..c53e8c610 100644 --- a/README.rst +++ b/README.rst @@ -105,7 +105,7 @@ Supported devices - Xiaomi Philips Zhirui Smart LED Bulb E14 Candle Lamp - Xiaomi Philips Zhirui Bedroom Smart Lamp - Xiaomi Universal IR Remote Controller (Chuangmi IR) -- Xiaomi Mi Smart Pedestal Fan V2, V3, SA1, ZA1, ZA3, ZA4, P5, P9, P10 +- Xiaomi Mi Smart Pedestal Fan V2, V3, SA1, ZA1, ZA3, ZA4, P5, P9, P10, P11 - Xiaomi Mi Air Humidifier V1, CA1, CA4, CB1, MJJSQ, JSQ001 - Xiaomi Mi Water Purifier (Basic support: Turn on & off) - Xiaomi PM2.5 Air Quality Monitor V1, B1, S1 diff --git a/miio/__init__.py b/miio/__init__.py index f108e507c..0bc490d7e 100644 --- a/miio/__init__.py +++ b/miio/__init__.py @@ -30,7 +30,7 @@ from miio.device import Device from miio.exceptions import DeviceError, DeviceException from miio.fan import Fan, FanP5, FanSA1, FanV2, FanZA1, FanZA4 -from miio.fan_miot import FanMiot, FanP9, FanP10 +from miio.fan_miot import FanMiot, FanP9, FanP10, FanP11 from miio.gateway import Gateway from miio.heater import Heater from miio.philips_bulb import PhilipsBulb, PhilipsWhiteBulb diff --git a/miio/discovery.py b/miio/discovery.py index 7e2b55275..6567ba799 100644 --- a/miio/discovery.py +++ b/miio/discovery.py @@ -79,7 +79,7 @@ MODEL_FAN_ZA3, MODEL_FAN_ZA4, ) -from .fan_miot import MODEL_FAN_P9, MODEL_FAN_P10 +from .fan_miot import MODEL_FAN_P9, MODEL_FAN_P10, MODEL_FAN_P11 from .heater import MODEL_HEATER_MA1, MODEL_HEATER_ZA1 from .powerstrip import MODEL_POWER_STRIP_V1, MODEL_POWER_STRIP_V2 from .toiletlid import MODEL_TOILETLID_V1 @@ -165,6 +165,7 @@ "dmaker-fan-p5": partial(Fan, model=MODEL_FAN_P5), "dmaker-fan-p9": partial(FanMiot, model=MODEL_FAN_P9), "dmaker-fan-p10": partial(FanMiot, model=MODEL_FAN_P10), + "dmaker-fan-p11": partial(FanMiot, model=MODEL_FAN_P11), "tinymu-toiletlid-v1": partial(Toiletlid, model=MODEL_TOILETLID_V1), "zhimi-airfresh-va2": partial(AirFresh, model=MODEL_AIRFRESH_VA2), "zhimi-airfresh-va4": partial(AirFresh, model=MODEL_AIRFRESH_VA4), diff --git a/miio/fan_miot.py b/miio/fan_miot.py index 3804e804e..4438df488 100644 --- a/miio/fan_miot.py +++ b/miio/fan_miot.py @@ -9,6 +9,7 @@ MODEL_FAN_P9 = "dmaker.fan.p9" MODEL_FAN_P10 = "dmaker.fan.p10" +MODEL_FAN_P11 = "dmaker.fan.p11" MIOT_MAPPING = { MODEL_FAN_P9: { @@ -39,6 +40,21 @@ "mode": {"siid": 2, "piid": 3}, "set_move": {"siid": 2, "piid": 9}, }, + MODEL_FAN_P11: { + # Source https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-p11:1 + "power": {"siid": 2, "piid": 1}, + "fan_level": {"siid": 2, "piid": 2}, + "mode": {"siid": 2, "piid": 3}, + "swing_mode": {"siid": 2, "piid": 4}, + "swing_mode_angle": {"siid": 2, "piid": 5}, + # "status": {"siid": 2, "piid": 6}, + "light": {"siid": 4, "piid": 1}, + "buzzer": {"siid": 5, "piid": 1}, + # "device_fault": {"siid": 6, "piid": 2}, + "child_lock": {"siid": 7, "piid": 1}, + "power_off_time": {"siid": 3, "piid": 1}, + "set_move": {"siid": 6, "piid": 1}, + }, } @@ -324,3 +340,15 @@ def __init__( lazy_discover: bool = True, ) -> None: super().__init__(ip, token, start_id, debug, lazy_discover, model=MODEL_FAN_P10) + + +class FanP11(FanMiot): + def __init__( + self, + ip: str = None, + token: str = None, + start_id: int = 0, + debug: int = 0, + lazy_discover: bool = True, + ) -> None: + super().__init__(ip, token, start_id, debug, lazy_discover, model=MODEL_FAN_P11)