Skip to content

Commit

Permalink
Deprecate roborock specific miio.Vacuum (#1191)
Browse files Browse the repository at this point in the history
* Fix module path for mirobo script

* Deprecate Vacuum in favor of RoborockVacuum for roborock vacuums

* Add miio.vacuum to maintain backwards compat, add deprecation warning
  • Loading branch information
rytilahti authored Nov 29, 2021
1 parent cb8ea87 commit 9f51bc4
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 62 deletions.
2 changes: 1 addition & 1 deletion miio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from miio.integrations.petwaterdispenser import PetWaterDispenser
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 import RoborockVacuum, Vacuum, VacuumException
from miio.integrations.vacuum.roborock.vacuumcontainers import (
CleaningDetails,
CleaningSummary,
Expand Down
2 changes: 1 addition & 1 deletion miio/integrations/vacuum/roborock/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# flake8: noqa
from .vacuum import Vacuum, VacuumException, VacuumStatus
from .vacuum import RoborockVacuum, Vacuum, VacuumException, VacuumStatus
12 changes: 10 additions & 2 deletions miio/integrations/vacuum/roborock/tests/test_vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

import pytest

from miio import Vacuum, VacuumStatus
from miio import RoborockVacuum, Vacuum, VacuumStatus
from miio.tests.dummies import DummyDevice

from ..vacuum import CarpetCleaningMode, MopMode


class DummyVacuum(DummyDevice, Vacuum):
class DummyVacuum(DummyDevice, RoborockVacuum):
STATE_CHARGING = 8
STATE_CLEANING = 5
STATE_ZONED_CLEAN = 9
Expand Down Expand Up @@ -311,3 +311,11 @@ def test_mop_mode(self):

with patch.object(self.device, "send", return_value=[32453]):
assert self.device.mop_mode() is None


def test_deprecated_vacuum(caplog):
with pytest.deprecated_call():
Vacuum("127.1.1.1", "68ffffffffffffffffffffffffffffff")

with pytest.deprecated_call():
from miio.vacuum import ROCKROBO_S6 # noqa: F401
15 changes: 13 additions & 2 deletions miio/integrations/vacuum/roborock/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
)
from miio.device import Device, DeviceInfo
from miio.exceptions import DeviceException, DeviceInfoUnavailableException
from miio.utils import deprecated

from .vacuumcontainers import (
CarpetModeStatus,
Expand Down Expand Up @@ -146,8 +147,8 @@ class CarpetCleaningMode(enum.Enum):
]


class Vacuum(Device):
"""Main class representing the vacuum."""
class RoborockVacuum(Device):
"""Main class for roborock vacuums (roborock.vacuum.*)."""

_supported_models = SUPPORTED_MODELS

Expand Down Expand Up @@ -892,3 +893,13 @@ def cleanup(vac: Vacuum, *args, **kwargs):
json.dump(seqs, f)

return dg


class Vacuum(RoborockVacuum):
"""Main class for roborock vacuums."""

@deprecated(
"This class will become the base class for all vacuum implementations. Use RoborockVacuum to control roborock vacuums."
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Loading

0 comments on commit 9f51bc4

Please sign in to comment.