Skip to content

Commit

Permalink
Add more supported models based on discovery.py's mdns records (#1258)
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Dec 15, 2021
1 parent df1745a commit 8283b22
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 7 deletions.
8 changes: 5 additions & 3 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ Development checklist
or :class:`miio.miot_device.MiotDevice` (for MiOT) (:ref:`Minimal example`).
2. All commands and their arguments should be decorated with `@command` decorator,
which will make them accessible to `miiocli` (:ref:`miiocli`).
3. Status containers is derived from `DeviceStatus` class and all properties should
3. All implementations must define :ref:`Device._supported_models` variable in the class
listing the known models (as reported by `info()`).
4. Status containers is derived from `DeviceStatus` class and all properties should
have type annotations for their return values.
4. Creating tests (:ref:`adding_tests`).
5. Updating documentation is generally not needed as the API documentation
5. Creating tests (:ref:`adding_tests`).
6. Updating documentation is generally not needed as the API documentation
will be generated automatically.


Expand Down
9 changes: 9 additions & 0 deletions miio/airconditioner_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
from .miot_device import DeviceStatus, MiotDevice

_LOGGER = logging.getLogger(__name__)

SUPPORTED_MODELS = [
"xiaomi.aircondition.mc1",
"xiaomi.aircondition.mc2",
"xiaomi.aircondition.mc4",
"xiaomi.aircondition.mc5",
]

_MAPPING = {
# Source http://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-mc4:1
# Air Conditioner (siid=2)
Expand Down Expand Up @@ -273,6 +281,7 @@ def timer(self) -> TimerStatus:
class AirConditionerMiot(MiotDevice):
"""Main class representing the air conditioner which uses MIoT protocol."""

_supported_models = SUPPORTED_MODELS
mapping = _MAPPING

@command(
Expand Down
1 change: 1 addition & 0 deletions miio/airpurifier_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"zhimi.airpurifier.ma4", # airpurifier 3
"zhimi.airpurifier.mb3", # airpurifier 3h
"zhimi.airpurifier.va1", # airpurifier proh
"zhimi.airpurifier.vb2", # airpurifier proh
]

_LOGGER = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion miio/aqaracamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def av_password(self) -> str:
class AqaraCamera(Device):
"""Main class representing the Xiaomi Aqara Camera."""

_supported_models = ["lumi.camera.aq1"]
_supported_models = ["lumi.camera.aq1", "lumi.camera.aq2"]

@command(
default_output=format_output(
Expand Down
5 changes: 4 additions & 1 deletion miio/ceil.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
_LOGGER = logging.getLogger(__name__)


SUPPORTED_MODELS = ["philips.light.ceiling", "philips.light.zyceiling"]


class CeilException(DeviceException):
pass

Expand Down Expand Up @@ -73,7 +76,7 @@ class Ceil(Device):
# TODO: - Auto On/Off Not Supported
# - Adjust Scenes with Wall Switch Not Supported

_supported_models = ["unknown.models"]
_supported_models = SUPPORTED_MODELS

@command(
default_output=format_output(
Expand Down
5 changes: 4 additions & 1 deletion miio/chuangmi_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ class ChuangmiIrException(DeviceException):
class ChuangmiIr(Device):
"""Main class representing Chuangmi IR Remote Controller."""

_supported_models = ["unknown.models"]
_supported_models = [
"chuangmi.ir.v2",
"chuangmi-remote-h102a03", # maybe?
]

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

Expand Down
4 changes: 3 additions & 1 deletion miio/waterpurifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def valve(self) -> str:
class WaterPurifier(Device):
"""Main class representing the water purifier."""

_supported_models = ["unknown.models"]
_supported_models = [
"yunmi.waterpuri.v2", # unknown if correct, based on mdns response
]

@command(
default_output=format_output(
Expand Down

0 comments on commit 8283b22

Please sign in to comment.