1010from functools import cached_property
1111from typing import Any , NamedTuple , get_args , get_origin
1212
13+ from .clean_modes import (
14+ CleanRoutes ,
15+ VacuumModes ,
16+ VacuumModesOld ,
17+ WaterModes ,
18+ get_clean_modes ,
19+ get_clean_routes ,
20+ get_water_modes ,
21+ )
1322from .code_mappings import (
1423 SHORT_MODEL_TO_ENUM ,
1524 RoborockCategory ,
1928 RoborockDockTypeCode ,
2029 RoborockDockWashTowelModeCode ,
2130 RoborockErrorCode ,
22- RoborockFanPowerCode ,
2331 RoborockFanSpeedP10 ,
2432 RoborockFanSpeedQ7Max ,
2533 RoborockFanSpeedQRevoCurv ,
3442 RoborockFinishReason ,
3543 RoborockInCleaning ,
3644 RoborockModeEnum ,
37- RoborockMopIntensityCode ,
3845 RoborockMopIntensityP10 ,
3946 RoborockMopIntensityQ7Max ,
4047 RoborockMopIntensityQRevoCurv ,
4653 RoborockMopIntensityS8MaxVUltra ,
4754 RoborockMopIntensitySaros10 ,
4855 RoborockMopIntensitySaros10R ,
49- RoborockMopModeCode ,
5056 RoborockMopModeQRevoCurv ,
5157 RoborockMopModeQRevoMaster ,
5258 RoborockMopModeQRevoMaxV ,
9298 ROBOROCK_G20S_Ultra ,
9399)
94100from .device_features import DeviceFeatures
95- from .exceptions import RoborockException
96101
97102_LOGGER = logging .getLogger (__name__ )
98103
@@ -357,12 +362,12 @@ class Status(RoborockBase):
357362 back_type : int | None = None
358363 wash_phase : int | None = None
359364 wash_ready : int | None = None
360- fan_power : RoborockFanPowerCode | None = None
365+ fan_power : int | None = None
361366 dnd_enabled : int | None = None
362367 map_status : int | None = None
363368 is_locating : int | None = None
364369 lock_status : int | None = None
365- water_box_mode : RoborockMopIntensityCode | None = None
370+ water_box_mode : int | None = None
366371 water_box_carriage_status : int | None = None
367372 mop_forbidden_enable : int | None = None
368373 camera_status : int | None = None
@@ -375,7 +380,7 @@ class Status(RoborockBase):
375380 dust_collection_status : int | None = None
376381 auto_dust_collection : int | None = None
377382 avoid_count : int | None = None
378- mop_mode : RoborockMopModeCode | None = None
383+ mop_mode : int | None = None
379384 debug_mode : int | None = None
380385 collision_avoid_status : int | None = None
381386 switch_map_mode : int | None = None
@@ -406,28 +411,6 @@ def __post_init__(self) -> None:
406411 self .error_code_name = self .error_code .name
407412 if self .state is not None :
408413 self .state_name = self .state .name
409- if self .water_box_mode is not None :
410- self .water_box_mode_name = self .water_box_mode .name
411- if self .fan_power is not None :
412- self .fan_power_options = self .fan_power .keys ()
413- self .fan_power_name = self .fan_power .name
414- if self .mop_mode is not None :
415- self .mop_mode_name = self .mop_mode .name
416-
417- def get_fan_speed_code (self , fan_speed : str ) -> int :
418- if self .fan_power is None :
419- raise RoborockException ("Attempted to get fan speed before status has been updated." )
420- return self .fan_power .as_dict ().get (fan_speed )
421-
422- def get_mop_intensity_code (self , mop_intensity : str ) -> int :
423- if self .water_box_mode is None :
424- raise RoborockException ("Attempted to get mop_intensity before status has been updated." )
425- return self .water_box_mode .as_dict ().get (mop_intensity )
426-
427- def get_mop_mode_code (self , mop_mode : str ) -> int :
428- if self .mop_mode is None :
429- raise RoborockException ("Attempted to get mop_mode before status has been updated." )
430- return self .mop_mode .as_dict ().get (mop_mode )
431414
432415 @property
433416 def current_map (self ) -> int | None :
@@ -574,6 +557,34 @@ class Saros10Status(Status):
574557}
575558
576559
560+ def get_custom_status (features : DeviceFeatures , region : str ) -> "DeviceStatus" :
561+ _available_fan_speeds = get_clean_modes (features )
562+ _available_fan_speed_mapping = {fan .code : fan .name for fan in _available_fan_speeds }
563+ _available_water_modes = get_water_modes (features )
564+ _available_water_modes_mapping = {mop .code : mop .name for mop in _available_water_modes }
565+ _available_mop_routes = get_clean_routes (features , region )
566+ _available_mop_routes_mapping = {route .code : route .name for route in _available_mop_routes }
567+
568+ class DeviceStatus (Status ):
569+ available_fan_speeds : list [VacuumModes ] | list [VacuumModesOld ] = _available_fan_speeds
570+ available_water_modes : list [WaterModes ] = _available_water_modes
571+ available_mop_routes : list [CleanRoutes ] = _available_mop_routes
572+
573+ @property
574+ def fan_speed (self ) -> VacuumModes | None :
575+ return _available_fan_speed_mapping .get (self .fan_power )
576+
577+ @property
578+ def water_mode (self ) -> WaterModes | None :
579+ return _available_water_modes_mapping .get (self .water_box_mode )
580+
581+ @property
582+ def mop_route (self ) -> CleanRoutes | None :
583+ return _available_mop_routes_mapping .get (self .mop_mode )
584+
585+ return DeviceStatus
586+
587+
577588@dataclass
578589class DnDTimer (RoborockBaseTimer ):
579590 """DnDTimer"""
@@ -762,6 +773,7 @@ class DeviceData(RoborockBase):
762773 host : str | None = None
763774 product_nickname : RoborockProductNickname | None = None
764775 device_features : DeviceFeatures | None = None
776+ region : str | None = None
765777
766778 def __post_init__ (self ):
767779 self .product_nickname = SHORT_MODEL_TO_ENUM .get (self .model .split ("." )[- 1 ], RoborockProductNickname .PEARLPLUS )
0 commit comments