Skip to content

Commit

Permalink
Move vacuums to self-contained integrations (#1165)
Browse files Browse the repository at this point in the history
* Move vacuum and its files into its own package (integrations.roborock)

* Adjust absolute paths for vacuumcontainer dependents

* Move roborock to be under vacuum subdirectory

* Move vacuum implementations under miio.integrations.vacuum

* Move g1vacuum aka mijia to vacuum integrations

* Fix incorrect imports for mijia
  • Loading branch information
rytilahti authored Nov 1, 2021
1 parent e1adea5 commit a19104b
Show file tree
Hide file tree
Showing 23 changed files with 54 additions and 45 deletions.
27 changes: 13 additions & 14 deletions miio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,27 @@
from miio.cooker import Cooker
from miio.curtain_youpin import CurtainMiot
from miio.device import Device, DeviceStatus
from miio.dreamevacuum_miot import DreameVacuumMiot
from miio.exceptions import DeviceError, DeviceException
from miio.fan import Fan, FanP5, FanSA1, FanV2, FanZA1, FanZA4
from miio.fan_leshow import FanLeshow
from miio.fan_miot import Fan1C, FanMiot, FanP9, FanP10, FanP11, FanZA5
from miio.g1vacuum import G1Vacuum
from miio.gateway import Gateway
from miio.heater import Heater
from miio.heater_miot import HeaterMiot
from miio.huizuo import Huizuo, HuizuoLampFan, HuizuoLampHeater, HuizuoLampScene
from miio.integrations.vacuum.dreame.dreamevacuum_miot import DreameVacuumMiot
from miio.integrations.vacuum.mijia import G1Vacuum
from miio.integrations.vacuum.roborock import Vacuum, VacuumException
from miio.integrations.vacuum.roborock.vacuumcontainers import (
CleaningDetails,
CleaningSummary,
ConsumableStatus,
DNDStatus,
Timer,
VacuumStatus,
)
from miio.integrations.vacuum.roidmi.roidmivacuum_miot import RoidmiVacuumMiot
from miio.integrations.vacuum.viomi.viomivacuum import ViomiVacuum
from miio.integrations.yeelight import Yeelight
from miio.miot_device import MiotDevice
from miio.philips_bulb import PhilipsBulb, PhilipsWhiteBulb
Expand All @@ -51,20 +62,8 @@
from miio.powerstrip import PowerStrip
from miio.protocol import Message, Utils
from miio.pwzn_relay import PwznRelay
from miio.roidmivacuum_miot import RoidmiVacuumMiot
from miio.scishare_coffeemaker import ScishareCoffee
from miio.toiletlid import Toiletlid
from miio.vacuum import Vacuum, VacuumException
from miio.vacuum_tui import VacuumTUI
from miio.vacuumcontainers import (
CleaningDetails,
CleaningSummary,
ConsumableStatus,
DNDStatus,
Timer,
VacuumStatus,
)
from miio.viomivacuum import ViomiVacuum
from miio.walkingpad import Walkingpad
from miio.waterpurifier import WaterPurifier
from miio.waterpurifier_yunmi import WaterPurifierYunmi
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import logging
from enum import Enum

from .click_common import command, format_output
from .miot_device import DeviceStatus as DeviceStatusContainer
from .miot_device import MiotDevice, MiotMapping
from miio.click_common import command, format_output
from miio.miot_device import DeviceStatus as DeviceStatusContainer
from miio.miot_device import MiotDevice, MiotMapping

_LOGGER = logging.getLogger(__name__)

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

from miio import DreameVacuumMiot
from miio.dreamevacuum_miot import (
from miio.tests.dummies import DummyMiotDevice

from ..dreamevacuum_miot import (
ChargingState,
CleaningMode,
DeviceStatus,
FaultStatus,
OperatingMode,
)

from .dummies import DummyMiotDevice

_INITIAL_STATE = {
"battery_level": 42,
"charging_state": ChargingState.Charging,
Expand Down
2 changes: 2 additions & 0 deletions miio/integrations/vacuum/mijia/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# flake8: noqa
from .g1vacuum import G1Vacuum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import click

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

_LOGGER = logging.getLogger(__name__)
MIJIA_VACUUM_V1 = "mijia.vacuum.v1"
Expand Down
Empty file.
2 changes: 2 additions & 0 deletions miio/integrations/vacuum/roborock/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# flake8: noqa
from .vacuum import Vacuum, VacuumException, VacuumStatus
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import pytest

from miio import Vacuum, VacuumStatus
from miio.vacuum import CarpetCleaningMode, MopMode
from miio.tests.dummies import DummyDevice

from .dummies import DummyDevice
from ..vacuum import CarpetCleaningMode, MopMode


class DummyVacuum(DummyDevice, Vacuum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
import pytz
from appdirs import user_cache_dir

from .click_common import (
from miio.click_common import (
DeviceGroup,
EnumType,
GlobalContextObject,
LiteralParamType,
command,
)
from .device import Device, DeviceInfo
from .exceptions import DeviceException, DeviceInfoUnavailableException
from miio.device import Device, DeviceInfo
from miio.exceptions import DeviceException, DeviceInfoUnavailableException

from .vacuumcontainers import (
CarpetModeStatus,
CleaningDetails,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
from miio.exceptions import DeviceInfoUnavailableException
from miio.miioprotocol import MiIOProtocol
from miio.updater import OneShotServer
from miio.vacuum import CarpetCleaningMode

from .vacuum import CarpetCleaningMode
from .vacuum_tui import VacuumTUI

_LOGGER = logging.getLogger(__name__)
pass_dev = click.make_pass_decorator(miio.Device, ensure=True)
Expand Down Expand Up @@ -240,7 +242,7 @@ def manual(vac: miio.Vacuum):
@pass_dev
def tui(vac: miio.Vacuum):
"""TUI for the manual mode."""
miio.VacuumTUI(vac).run()
VacuumTUI(vac).run()


@manual.command(name="start")
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from croniter import croniter

from .device import DeviceStatus
from .utils import pretty_seconds, pretty_time
from miio.device import DeviceStatus
from miio.utils import pretty_seconds, pretty_time


def pretty_area(x: float) -> float:
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import click

from .click_common import EnumType, command
from .miot_device import DeviceStatus, MiotDevice, MiotMapping
from .vacuumcontainers import DNDStatus
from miio.click_common import EnumType, command
from miio.integrations.vacuum.roborock.vacuumcontainers import DNDStatus
from miio.miot_device import DeviceStatus, MiotDevice, MiotMapping

_LOGGER = logging.getLogger(__name__)

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

import pytest

from miio import RoidmiVacuumMiot
from miio.roidmivacuum_miot import (
from miio.integrations.vacuum.roborock.vacuumcontainers import DNDStatus
from miio.tests.dummies import DummyMiotDevice

from ..roidmivacuum_miot import (
ChargingState,
FanSpeed,
PathMode,
RoidmiState,
RoidmiVacuumMiot,
SweepMode,
SweepType,
WaterLevel,
)
from miio.vacuumcontainers import DNDStatus

from .dummies import DummyMiotDevice

_INITIAL_STATE = {
"auto_boost": 1,
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@

import click

from .click_common import EnumType, command, format_output
from .device import Device, DeviceStatus
from .exceptions import DeviceException
from .utils import pretty_seconds
from .vacuumcontainers import ConsumableStatus, DNDStatus
from miio.click_common import EnumType, command, format_output
from miio.device import Device, DeviceStatus
from miio.exceptions import DeviceException
from miio.integrations.vacuum.roborock.vacuumcontainers import (
ConsumableStatus,
DNDStatus,
)
from miio.utils import pretty_seconds

_LOGGER = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ packages = [
keywords = ["xiaomi", "miio", "miot", "smart home"]

[tool.poetry.scripts]
mirobo = "miio.vacuum_cli:cli"
mirobo = "miio.integrations.roborock.vacuum_cli:cli"
miio-extract-tokens = "miio.extract_tokens:main"
miiocli = "miio.cli:create_cli"

Expand Down

0 comments on commit a19104b

Please sign in to comment.