Skip to content

Commit

Permalink
Add basic dmaker.fan.p11 support (#850)
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi authored Nov 5, 2020
1 parent 05da523 commit 85f52bc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion miio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion miio/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
28 changes: 28 additions & 0 deletions miio/fan_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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},
},
}


Expand Down Expand Up @@ -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)

0 comments on commit 85f52bc

Please sign in to comment.