Skip to content

Commit

Permalink
roborock: auto empty dustbin support
Browse files Browse the repository at this point in the history
addresses #1107
  • Loading branch information
craigcabrey committed Nov 28, 2021
1 parent a577fe9 commit 9aedc53
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 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 Down Expand Up @@ -746,6 +756,49 @@ def set_carpet_cleaning_mode(self, mode: CarpetCleaningMode):
== "ok"
)

@command()
def enable_dust_collection(self):
"""Enable automatic dust collection."""
return (
self.send("set_dust_collection_switch_status", {"status": 1})[0]
== "ok"
)

@command()
def disable_dust_collection(self):
"""Disable automatic dust collection."""
return (
self.send("set_dust_collection_switch_status", {"status": 0})[0]
== "ok"
)

@command()
def dust_collection_mode(self) -> Optional[DustCollectionMode]:
"""Get the dust collection mode setting."""
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("mode", type=EnumType(DustCollectionMode)))
def set_dust_collection_mode(self, mode: DustCollectionMode) -> bool:
"""Set dust collection mode setting."""
return (
self.send("set_dust_collection_mode", {"mode": mode.value})[0]
== "ok"
)

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

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

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

0 comments on commit 9aedc53

Please sign in to comment.