Skip to content

Commit

Permalink
Move humidifier implementations to miio.integrations.humidifier packa…
Browse files Browse the repository at this point in the history
…ge (#1365)
  • Loading branch information
rytilahti authored Mar 20, 2022
1 parent a351515 commit 67f7de9
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 53 deletions.
13 changes: 8 additions & 5 deletions miio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from miio.device import Device, DeviceStatus # isort: skip
from miio.exceptions import DeviceError, DeviceException # isort: skip
from miio.miot_device import MiotDevice # isort: skip
from miio.deviceinfo import DeviceInfo # isort: skip

# Integration imports
from miio.airconditioner_miot import AirConditionerMiot
Expand All @@ -21,10 +22,6 @@
)
from miio.airconditioningcompanionMCN import AirConditioningCompanionMcn02
from miio.airdehumidifier import AirDehumidifier
from miio.airhumidifier import AirHumidifier
from miio.airhumidifier_jsq import AirHumidifierJsq
from miio.airhumidifier_miot import AirHumidifierMiot
from miio.airhumidifier_mjjsq import AirHumidifierMjjsq
from miio.airqualitymonitor import AirQualityMonitor
from miio.airqualitymonitor_miot import AirQualityMonitorCGDN1
from miio.aqaracamera import AqaraCamera
Expand All @@ -43,7 +40,13 @@
from miio.integrations.fan.dmaker import Fan1C, FanMiot, FanP5
from miio.integrations.fan.leshow import FanLeshow
from miio.integrations.fan.zhimi import Fan, FanZA5
from miio.integrations.humidifier.deerma import AirHumidifierJsqs
from miio.integrations.humidifier import (
AirHumidifier,
AirHumidifierJsq,
AirHumidifierJsqs,
AirHumidifierMiot,
AirHumidifierMjjsq,
)
from miio.integrations.light.philips import (
Ceil,
PhilipsBulb,
Expand Down
30 changes: 12 additions & 18 deletions miio/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
AirPurifier,
AirPurifierMiot,
)
from miio.integrations.humidifier import (
AirHumidifier,
AirHumidifierJsq,
AirHumidifierJsqs,
AirHumidifierMjjsq,
)
from miio.integrations.yeelight import Yeelight

from . import (
AirConditionerMiot,
AirConditioningCompanion,
AirConditioningCompanionMcn02,
AirHumidifier,
AirHumidifierJsq,
AirHumidifierJsqs,
AirHumidifierMjjsq,
AirQualityMonitor,
AqaraCamera,
Ceil,
Expand Down Expand Up @@ -57,12 +59,6 @@
MODEL_ACPARTNER_V3,
)
from .airconditioningcompanionMCN import MODEL_ACPARTNER_MCN02
from .airhumidifier import (
MODEL_HUMIDIFIER_CA1,
MODEL_HUMIDIFIER_CB1,
MODEL_HUMIDIFIER_V1,
)
from .airhumidifier_mjjsq import MODEL_HUMIDIFIER_JSQ1, MODEL_HUMIDIFIER_MJJSQ
from .airqualitymonitor import (
MODEL_AIRQUALITYMONITOR_B1,
MODEL_AIRQUALITYMONITOR_S1,
Expand Down Expand Up @@ -130,14 +126,12 @@
"chuangmi-camera-ipc019": ChuangmiCamera,
"chuangmi-ir-v2": ChuangmiIr,
"chuangmi-remote-h102a03_": ChuangmiIr,
"zhimi-humidifier-v1": partial(AirHumidifier, model=MODEL_HUMIDIFIER_V1),
"zhimi-humidifier-ca1": partial(AirHumidifier, model=MODEL_HUMIDIFIER_CA1),
"zhimi-humidifier-cb1": partial(AirHumidifier, model=MODEL_HUMIDIFIER_CB1),
"shuii-humidifier-jsq001": partial(AirHumidifierJsq, model=MODEL_HUMIDIFIER_MJJSQ),
"deerma-humidifier-mjjsq": partial(
AirHumidifierMjjsq, model=MODEL_HUMIDIFIER_MJJSQ
),
"deerma-humidifier-jsq1": partial(AirHumidifierMjjsq, model=MODEL_HUMIDIFIER_JSQ1),
"zhimi-humidifier-v1": AirHumidifier,
"zhimi-humidifier-ca1": AirHumidifier,
"zhimi-humidifier-cb1": AirHumidifier,
"shuii-humidifier-jsq001": AirHumidifierJsq,
"deerma-humidifier-mjjsq": AirHumidifierMjjsq,
"deerma-humidifier-jsq1": AirHumidifierMjjsq,
"deerma-humidifier-jsqs": AirHumidifierJsqs,
"yunmi-waterpuri-v2": WaterPurifier,
"yunmi.waterpuri.lx9": WaterPurifierYunmi,
Expand Down
4 changes: 4 additions & 0 deletions miio/integrations/humidifier/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# flake8: noqa
from .deerma import *
from .shuii import *
from .zhimi import *
1 change: 1 addition & 0 deletions miio/integrations/humidifier/deerma/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# flake8: noqa
from .airhumidifier_jsqs import AirHumidifierJsqs
from .airhumidifier_mjjsq import AirHumidifierMjjsq
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

import click

from .click_common import EnumType, command, format_output
from .device import Device, DeviceStatus
from .exceptions import DeviceException
from miio import Device, DeviceException, DeviceStatus
from miio.click_common import EnumType, command, format_output

_LOGGER = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

import pytest

from miio import AirHumidifierMjjsq
from miio.airhumidifier_mjjsq import (
from miio.tests.dummies import DummyDevice

from .. import AirHumidifierMjjsq
from ..airhumidifier_mjjsq import (
MODEL_HUMIDIFIER_JSQ1,
AirHumidifierException,
AirHumidifierStatus,
OperationMode,
)

from .dummies import DummyDevice


class DummyAirHumidifierMjjsq(DummyDevice, AirHumidifierMjjsq):
def __init__(self, *args, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions miio/integrations/humidifier/shuii/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# flake8: noqa
from .airhumidifier_jsq import AirHumidifierJsq
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@

import click

from .airhumidifier import AirHumidifierException
from .click_common import EnumType, command, format_output
from .device import Device, DeviceStatus
from miio import Device, DeviceException, DeviceStatus
from miio.click_common import EnumType, command, format_output

_LOGGER = logging.getLogger(__name__)


class AirHumidifierException(DeviceException):
pass


# Xiaomi Zero Fog Humidifier
MODEL_HUMIDIFIER_JSQ001 = "shuii.humidifier.jsq001"

Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

import pytest

from miio import AirHumidifierJsq
from miio.airhumidifier import AirHumidifierException
from miio.airhumidifier_jsq import (
from miio.tests.dummies import DummyDevice

from .. import AirHumidifierJsq
from ..airhumidifier_jsq import (
MODEL_HUMIDIFIER_JSQ001,
AirHumidifierException,
AirHumidifierStatus,
LedBrightness,
OperationMode,
)

from .dummies import DummyDevice


class DummyAirHumidifierJsq(DummyDevice, AirHumidifierJsq):
def __init__(self, *args, **kwargs):
Expand Down
3 changes: 3 additions & 0 deletions miio/integrations/humidifier/zhimi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# flake8: noqa
from .airhumidifier import AirHumidifier
from .airhumidifier_miot import AirHumidifierMiot
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

import click

from .click_common import EnumType, command, format_output
from .device import Device, DeviceInfo, DeviceStatus
from .exceptions import DeviceError, DeviceException
from miio import Device, DeviceError, DeviceException, DeviceInfo, DeviceStatus
from miio.click_common import EnumType, command, format_output

_LOGGER = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

import click

from .click_common import EnumType, command, format_output
from .exceptions import DeviceException
from .miot_device import DeviceStatus, MiotDevice
from miio import DeviceException, DeviceStatus, MiotDevice
from miio.click_common import EnumType, command, format_output

_LOGGER = logging.getLogger(__name__)

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import pytest

from miio import AirHumidifier, DeviceException
from miio.airhumidifier import (
from miio import DeviceException, DeviceInfo
from miio.tests.dummies import DummyDevice

from .. import AirHumidifier
from ..airhumidifier import (
MODEL_HUMIDIFIER_CA1,
MODEL_HUMIDIFIER_CB1,
MODEL_HUMIDIFIER_V1,
AirHumidifierException,
LedBrightness,
OperationMode,
)
from miio.device import DeviceInfo

from .dummies import DummyDevice


class DummyAirHumidifier(DummyDevice, AirHumidifier):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import pytest

from miio import AirHumidifierMiot
from miio.airhumidifier_miot import (
from miio.tests.dummies import DummyMiotDevice

from .. import AirHumidifierMiot
from ..airhumidifier_miot import (
AirHumidifierMiotException,
LedBrightness,
OperationMode,
PressedButton,
)

from .dummies import DummyMiotDevice

_INITIAL_STATE = {
"power": True,
"fault": 0,
Expand Down

0 comments on commit 67f7de9

Please sign in to comment.