forked from Python-roborock/python-roborock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv1_containers.py
More file actions
814 lines (671 loc) · 25.7 KB
/
v1_containers.py
File metadata and controls
814 lines (671 loc) · 25.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
import datetime
import logging
from dataclasses import dataclass, field
from enum import StrEnum
from typing import Any
from roborock.const import (
CLEANING_BRUSH_REPLACE_TIME,
DUST_COLLECTION_REPLACE_TIME,
FILTER_REPLACE_TIME,
MAIN_BRUSH_REPLACE_TIME,
MOP_ROLLER_REPLACE_TIME,
NO_MAP,
ROBOROCK_G10S_PRO,
ROBOROCK_P10,
ROBOROCK_Q7_MAX,
ROBOROCK_QREVO_CURV,
ROBOROCK_QREVO_MASTER,
ROBOROCK_QREVO_MAXV,
ROBOROCK_QREVO_PRO,
ROBOROCK_QREVO_S,
ROBOROCK_S4_MAX,
ROBOROCK_S5_MAX,
ROBOROCK_S6,
ROBOROCK_S6_MAXV,
ROBOROCK_S6_PURE,
ROBOROCK_S7,
ROBOROCK_S7_MAXV,
ROBOROCK_S8,
ROBOROCK_S8_MAXV_ULTRA,
ROBOROCK_S8_PRO_ULTRA,
ROBOROCK_SAROS_10,
ROBOROCK_SAROS_10R,
SENSOR_DIRTY_REPLACE_TIME,
SIDE_BRUSH_REPLACE_TIME,
STRAINER_REPLACE_TIME,
ROBOROCK_G20S_Ultra,
)
from roborock.exceptions import RoborockException
from roborock.roborock_message import RoborockDataProtocol
from ..containers import NamedRoomMapping, RoborockBase, RoborockBaseTimer, _attr_repr
from .v1_clean_modes import WashTowelModes
from .v1_code_mappings import (
CleanFluidStatus,
ClearWaterBoxStatus,
DirtyWaterBoxStatus,
DustBagStatus,
RoborockCleanType,
RoborockDockDustCollectionModeCode,
RoborockDockErrorCode,
RoborockDockTypeCode,
RoborockErrorCode,
RoborockFanPowerCode,
RoborockFanSpeedP10,
RoborockFanSpeedQ7Max,
RoborockFanSpeedQRevoCurv,
RoborockFanSpeedQRevoMaster,
RoborockFanSpeedQRevoMaxV,
RoborockFanSpeedS6Pure,
RoborockFanSpeedS7,
RoborockFanSpeedS7MaxV,
RoborockFanSpeedS8MaxVUltra,
RoborockFanSpeedSaros10,
RoborockFanSpeedSaros10R,
RoborockFinishReason,
RoborockInCleaning,
RoborockMopIntensityCode,
RoborockMopIntensityP10,
RoborockMopIntensityQ7Max,
RoborockMopIntensityQRevoCurv,
RoborockMopIntensityQRevoMaster,
RoborockMopIntensityQRevoMaxV,
RoborockMopIntensityS5Max,
RoborockMopIntensityS6MaxV,
RoborockMopIntensityS7,
RoborockMopIntensityS8MaxVUltra,
RoborockMopIntensitySaros10,
RoborockMopIntensitySaros10R,
RoborockMopModeCode,
RoborockMopModeQRevoCurv,
RoborockMopModeQRevoMaster,
RoborockMopModeQRevoMaxV,
RoborockMopModeS7,
RoborockMopModeS8MaxVUltra,
RoborockMopModeS8ProUltra,
RoborockMopModeSaros10,
RoborockMopModeSaros10R,
RoborockStartType,
RoborockStateCode,
)
_LOGGER = logging.getLogger(__name__)
class FieldNameBase(StrEnum):
"""A base enum class that represents a field name in a RoborockBase dataclass."""
class StatusField(FieldNameBase):
"""An enum that represents a field in the `Status` class.
This is used with `roborock.devices.traits.v1.status.DeviceFeaturesTrait`
to understand if a feature is supported by the device using `is_field_supported`.
The enum values are names of fields in the `Status` class. Each field is annotated
with a metadata value to determine if the field is supported by the device.
"""
STATE = "state"
BATTERY = "battery"
FAN_POWER = "fan_power"
WATER_BOX_MODE = "water_box_mode"
CHARGE_STATUS = "charge_status"
DRY_STATUS = "dry_status"
ERROR_CODE = "error_code"
@dataclass
class Status(RoborockBase):
"""This status will be deprecated in favor of StatusV2."""
msg_ver: int | None = None
msg_seq: int | None = None
state: RoborockStateCode | None = field(default=None, metadata={"dps": RoborockDataProtocol.STATE})
battery: int | None = field(default=None, metadata={"dps": RoborockDataProtocol.BATTERY})
clean_time: int | None = None
clean_area: int | None = None
error_code: RoborockErrorCode | None = field(default=None, metadata={"dps": RoborockDataProtocol.ERROR_CODE})
map_present: int | None = None
in_cleaning: RoborockInCleaning | None = None
in_returning: int | None = None
in_fresh_state: int | None = None
lab_status: int | None = None
water_box_status: int | None = None
back_type: int | None = None
wash_phase: int | None = None
wash_ready: int | None = None
fan_power: RoborockFanPowerCode | None = field(default=None, metadata={"dps": RoborockDataProtocol.FAN_POWER})
dnd_enabled: int | None = None
map_status: int | None = None
is_locating: int | None = None
lock_status: int | None = None
water_box_mode: RoborockMopIntensityCode | None = field(
default=None, metadata={"dps": RoborockDataProtocol.WATER_BOX_MODE}
)
water_box_carriage_status: int | None = None
mop_forbidden_enable: int | None = None
camera_status: int | None = None
is_exploring: int | None = None
home_sec_status: int | None = None
home_sec_enable_password: int | None = None
adbumper_status: list[int] | None = None
water_shortage_status: int | None = None
dock_type: RoborockDockTypeCode | None = None
dust_collection_status: int | None = None
auto_dust_collection: int | None = None
avoid_count: int | None = None
mop_mode: RoborockMopModeCode | None = None
debug_mode: int | None = None
collision_avoid_status: int | None = None
switch_map_mode: int | None = None
dock_error_status: RoborockDockErrorCode | None = None
charge_status: int | None = field(default=None, metadata={"dps": RoborockDataProtocol.CHARGE_STATUS})
unsave_map_reason: int | None = None
unsave_map_flag: int | None = None
wash_status: int | None = None
distance_off: int | None = None
in_warmup: int | None = None
dry_status: int | None = field(default=None, metadata={"dps": RoborockDataProtocol.DRYING_STATUS})
rdt: int | None = None
clean_percent: int | None = None
rss: int | None = None
dss: int | None = None
common_status: int | None = None
corner_clean_mode: int | None = None
last_clean_t: int | None = None
replenish_mode: int | None = None
repeat: int | None = None
kct: int | None = None
subdivision_sets: int | None = None
@property
def square_meter_clean_area(self) -> float | None:
return round(self.clean_area / 1000000, 1) if self.clean_area is not None else None
@property
def error_code_name(self) -> str | None:
return self.error_code.name if self.error_code is not None else None
@property
def state_name(self) -> str | None:
return self.state.name if self.state is not None else None
@property
def water_box_mode_name(self) -> str | None:
return self.water_box_mode.name if self.water_box_mode is not None else None
@property
def fan_power_options(self) -> list[str]:
if self.fan_power is None:
return []
return list(self.fan_power.keys())
@property
def fan_power_name(self) -> str | None:
return self.fan_power.name if self.fan_power is not None else None
@property
def mop_mode_name(self) -> str | None:
return self.mop_mode.name if self.mop_mode is not None else None
def get_fan_speed_code(self, fan_speed: str) -> int:
if self.fan_power is None:
raise RoborockException("Attempted to get fan speed before status has been updated.")
return self.fan_power.as_dict().get(fan_speed)
def get_mop_intensity_code(self, mop_intensity: str) -> int:
if self.water_box_mode is None:
raise RoborockException("Attempted to get mop_intensity before status has been updated.")
return self.water_box_mode.as_dict().get(mop_intensity)
def get_mop_mode_code(self, mop_mode: str) -> int:
if self.mop_mode is None:
raise RoborockException("Attempted to get mop_mode before status has been updated.")
return self.mop_mode.as_dict().get(mop_mode)
@property
def current_map(self) -> int | None:
"""Returns the current map ID if the map is present."""
if self.map_status is not None:
map_flag = self.map_status >> 2
if map_flag != NO_MAP:
return map_flag
return None
@property
def clear_water_box_status(self) -> ClearWaterBoxStatus | None:
if self.dss:
return ClearWaterBoxStatus((self.dss >> 2) & 3)
return None
@property
def dirty_water_box_status(self) -> DirtyWaterBoxStatus | None:
if self.dss:
return DirtyWaterBoxStatus((self.dss >> 4) & 3)
return None
@property
def dust_bag_status(self) -> DustBagStatus | None:
if self.dss:
return DustBagStatus((self.dss >> 6) & 3)
return None
@property
def water_box_filter_status(self) -> int | None:
if self.dss:
return (self.dss >> 8) & 3
return None
@property
def clean_fluid_status(self) -> CleanFluidStatus | None:
if self.dss:
value = (self.dss >> 10) & 3
if value == 0:
return None # Feature not supported by this device
return CleanFluidStatus(value)
return None
@property
def hatch_door_status(self) -> int | None:
if self.dss:
return (self.dss >> 12) & 7
return None
@property
def dock_cool_fan_status(self) -> int | None:
if self.dss:
return (self.dss >> 15) & 3
return None
def __repr__(self) -> str:
return _attr_repr(self)
@dataclass
class StatusV2(RoborockBase):
"""
This is a new version of the Status object.
This is the result of GET_STATUS from the api.
"""
msg_ver: int | None = None
msg_seq: int | None = None
state: RoborockStateCode | None = field(default=None, metadata={"dps": RoborockDataProtocol.STATE})
battery: int | None = field(default=None, metadata={"dps": RoborockDataProtocol.BATTERY})
clean_time: int | None = None
clean_area: int | None = None
error_code: RoborockErrorCode | None = field(default=None, metadata={"dps": RoborockDataProtocol.ERROR_CODE})
map_present: int | None = None
in_cleaning: RoborockInCleaning | None = None
in_returning: int | None = None
in_fresh_state: int | None = None
lab_status: int | None = None
water_box_status: int | None = None
back_type: int | None = None
wash_phase: int | None = None
wash_ready: int | None = None
fan_power: int | None = field(default=None, metadata={"dps": RoborockDataProtocol.FAN_POWER})
dnd_enabled: int | None = None
map_status: int | None = None
is_locating: int | None = None
lock_status: int | None = None
water_box_mode: int | None = field(default=None, metadata={"dps": RoborockDataProtocol.WATER_BOX_MODE})
water_box_carriage_status: int | None = None
mop_forbidden_enable: int | None = None
camera_status: int | None = None
is_exploring: int | None = None
home_sec_status: int | None = None
home_sec_enable_password: int | None = None
adbumper_status: list[int] | None = None
water_shortage_status: int | None = None
dock_type: RoborockDockTypeCode | None = None
dust_collection_status: int | None = None
auto_dust_collection: int | None = None
avoid_count: int | None = None
mop_mode: int | None = None
debug_mode: int | None = None
collision_avoid_status: int | None = None
switch_map_mode: int | None = None
dock_error_status: RoborockDockErrorCode | None = None
charge_status: int | None = field(default=None, metadata={"dps": RoborockDataProtocol.CHARGE_STATUS})
unsave_map_reason: int | None = None
unsave_map_flag: int | None = None
wash_status: int | None = None
distance_off: int | None = None
in_warmup: int | None = None
dry_status: int | None = field(default=None, metadata={"dps": RoborockDataProtocol.DRYING_STATUS})
rdt: int | None = None
clean_percent: int | None = None
rss: int | None = None
dss: int | None = None
common_status: int | None = None
corner_clean_mode: int | None = None
last_clean_t: int | None = None
replenish_mode: int | None = None
repeat: int | None = None
kct: int | None = None
subdivision_sets: int | None = None
@property
def square_meter_clean_area(self) -> float | None:
return round(self.clean_area / 1000000, 1) if self.clean_area is not None else None
@property
def error_code_name(self) -> str | None:
return self.error_code.name if self.error_code is not None else None
@property
def state_name(self) -> str | None:
return self.state.name if self.state is not None else None
@property
def current_map(self) -> int | None:
"""Returns the current map ID if the map is present."""
if self.map_status is not None:
map_flag = self.map_status >> 2
if map_flag != NO_MAP:
return map_flag
return None
@property
def clear_water_box_status(self) -> ClearWaterBoxStatus | None:
if self.dss:
return ClearWaterBoxStatus((self.dss >> 2) & 3)
return None
@property
def dirty_water_box_status(self) -> DirtyWaterBoxStatus | None:
if self.dss:
return DirtyWaterBoxStatus((self.dss >> 4) & 3)
return None
@property
def dust_bag_status(self) -> DustBagStatus | None:
if self.dss:
return DustBagStatus((self.dss >> 6) & 3)
return None
@property
def water_box_filter_status(self) -> int | None:
if self.dss:
return (self.dss >> 8) & 3
return None
@property
def clean_fluid_status(self) -> CleanFluidStatus | None:
if self.dss:
value = (self.dss >> 10) & 3
if value == 0:
return None # Feature not supported by this device
return CleanFluidStatus(value)
return None
@property
def hatch_door_status(self) -> int | None:
if self.dss:
return (self.dss >> 12) & 7
return None
@property
def dock_cool_fan_status(self) -> int | None:
if self.dss:
return (self.dss >> 15) & 3
return None
def __repr__(self) -> str:
return _attr_repr(self)
@dataclass
class S4MaxStatus(Status):
fan_power: RoborockFanSpeedS6Pure | None = None
water_box_mode: RoborockMopIntensityS7 | None = None
mop_mode: RoborockMopModeS7 | None = None
@dataclass
class S5MaxStatus(Status):
fan_power: RoborockFanSpeedS6Pure | None = None
water_box_mode: RoborockMopIntensityS5Max | None = None
@dataclass
class Q7MaxStatus(Status):
fan_power: RoborockFanSpeedQ7Max | None = None
water_box_mode: RoborockMopIntensityQ7Max | None = None
@dataclass
class QRevoMasterStatus(Status):
fan_power: RoborockFanSpeedQRevoMaster | None = None
water_box_mode: RoborockMopIntensityQRevoMaster | None = None
mop_mode: RoborockMopModeQRevoMaster | None = None
@dataclass
class QRevoCurvStatus(Status):
fan_power: RoborockFanSpeedQRevoCurv | None = None
water_box_mode: RoborockMopIntensityQRevoCurv | None = None
mop_mode: RoborockMopModeQRevoCurv | None = None
@dataclass
class QRevoMaxVStatus(Status):
fan_power: RoborockFanSpeedQRevoMaxV | None = None
water_box_mode: RoborockMopIntensityQRevoMaxV | None = None
mop_mode: RoborockMopModeQRevoMaxV | None = None
@dataclass
class S6MaxVStatus(Status):
fan_power: RoborockFanSpeedS7MaxV | None = None
water_box_mode: RoborockMopIntensityS6MaxV | None = None
@dataclass
class S6PureStatus(Status):
fan_power: RoborockFanSpeedS6Pure | None = None
@dataclass
class S7MaxVStatus(Status):
fan_power: RoborockFanSpeedS7MaxV | None = None
water_box_mode: RoborockMopIntensityS7 | None = None
mop_mode: RoborockMopModeS7 | None = None
@dataclass
class S7Status(Status):
fan_power: RoborockFanSpeedS7 | None = None
water_box_mode: RoborockMopIntensityS7 | None = None
mop_mode: RoborockMopModeS7 | None = None
@dataclass
class S8ProUltraStatus(Status):
fan_power: RoborockFanSpeedS7MaxV | None = None
water_box_mode: RoborockMopIntensityS7 | None = None
mop_mode: RoborockMopModeS8ProUltra | None = None
@dataclass
class S8Status(Status):
fan_power: RoborockFanSpeedS7MaxV | None = None
water_box_mode: RoborockMopIntensityS7 | None = None
mop_mode: RoborockMopModeS8ProUltra | None = None
@dataclass
class P10Status(Status):
fan_power: RoborockFanSpeedP10 | None = None
water_box_mode: RoborockMopIntensityP10 | None = None
mop_mode: RoborockMopModeS8ProUltra | None = None
@dataclass
class S8MaxvUltraStatus(Status):
fan_power: RoborockFanSpeedS8MaxVUltra | None = None
water_box_mode: RoborockMopIntensityS8MaxVUltra | None = None
mop_mode: RoborockMopModeS8MaxVUltra | None = None
@dataclass
class Saros10RStatus(Status):
fan_power: RoborockFanSpeedSaros10R | None = None
water_box_mode: RoborockMopIntensitySaros10R | None = None
mop_mode: RoborockMopModeSaros10R | None = None
@dataclass
class Saros10Status(Status):
fan_power: RoborockFanSpeedSaros10 | None = None
water_box_mode: RoborockMopIntensitySaros10 | None = None
mop_mode: RoborockMopModeSaros10 | None = None
ModelStatus: dict[str, type[Status]] = {
ROBOROCK_S4_MAX: S4MaxStatus,
ROBOROCK_S5_MAX: S5MaxStatus,
ROBOROCK_Q7_MAX: Q7MaxStatus,
ROBOROCK_QREVO_MASTER: QRevoMasterStatus,
ROBOROCK_QREVO_CURV: QRevoCurvStatus,
ROBOROCK_S6: S6PureStatus,
ROBOROCK_S6_MAXV: S6MaxVStatus,
ROBOROCK_S6_PURE: S6PureStatus,
ROBOROCK_S7_MAXV: S7MaxVStatus,
ROBOROCK_S7: S7Status,
ROBOROCK_S8: S8Status,
ROBOROCK_S8_PRO_ULTRA: S8ProUltraStatus,
ROBOROCK_G10S_PRO: S7MaxVStatus,
ROBOROCK_G20S_Ultra: QRevoMasterStatus,
ROBOROCK_P10: P10Status,
# These likely are not correct,
# but i am currently unable to do my typical reverse engineering/ get any data from users on this,
# so this will be here in the mean time.
ROBOROCK_QREVO_S: P10Status,
ROBOROCK_QREVO_MAXV: QRevoMaxVStatus,
ROBOROCK_QREVO_PRO: P10Status,
ROBOROCK_S8_MAXV_ULTRA: S8MaxvUltraStatus,
ROBOROCK_SAROS_10R: Saros10RStatus,
ROBOROCK_SAROS_10: Saros10Status,
}
@dataclass
class DnDTimer(RoborockBaseTimer):
"""DnDTimer"""
@dataclass
class ValleyElectricityTimer(RoborockBaseTimer):
"""ValleyElectricityTimer"""
@dataclass
class CleanSummary(RoborockBase):
clean_time: int | None = None
clean_area: int | None = None
clean_count: int | None = None
dust_collection_count: int | None = None
records: list[int] | None = None
last_clean_t: int | None = None
@property
def square_meter_clean_area(self) -> float | None:
"""Returns the clean area in square meters."""
if isinstance(self.clean_area, list | str):
_LOGGER.warning(f"Clean area is a unexpected type! Please give the following in a issue: {self.clean_area}")
return None
return round(self.clean_area / 1000000, 1) if self.clean_area is not None else None
def __repr__(self) -> str:
"""Return a string representation of the object including all attributes."""
return _attr_repr(self)
@dataclass
class CleanRecord(RoborockBase):
begin: int | None = None
end: int | None = None
duration: int | None = None
area: int | None = None
error: int | None = None
complete: int | None = None
start_type: RoborockStartType | None = None
clean_type: RoborockCleanType | None = None
finish_reason: RoborockFinishReason | None = None
dust_collection_status: int | None = None
avoid_count: int | None = None
wash_count: int | None = None
map_flag: int | None = None
@property
def square_meter_area(self) -> float | None:
return round(self.area / 1000000, 1) if self.area is not None else None
@property
def begin_datetime(self) -> datetime.datetime | None:
return datetime.datetime.fromtimestamp(self.begin).astimezone(datetime.UTC) if self.begin else None
@property
def end_datetime(self) -> datetime.datetime | None:
return datetime.datetime.fromtimestamp(self.end).astimezone(datetime.UTC) if self.end else None
def __repr__(self) -> str:
return _attr_repr(self)
class CleanSummaryWithDetail(CleanSummary):
"""CleanSummary with the last CleanRecord included."""
last_clean_record: CleanRecord | None = None
class ConsumableField(FieldNameBase):
"""An enum that represents a field in the `Consumable` class.
This is used with `roborock.devices.traits.v1.status.DeviceFeaturesTrait`
to understand if a feature is supported by the device using `is_field_supported`.
The enum values are names of fields in the `Consumable` class. Each field is annotated
with a metadata value to determine if the field is supported by the device.
"""
MAIN_BRUSH_WORK_TIME = "main_brush_work_time"
SIDE_BRUSH_WORK_TIME = "side_brush_work_time"
FILTER_WORK_TIME = "filter_work_time"
@dataclass
class Consumable(RoborockBase):
main_brush_work_time: int | None = field(default=None, metadata={"dps": RoborockDataProtocol.MAIN_BRUSH_WORK_TIME})
side_brush_work_time: int | None = field(default=None, metadata={"dps": RoborockDataProtocol.SIDE_BRUSH_WORK_TIME})
filter_work_time: int | None = field(default=None, metadata={"dps": RoborockDataProtocol.FILTER_WORK_TIME})
filter_element_work_time: int | None = None
sensor_dirty_time: int | None = None
strainer_work_times: int | None = None
dust_collection_work_times: int | None = None
cleaning_brush_work_times: int | None = None
moproller_work_time: int | None = None
@property
def main_brush_time_left(self) -> int | None:
return MAIN_BRUSH_REPLACE_TIME - self.main_brush_work_time if self.main_brush_work_time is not None else None
@property
def side_brush_time_left(self) -> int | None:
return SIDE_BRUSH_REPLACE_TIME - self.side_brush_work_time if self.side_brush_work_time is not None else None
@property
def filter_time_left(self) -> int | None:
return FILTER_REPLACE_TIME - self.filter_work_time if self.filter_work_time is not None else None
@property
def sensor_time_left(self) -> int | None:
return SENSOR_DIRTY_REPLACE_TIME - self.sensor_dirty_time if self.sensor_dirty_time is not None else None
@property
def strainer_time_left(self) -> int | None:
return STRAINER_REPLACE_TIME - self.strainer_work_times if self.strainer_work_times is not None else None
@property
def dust_collection_time_left(self) -> int | None:
return (
DUST_COLLECTION_REPLACE_TIME - self.dust_collection_work_times
if self.dust_collection_work_times is not None
else None
)
@property
def cleaning_brush_time_left(self) -> int | None:
return (
CLEANING_BRUSH_REPLACE_TIME - self.cleaning_brush_work_times
if self.cleaning_brush_work_times is not None
else None
)
@property
def mop_roller_time_left(self) -> int | None:
return MOP_ROLLER_REPLACE_TIME - self.moproller_work_time if self.moproller_work_time is not None else None
def __repr__(self) -> str:
return _attr_repr(self)
@dataclass
class MultiMapsListRoom(RoborockBase):
id: int | None = None
tag: int | None = None
iot_name_id: str | None = None
iot_name: str | None = None
@property
def named_room_mapping(self) -> NamedRoomMapping | None:
"""Returns a NamedRoomMapping object if valid."""
if self.id is None or self.iot_name_id is None:
return None
return NamedRoomMapping(
segment_id=self.id,
iot_id=self.iot_name_id,
raw_name=self.iot_name,
)
@dataclass
class MultiMapsListMapInfoBakMaps(RoborockBase):
mapflag: Any | None = None
add_time: Any | None = None
@dataclass
class MultiMapsListMapInfo(RoborockBase):
map_flag: int
name: str
add_time: Any | None = None
length: Any | None = None
bak_maps: list[MultiMapsListMapInfoBakMaps] | None = None
rooms: list[MultiMapsListRoom] | None = None
@property
def mapFlag(self) -> int:
"""Alias for map_flag, returns the map flag as an integer."""
return self.map_flag
@property
def rooms_map(self) -> dict[int, NamedRoomMapping]:
"""Returns a dictionary of room mappings by segment id."""
return {
room.id: mapping
for room in self.rooms or ()
if room.id is not None and (mapping := room.named_room_mapping) is not None
}
@dataclass
class MultiMapsList(RoborockBase):
max_multi_map: int | None = None
max_bak_map: int | None = None
multi_map_count: int | None = None
map_info: list[MultiMapsListMapInfo] | None = None
@dataclass
class SmartWashParams(RoborockBase):
smart_wash: int | None = None
wash_interval: int | None = None
@dataclass
class DustCollectionMode(RoborockBase):
mode: RoborockDockDustCollectionModeCode | None = None
@dataclass
class WashTowelMode(RoborockBase):
wash_mode: WashTowelModes | None = None
@dataclass
class NetworkInfo(RoborockBase):
ip: str
ssid: str | None = None
mac: str | None = None
bssid: str | None = None
rssi: int | None = None
@dataclass
class AppInitStatusLocalInfo(RoborockBase):
location: str
bom: str | None = None
featureset: int | None = None
language: str | None = None
logserver: str | None = None
wifiplan: str | None = None
timezone: str | None = None
name: str | None = None
@dataclass
class AppInitStatus(RoborockBase):
local_info: AppInitStatusLocalInfo
feature_info: list[int]
new_feature_info: int
new_feature_info_str: str = ""
new_feature_info_2: int | None = None
carriage_type: int | None = None
dsp_version: str | None = None
@dataclass
class ChildLockStatus(RoborockBase):
lock_status: int = 0
@dataclass
class FlowLedStatus(RoborockBase):
status: int = 0
@dataclass
class LedStatus(RoborockBase):
status: int = 0