@@ -197,6 +197,24 @@ async def get_clean_record(self, record_id: int) -> CleanRecord | None:
197197 if isinstance (record , dict ):
198198 return CleanRecord .from_dict (record )
199199 elif isinstance (record , list ):
200+ if isinstance (record [- 1 ], dict ):
201+ records = [CleanRecord .from_dict (rec ) for rec in record ]
202+ final_record = records [- 1 ]
203+ try :
204+ # This code is semi-presumptions - so it is put in a try finally to be safe.
205+ final_record .begin = records [0 ].begin
206+ final_record .begin_datetime = records [0 ].begin_datetime
207+ final_record .start_type = records [0 ].start_type
208+ for rec in records [0 :- 1 ]:
209+ final_record .duration += rec .duration if rec .duration is not None else 0
210+ final_record .area += rec .area if rec .area is not None else 0
211+ final_record .avoid_count += rec .avoid_count if rec .avoid_count is not None else 0
212+ final_record .wash_count += rec .wash_count if rec .wash_count is not None else 0
213+ final_record .square_meter_area += (
214+ rec .square_meter_area if rec .square_meter_area is not None else 0
215+ )
216+ finally :
217+ return final_record
200218 # There are still a few unknown variables in this.
201219 begin , end , duration , area = unpack_list (record , 4 )
202220 return CleanRecord (begin = begin , end = end , duration = duration , area = area )
@@ -277,7 +295,7 @@ async def get_room_mapping(self) -> list[RoomMapping] | None:
277295 """Gets the mapping from segment id -> iot id. Only works on local api."""
278296 mapping : list = await self .send_command (RoborockCommand .GET_ROOM_MAPPING )
279297 if isinstance (mapping , list ):
280- if not isinstance (mapping [0 ], list ) and len ( mapping ) == 2 :
298+ if len ( mapping ) == 2 and not isinstance (mapping [0 ], list ):
281299 return [RoomMapping (segment_id = mapping [0 ], iot_id = mapping [1 ])]
282300 return [
283301 RoomMapping (segment_id = segment_id , iot_id = iot_id ) # type: ignore
0 commit comments