@@ -131,6 +131,16 @@ class CarpetCleaningMode(enum.Enum):
131131 Ignore = 2
132132
133133
134+ class DustCollectionMode (enum .Enum ):
135+ """Auto emptying mode (S7 only)"""
136+
137+ Smart = 0
138+ Quick = 1
139+ Daily = 2
140+ Strong = 3
141+ Max = 4
142+
143+
134144ROCKROBO_V1 = "rockrobo.vacuum.v1"
135145ROCKROBO_S4 = "roborock.vacuum.s4"
136146ROCKROBO_S4_MAX = "roborock.vacuum.a19"
@@ -171,11 +181,16 @@ class CarpetCleaningMode(enum.Enum):
171181 ROCKROBO_C1 ,
172182]
173183
184+ AUTO_EMPTY_MODELS = [
185+ ROCKROBO_S7 ,
186+ ]
187+
174188
175189class RoborockVacuum (Device , VacuumInterface ):
176190 """Main class for roborock vacuums (roborock.vacuum.*)."""
177191
178192 _supported_models = SUPPORTED_MODELS
193+ _auto_empty_models = AUTO_EMPTY_MODELS
179194
180195 def __init__ (
181196 self ,
@@ -802,6 +817,47 @@ def set_carpet_cleaning_mode(self, mode: CarpetCleaningMode):
802817 == "ok"
803818 )
804819
820+ @command ()
821+ def dust_collection_mode (self ) -> Optional [DustCollectionMode ]:
822+ """Get the dust collection mode setting."""
823+ self ._verify_auto_empty_support ()
824+ try :
825+ return DustCollectionMode (self .send ("get_dust_collection_mode" )["mode" ])
826+ except Exception as err :
827+ _LOGGER .warning ("Error while requesting dust collection mode: %s" , err )
828+ return None
829+
830+ @command (click .argument ("enabled" , required = True , type = bool ))
831+ def set_dust_collection (self , enabled : bool ) -> bool :
832+ """Turn automatic dust collection on or off."""
833+ self ._verify_auto_empty_support ()
834+ return (
835+ self .send ("set_dust_collection_switch_status" , {"status" : int (enabled )})[0 ]
836+ == "ok"
837+ )
838+
839+ @command (click .argument ("mode" , required = True , type = EnumType (DustCollectionMode )))
840+ def set_dust_collection_mode (self , mode : DustCollectionMode ) -> bool :
841+ """Set dust collection mode setting."""
842+ self ._verify_auto_empty_support ()
843+ return self .send ("set_dust_collection_mode" , {"mode" : mode .value })[0 ] == "ok"
844+
845+ @command ()
846+ def start_dust_collection (self ):
847+ """Activate automatic dust collection."""
848+ self ._verify_auto_empty_support ()
849+ return self .send ("app_start_collect_dust" )
850+
851+ @command ()
852+ def stop_dust_collection (self ):
853+ """Abort in progress dust collection."""
854+ self ._verify_auto_empty_support ()
855+ return self .send ("app_stop_collect_dust" )
856+
857+ def _verify_auto_empty_support (self ) -> None :
858+ if self .model not in self ._auto_empty_models :
859+ raise VacuumException ("Device does not support auto emptying" )
860+
805861 @command ()
806862 def stop_zoned_clean (self ):
807863 """Stop cleaning a zone."""
0 commit comments