Skip to content

Commit

Permalink
Add known models to supported models (#1202)
Browse files Browse the repository at this point in the history
* airhumidifier: add supported models

* gateway: add supported models

* aurqualitymonitor: add supported models

* Add currently known models to supported models
  • Loading branch information
rytilahti committed Dec 1, 2021
1 parent 5e03352 commit 7fc4540
Show file tree
Hide file tree
Showing 37 changed files with 123 additions and 2 deletions.
2 changes: 2 additions & 0 deletions miio/airconditioningcompanion.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ def mode(self) -> Optional[OperationMode]:
class AirConditioningCompanion(Device):
"""Main class representing Xiaomi Air Conditioning Companion V1 and V2."""

_supported_models = MODELS_SUPPORTED

def __init__(
self,
ip: str = None,
Expand Down
2 changes: 2 additions & 0 deletions miio/airconditioningcompanionMCN.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def swing_mode(self) -> Optional[SwingMode]:
class AirConditioningCompanionMcn02(Device):
"""Main class representing Xiaomi Air Conditioning Companion V1 and V2."""

_supported_models = [MODEL_ACPARTNER_MCN02]

def __init__(
self,
ip: str = None,
Expand Down
2 changes: 2 additions & 0 deletions miio/airdehumidifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ def alarm(self) -> str:
class AirDehumidifier(Device):
"""Implementation of Xiaomi Mi Air Dehumidifier."""

_supported_models = list(AVAILABLE_PROPERTIES.keys())

@command(
default_output=format_output(
"",
Expand Down
2 changes: 2 additions & 0 deletions miio/airfresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ def extra_features(self) -> Optional[int]:
class AirFresh(Device):
"""Main class representing the air fresh."""

_supported_models = list(AVAILABLE_PROPERTIES.keys())

@command(
default_output=format_output(
"",
Expand Down
2 changes: 2 additions & 0 deletions miio/airfresh_t2017.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ def display_orientation(self) -> Optional[DisplayOrientation]:
class AirFreshA1(Device):
"""Main class representing the air fresh a1."""

_supported_models = list(AVAILABLE_PROPERTIES.keys())

@command(
default_output=format_output(
"",
Expand Down
9 changes: 9 additions & 0 deletions miio/airhumidifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
MODEL_HUMIDIFIER_CB1 = "zhimi.humidifier.cb1"
MODEL_HUMIDIFIER_CB2 = "zhimi.humidifier.cb2"

SUPPORTED_MODELS = [
MODEL_HUMIDIFIER_V1,
MODEL_HUMIDIFIER_CA1,
MODEL_HUMIDIFIER_CB1,
MODEL_HUMIDIFIER_CB2,
]

AVAILABLE_PROPERTIES_COMMON = [
"power",
"mode",
Expand Down Expand Up @@ -251,6 +258,8 @@ def button_pressed(self) -> Optional[str]:
class AirHumidifier(Device):
"""Implementation of Xiaomi Mi Air Humidifier."""

_supported_models = SUPPORTED_MODELS

@command(
default_output=format_output(
"",
Expand Down
2 changes: 2 additions & 0 deletions miio/airhumidifier_jsq.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ def use_time(self) -> Optional[int]:
class AirHumidifierJsq(Device):
"""Implementation of Xiaomi Zero Fog Humidifier: shuii.humidifier.jsq001."""

_supported_models = [MODEL_HUMIDIFIER_JSQ001]

@command(
default_output=format_output(
"",
Expand Down
2 changes: 2 additions & 0 deletions miio/airhumidifier_mjjsq.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def use_time(self) -> Optional[int]:
class AirHumidifierMjjsq(Device):
"""Support for deerma.humidifier.(mj)jsq."""

_supported_models = list(AVAILABLE_PROPERTIES.keys())

@command(
default_output=format_output(
"",
Expand Down
11 changes: 11 additions & 0 deletions miio/airpurifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
_LOGGER = logging.getLogger(__name__)


SUPPORTED_MODELS = [
"zhimi.airpurifier.v3",
"zhimi.airpurifier.v6",
"zhimi.airpurifier.v7",
"zhimi.airpurifier.m1",
"zhimi.airpurifier.m2",
]


class AirPurifierException(DeviceException):
pass

Expand Down Expand Up @@ -300,6 +309,8 @@ def button_pressed(self) -> Optional[str]:
class AirPurifier(Device):
"""Main class representing the air purifier."""

_supported_models = SUPPORTED_MODELS

@command(
default_output=format_output(
"",
Expand Down
4 changes: 4 additions & 0 deletions miio/airpurifier_airdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ def hcho(self) -> Optional[int]:


class AirDogX3(Device):
"""Support for Airdog air purifiers (airdog.airpurifier.x*)."""

_supported_models = list(AVAILABLE_PROPERTIES.keys())

@command(
default_output=format_output(
"",
Expand Down
2 changes: 2 additions & 0 deletions miio/airqualitymonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ def tvoc(self) -> Optional[int]:
class AirQualityMonitor(Device):
"""Xiaomi PM2.5 Air Quality Monitor."""

_supported_models = list(AVAILABLE_PROPERTIES.keys())

@command(
default_output=format_output(
"",
Expand Down
2 changes: 2 additions & 0 deletions miio/alarmclock.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class AlarmClock(Device):
seconds /tries to get an answer.
"""

_supported_models = ["zimi.clock.myk01"]

@command()
def get_config_version(self):
"""
Expand Down
2 changes: 2 additions & 0 deletions miio/aqaracamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def av_password(self) -> str:
class AqaraCamera(Device):
"""Main class representing the Xiaomi Aqara Camera."""

_supported_models = ["lumi.camera.aq1"]

@command(
default_output=format_output(
"",
Expand Down
2 changes: 2 additions & 0 deletions miio/ceil.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class Ceil(Device):
# TODO: - Auto On/Off Not Supported
# - Adjust Scenes with Wall Switch Not Supported

_supported_models = ["unknown.models"]

@command(
default_output=format_output(
"",
Expand Down
4 changes: 4 additions & 0 deletions miio/chuangmi_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class NASVideoRetentionTime(enum.IntEnum):
CONST_HIGH_SENSITIVITY = [MotionDetectionSensitivity.High] * 32
CONST_LOW_SENSITIVITY = [MotionDetectionSensitivity.Low] * 32

SUPPORTED_MODELS = ["chuangmi.camera.ipc009", "chuangmi.camera.ipc019"]


class CameraStatus(DeviceStatus):
"""Container for status reports from the Xiaomi Chuangmi Camera."""
Expand Down Expand Up @@ -148,6 +150,8 @@ def mini_level(self) -> int:
class ChuangmiCamera(Device):
"""Main class representing the Xiaomi Chuangmi Camera."""

_supported_models = SUPPORTED_MODELS

@command(
default_output=format_output(
"",
Expand Down
2 changes: 2 additions & 0 deletions miio/chuangmi_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class ChuangmiIrException(DeviceException):
class ChuangmiIr(Device):
"""Main class representing Chuangmi IR Remote Controller."""

_supported_models = ["unknown.models"]

PRONTO_RE = re.compile(r"^([\da-f]{4}\s?){3,}([\da-f]{4})$", re.IGNORECASE)

@command(
Expand Down
2 changes: 2 additions & 0 deletions miio/chuangmi_plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def wifi_led(self) -> Optional[bool]:
class ChuangmiPlug(Device):
"""Main class representing the Chuangmi Plug."""

_supported_models = list(AVAILABLE_PROPERTIES.keys())

@command(
default_output=format_output(
"",
Expand Down
4 changes: 3 additions & 1 deletion miio/cooker.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,9 @@ def custom(self) -> Optional[CookerCustomizations]:


class Cooker(Device):
"""Main class representing the cooker."""
"""Main class representing the chunmi.cooker.*."""

_supported_models = [*MODEL_NORMAL, *MODEL_PRESSURE]

@command(
default_output=format_output(
Expand Down
6 changes: 6 additions & 0 deletions miio/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ def child_lock(self) -> bool:
class Fan(Device):
"""Main class representing the Xiaomi Mi Smart Pedestal Fan."""

_supported_models = list(AVAILABLE_PROPERTIES.keys() - MODEL_FAN_P5)

def __init__(
self,
ip: str = None,
Expand Down Expand Up @@ -524,6 +526,10 @@ def __init__(


class FanP5(Device):
"""Support for dmaker.fan.p5."""

_supported_models = [MODEL_FAN_P5]

def __init__(
self,
ip: str = None,
Expand Down
2 changes: 2 additions & 0 deletions miio/fan_leshow.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def error_detected(self) -> bool:
class FanLeshow(Device):
"""Main class representing the Xiaomi Rosou SS4 Ventilator."""

_supported_models = list(AVAILABLE_PROPERTIES.keys())

@command(
default_output=format_output(
"",
Expand Down
13 changes: 13 additions & 0 deletions miio/gateway/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
GATEWAY_MODEL_AC_V3 = "lumi.acpartner.v3"


SUPPORTED_MODELS = [
GATEWAY_MODEL_CHINA,
GATEWAY_MODEL_EU,
GATEWAY_MODEL_ZIG3,
GATEWAY_MODEL_AQARA,
GATEWAY_MODEL_AC_V1,
GATEWAY_MODEL_AC_V2,
GATEWAY_MODEL_AC_V3,
]


class GatewayException(DeviceException):
"""Exception for the Xioami Gateway communication."""

Expand Down Expand Up @@ -77,6 +88,8 @@ class Gateway(Device):
* get_lumi_bind ["scene", <page number>] for rooms/devices
"""

_supported_models = SUPPORTED_MODELS

def __init__(
self,
ip: str = None,
Expand Down
2 changes: 2 additions & 0 deletions miio/gateway/gatewaydevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class GatewayDevice(Device):
"""GatewayDevice class Specifies the init method for all gateway device
functionalities."""

_supported_models = ["dummy.device"]

def __init__(
self,
ip: str = None,
Expand Down
2 changes: 2 additions & 0 deletions miio/heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def delay_off_countdown(self) -> Optional[int]:
class Heater(Device):
"""Main class representing the Smartmi Zhimi Heater."""

_supported_models = list(SUPPORTED_MODELS.keys())

@command(
default_output=format_output(
"",
Expand Down
3 changes: 3 additions & 0 deletions miio/integrations/vacuum/viomi/viomivacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

_LOGGER = logging.getLogger(__name__)

SUPPORTED_MODELS = ["viomi.vacuum.v7"]

ERROR_CODES = {
0: "Sleeping and not charging",
Expand Down Expand Up @@ -479,6 +480,8 @@ def _get_rooms_from_schedules(schedules: List[str]) -> Tuple[bool, Dict]:
class ViomiVacuum(Device):
"""Interface for Viomi vacuums (viomi.vacuum.v7)."""

_supported_models = SUPPORTED_MODELS

timeout = 5
retry_count = 10

Expand Down
2 changes: 2 additions & 0 deletions miio/philips_bulb.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def delay_off_countdown(self) -> int:
class PhilipsWhiteBulb(Device):
"""Main class representing Xiaomi Philips White LED Ball Lamp."""

_supported_models = list(AVAILABLE_PROPERTIES.keys())

@command(
default_output=format_output(
"",
Expand Down
2 changes: 2 additions & 0 deletions miio/philips_eyecare.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def delay_off_countdown(self) -> int:
class PhilipsEyecare(Device):
"""Main class representing Xiaomi Philips Eyecare Smart Lamp 2."""

_supported_models = ["unknown.models"]

@command(
default_output=format_output(
"",
Expand Down
2 changes: 2 additions & 0 deletions miio/philips_moonlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class PhilipsMoonlight(Device):
enable_bl # Night light
"""

_supported_models = ["philips.light.moonlight"]

@command(
default_output=format_output(
"",
Expand Down
2 changes: 2 additions & 0 deletions miio/philips_rwread.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def child_lock(self) -> bool:
class PhilipsRwread(Device):
"""Main class representing Xiaomi Philips RW Read."""

_supported_models = list(AVAILABLE_PROPERTIES.keys())

@command(
default_output=format_output(
"",
Expand Down
2 changes: 2 additions & 0 deletions miio/pwzn_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ def on_count(self) -> Optional[int]:
class PwznRelay(Device):
"""Main class representing the PWZN Relay."""

_supported_models = list(AVAILABLE_PROPERTIES.keys())

@command(default_output=format_output("", "on_count: {result.on_count}\n"))
def status(self) -> PwznRelayStatus:
"""Retrieve properties."""
Expand Down
2 changes: 2 additions & 0 deletions miio/scishare_coffeemaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class Status(IntEnum):
class ScishareCoffee(Device):
"""Main class for Scishare coffee maker (scishare.coffee.s1102)."""

_supported_models = ["scishare.coffee.s1102"]

@command()
def status(self) -> int:
"""Device status."""
Expand Down
9 changes: 9 additions & 0 deletions miio/tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,12 @@ def test_device_ctor_model(cls):
dummy_model = "dummy"
dev = cls("127.0.0.1", "68ffffffffffffffffffffffffffffff", model=dummy_model)
assert dev.model == dummy_model


@pytest.mark.parametrize("cls", Device.__subclasses__())
def test_device_supported_models(cls):
"""Make sure that every device subclass has a non-empty supported models."""
if cls.__name__ == "MiotDevice": # skip miotdevice
return

assert cls._supported_models
4 changes: 4 additions & 0 deletions miio/toiletlid.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def ambient_light(self) -> str:


class Toiletlid(Device):
"""Support for tinymu.toiletlid.v1."""

_supported_models = list(AVAILABLE_PROPERTIES.keys())

@command(
default_output=format_output(
"",
Expand Down
2 changes: 2 additions & 0 deletions miio/walkingpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def calories(self) -> int:
class Walkingpad(Device):
"""Main class representing Xiaomi Walkingpad."""

_supported_models = ["ksmb.walkingpad.v3"]

@command(
default_output=format_output(
"",
Expand Down
4 changes: 3 additions & 1 deletion miio/waterpurifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ def valve(self) -> str:


class WaterPurifier(Device):
"""Main class representing the waiter purifier."""
"""Main class representing the water purifier."""

_supported_models = ["unknown.models"]

@command(
default_output=format_output(
Expand Down

0 comments on commit 7fc4540

Please sign in to comment.