@@ -345,7 +345,6 @@ class Status(RoborockBase):
345345 battery : int | None = None
346346 clean_time : int | None = None
347347 clean_area : int | None = None
348- square_meter_clean_area : float | None = None
349348 error_code : RoborockErrorCode | None = None
350349 map_present : int | None = None
351350 in_cleaning : RoborockInCleaning | None = None
@@ -392,26 +391,36 @@ class Status(RoborockBase):
392391 dss : int | None = None
393392 common_status : int | None = None
394393 corner_clean_mode : int | None = None
395- error_code_name : str | None = None
396- state_name : str | None = None
397- water_box_mode_name : str | None = None
398- fan_power_options : list [str ] = field (default_factory = list )
399- fan_power_name : str | None = None
400- mop_mode_name : str | None = None
401-
402- def __post_init__ (self ) -> None :
403- self .square_meter_clean_area = round (self .clean_area / 1000000 , 1 ) if self .clean_area is not None else None
404- if self .error_code is not None :
405- self .error_code_name = self .error_code .name
406- if self .state is not None :
407- self .state_name = self .state .name
408- if self .water_box_mode is not None :
409- self .water_box_mode_name = self .water_box_mode .name
410- if self .fan_power is not None :
411- self .fan_power_options = self .fan_power .keys ()
412- self .fan_power_name = self .fan_power .name
413- if self .mop_mode is not None :
414- self .mop_mode_name = self .mop_mode .name
394+
395+ @property
396+ def square_meter_clean_area (self ) -> float | None :
397+ return round (self .clean_area / 1000000 , 1 ) if self .clean_area is not None else None
398+
399+ @property
400+ def error_code_name (self ) -> str | None :
401+ return self .error_code .name if self .error_code else None
402+
403+ @property
404+ def state_name (self ) -> str | None :
405+ return self .state .name if self .state else None
406+
407+ @property
408+ def water_box_mode_name (self ) -> str | None :
409+ return self .water_box_mode .name if self .water_box_mode else None
410+
411+ @property
412+ def fan_power_options (self ) -> list [str ]:
413+ if self .fan_power is None :
414+ return []
415+ return list (self .fan_power .keys ())
416+
417+ @property
418+ def fan_power_name (self ) -> str | None :
419+ return self .fan_power .name if self .fan_power else None
420+
421+ @property
422+ def mop_mode_name (self ) -> str | None :
423+ return self .mop_mode .name if self .mop_mode else None
415424
416425 def get_fan_speed_code (self , fan_speed : str ) -> int :
417426 if self .fan_power is None :
@@ -585,28 +594,26 @@ class ValleyElectricityTimer(RoborockBaseTimer):
585594class CleanSummary (RoborockBase ):
586595 clean_time : int | None = None
587596 clean_area : int | None = None
588- square_meter_clean_area : float | None = None
589597 clean_count : int | None = None
590598 dust_collection_count : int | None = None
591599 records : list [int ] | None = None
592600 last_clean_t : int | None = None
593601
594- def __post_init__ (self ) -> None :
602+ @property
603+ def square_meter_clean_area (self ) -> float | None :
604+ """Returns the clean area in square meters."""
595605 if isinstance (self .clean_area , list | str ):
596606 _LOGGER .warning (f"Clean area is a unexpected type! Please give the following in a issue: { self .clean_area } " )
597- else :
598- self . square_meter_clean_area = round (self .clean_area / 1000000 , 1 ) if self .clean_area is not None else None
607+ return None
608+ return round (self .clean_area / 1000000 , 1 ) if self .clean_area is not None else None
599609
600610
601611@dataclass
602612class CleanRecord (RoborockBase ):
603613 begin : int | None = None
604- begin_datetime : datetime .datetime | None = None
605614 end : int | None = None
606- end_datetime : datetime .datetime | None = None
607615 duration : int | None = None
608616 area : int | None = None
609- square_meter_area : float | None = None
610617 error : int | None = None
611618 complete : int | None = None
612619 start_type : RoborockStartType | None = None
@@ -617,12 +624,17 @@ class CleanRecord(RoborockBase):
617624 wash_count : int | None = None
618625 map_flag : int | None = None
619626
620- def __post_init__ (self ) -> None :
621- self .square_meter_area = round (self .area / 1000000 , 1 ) if self .area is not None else None
622- self .begin_datetime = (
623- datetime .datetime .fromtimestamp (self .begin ).astimezone (timezone .utc ) if self .begin else None
624- )
625- self .end_datetime = datetime .datetime .fromtimestamp (self .end ).astimezone (timezone .utc ) if self .end else None
627+ @property
628+ def sqaure_meter_area (self ) -> float | None :
629+ return round (self .area / 1000000 , 1 ) if self .area is not None else None
630+
631+ @property
632+ def begin_datetime (self ) -> datetime .datetime | None :
633+ return datetime .datetime .fromtimestamp (self .begin ).astimezone (timezone .utc ) if self .begin else None
634+
635+ @property
636+ def end_datetime (self ) -> datetime .datetime | None :
637+ return datetime .datetime .fromtimestamp (self .end ).astimezone (timezone .utc ) if self .end else None
626638
627639
628640@dataclass
@@ -636,44 +648,46 @@ class Consumable(RoborockBase):
636648 dust_collection_work_times : int | None = None
637649 cleaning_brush_work_times : int | None = None
638650 moproller_work_time : int | None = None
639- main_brush_time_left : int | None = None
640- side_brush_time_left : int | None = None
641- filter_time_left : int | None = None
642- sensor_time_left : int | None = None
643- strainer_time_left : int | None = None
644- dust_collection_time_left : int | None = None
645- cleaning_brush_time_left : int | None = None
646- mop_roller_time_left : int | None = None
647-
648- def __post_init__ (self ) -> None :
649- self .main_brush_time_left = (
650- MAIN_BRUSH_REPLACE_TIME - self .main_brush_work_time if self .main_brush_work_time is not None else None
651- )
652- self .side_brush_time_left = (
653- SIDE_BRUSH_REPLACE_TIME - self .side_brush_work_time if self .side_brush_work_time is not None else None
654- )
655- self .filter_time_left = (
656- FILTER_REPLACE_TIME - self .filter_work_time if self .filter_work_time is not None else None
657- )
658- self .sensor_time_left = (
659- SENSOR_DIRTY_REPLACE_TIME - self .sensor_dirty_time if self .sensor_dirty_time is not None else None
660- )
661- self .strainer_time_left = (
662- STRAINER_REPLACE_TIME - self .strainer_work_times if self .strainer_work_times is not None else None
663- )
664- self .dust_collection_time_left = (
651+
652+ @property
653+ def main_brush_time_left (self ) -> int | None :
654+ return MAIN_BRUSH_REPLACE_TIME - self .main_brush_work_time if self .main_brush_work_time is not None else None
655+
656+ @property
657+ def side_brush_time_left (self ) -> int | None :
658+ return SIDE_BRUSH_REPLACE_TIME - self .side_brush_work_time if self .side_brush_work_time is not None else None
659+
660+ @property
661+ def filter_time_left (self ) -> int | None :
662+ return FILTER_REPLACE_TIME - self .filter_work_time if self .filter_work_time is not None else None
663+
664+ @property
665+ def sensor_time_left (self ) -> int | None :
666+ return SENSOR_DIRTY_REPLACE_TIME - self .sensor_dirty_time if self .sensor_dirty_time is not None else None
667+
668+ @property
669+ def strainer_time_left (self ) -> int | None :
670+ return STRAINER_REPLACE_TIME - self .strainer_work_times if self .strainer_work_times is not None else None
671+
672+ @property
673+ def dust_collection_time_left (self ) -> int | None :
674+ return (
665675 DUST_COLLECTION_REPLACE_TIME - self .dust_collection_work_times
666676 if self .dust_collection_work_times is not None
667677 else None
668678 )
669- self .cleaning_brush_time_left = (
679+
680+ @property
681+ def cleaning_brush_time_left (self ) -> int | None :
682+ return (
670683 CLEANING_BRUSH_REPLACE_TIME - self .cleaning_brush_work_times
671684 if self .cleaning_brush_work_times is not None
672685 else None
673686 )
674- self .mop_roller_time_left = (
675- MOP_ROLLER_REPLACE_TIME - self .moproller_work_time if self .moproller_work_time is not None else None
676- )
687+
688+ @property
689+ def mop_roller_time_left (self ) -> int | None :
690+ return MOP_ROLLER_REPLACE_TIME - self .moproller_work_time if self .moproller_work_time is not None else None
677691
678692
679693@dataclass
@@ -757,11 +771,11 @@ class DeviceData(RoborockBase):
757771 device : HomeDataDevice
758772 model : str
759773 host : str | None = None
760- product_nickname : RoborockProductNickname | None = None
761774 device_features : DeviceFeatures | None = None
762775
763- def __post_init__ (self ):
764- self .product_nickname = SHORT_MODEL_TO_ENUM .get (self .model .split ("." )[- 1 ], RoborockProductNickname .PEARLPLUS )
776+ @property
777+ def product_nickname (self ) -> RoborockProductNickname :
778+ return SHORT_MODEL_TO_ENUM .get (self .model .split ("." )[- 1 ], RoborockProductNickname .PEARLPLUS )
765779
766780
767781@dataclass
@@ -846,11 +860,12 @@ class RoborockProduct(RoborockBase):
846860 agreements : list | None = None
847861 cardspec : str | None = None
848862 plugin_pic_url : str | None = None
849- products_specification : RoborockProductSpec | None = None
850863
851- def __post_init__ (self ):
864+ @property
865+ def product_nickname (self ) -> RoborockProductNickname | None :
852866 if self .cardspec :
853- self .products_specification = RoborockProductSpec .from_dict (json .loads (self .cardspec ).get ("data" ))
867+ return RoborockProductSpec .from_dict (json .loads (self .cardspec ).get ("data" ))
868+ return None
854869
855870
856871@dataclass
0 commit comments