Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/device_docs/vacuum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ for original firmwares.

This feature works similarly to the sound updates,
so passing a local file will create a self-hosting server
and updating from an URL requires you to pass the md5 hash of the file.
and updating from an URL requires you to pass the md5 hash of the file.

::

Expand Down
56 changes: 56 additions & 0 deletions miio/integrations/vacuum/roborock/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ class CarpetCleaningMode(enum.Enum):
Ignore = 2


class DustCollectionMode(enum.Enum):
"""Auto emptying mode (S7 only)"""

Smart = 0
Quick = 1
Daily = 2
Strong = 3
Max = 4


ROCKROBO_V1 = "rockrobo.vacuum.v1"
ROCKROBO_S5 = "roborock.vacuum.s5"
ROCKROBO_S5_MAX = "roborock.vacuum.s5e"
Expand All @@ -139,11 +149,16 @@ class CarpetCleaningMode(enum.Enum):
ROCKROBO_E2,
]

AUTO_EMPTY_MODELS = [
ROCKROBO_S7,
]


class Vacuum(Device):
"""Main class representing the vacuum."""

_supported_models = SUPPORTED_MODELS
_auto_empty_models = AUTO_EMPTY_MODELS

def __init__(
self,
Expand Down Expand Up @@ -746,6 +761,47 @@ def set_carpet_cleaning_mode(self, mode: CarpetCleaningMode):
== "ok"
)

@command()
def dust_collection_mode(self) -> Optional[DustCollectionMode]:
"""Get the dust collection mode setting."""
self._verify_auto_empty_support()
try:
return DustCollectionMode(self.send("get_dust_collection_mode")["mode"])
except Exception as err:
_LOGGER.warning("Error while requesting dust collection mode: %s", err)
return None

@command(click.argument("enabled", required=True, type=bool))
def set_dust_collection(self, enabled: bool) -> bool:
"""Turn automatic dust collection on or off."""
self._verify_auto_empty_support()
return (
self.send("set_dust_collection_switch_status", {"status": int(enabled)})[0]
== "ok"
)

@command(click.argument("mode", required=True, type=EnumType(DustCollectionMode)))
def set_dust_collection_mode(self, mode: DustCollectionMode) -> bool:
"""Set dust collection mode setting."""
self._verify_auto_empty_support()
return self.send("set_dust_collection_mode", {"mode": mode.value})[0] == "ok"

@command()
def start_dust_collection(self):
"""Activate automatic dust collection."""
self._verify_auto_empty_support()
return self.send("app_start_collect_dust")

@command()
def stop_dust_collection(self):
"""Abort in progress dust collection."""
self._verify_auto_empty_support()
return self.send("app_stop_collect_dust")

def _verify_auto_empty_support(self) -> None:
if self.model not in self._auto_empty_models:
raise VacuumException("Device does not support auto emptying")

@command()
def stop_zoned_clean(self):
"""Stop cleaning a zone."""
Expand Down