Skip to content

Commit 12361b5

Browse files
authored
feat: add some missing codes and make warnings only message once (#218)
1 parent eabf08d commit 12361b5

File tree

3 files changed

+117
-7
lines changed

3 files changed

+117
-7
lines changed

roborock/code_mappings.py

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from enum import Enum, IntEnum
55

66
_LOGGER = logging.getLogger(__name__)
7+
completed_warnings = set()
78

89

910
class RoborockEnum(IntEnum):
@@ -16,10 +17,16 @@ def name(self) -> str:
1617
@classmethod
1718
def _missing_(cls: type[RoborockEnum], key) -> RoborockEnum:
1819
if hasattr(cls, "unknown"):
19-
_LOGGER.warning(f"Missing {cls.__name__} code: {key} - defaulting to 'unknown'")
20+
warning = f"Missing {cls.__name__} code: {key} - defaulting to 'unknown'"
21+
if warning not in completed_warnings:
22+
completed_warnings.add(warning)
23+
_LOGGER.warning(warning)
2024
return cls.unknown # type: ignore
2125
default_value = next(item for item in cls)
22-
_LOGGER.warning(f"Missing {cls.__name__} code: {key} - defaulting to {default_value}")
26+
warning = f"Missing {cls.__name__} code: {key} - defaulting to {default_value}"
27+
if warning not in completed_warnings:
28+
completed_warnings.add(warning)
29+
_LOGGER.warning(warning)
2330
return default_value
2431

2532
@classmethod
@@ -415,6 +422,93 @@ def __missing__(self, key):
415422
return RoborockCategory.UNKNOWN
416423

417424

425+
class RoborockFinishReason(RoborockEnum):
426+
manual_interrupt = 21 # Cleaning interrupted by user
427+
cleanup_interrupted = 24 # Cleanup interrupted
428+
manual_interrupt_2 = 21
429+
breakpoint = 32 # Could not continue cleaning
430+
breakpoint_2 = 33
431+
cleanup_interrupted_2 = 34
432+
manual_interrupt_3 = 35
433+
manual_interrupt_4 = 36
434+
manual_interrupt_5 = 37
435+
manual_interrupt_6 = 43
436+
locate_fail = 45 # Positioning Failed
437+
cleanup_interrupted_3 = 64
438+
locate_fail_2 = 65
439+
manual_interrupt_7 = 48
440+
manual_interrupt_8 = 49
441+
manual_interrupt_9 = 50
442+
cleanup_interrupted_4 = 51
443+
finished_cleaning = 52 # Finished cleaning
444+
finished_cleaning_2 = 54
445+
finished_cleaning_3 = 55
446+
finished_cleaning_4 = 56
447+
finished_clenaing_5 = 57
448+
manual_interrupt_10 = 60
449+
area_unreachable = 61 # Area unreachable
450+
area_unreachable_2 = 62
451+
washing_error = 67 # Washing error
452+
back_to_wash_failure = 68 # Failed to return to the dock
453+
cleanup_interrupted_5 = 101
454+
breakpoint_4 = 102
455+
manual_interrupt_11 = 103
456+
cleanup_interrupted_6 = 104
457+
cleanup_interrupted_7 = 105
458+
cleanup_interrupted_8 = 106
459+
cleanup_interrupted_9 = 107
460+
cleanup_interrupted_10 = 109
461+
cleanup_interrupted_11 = 110
462+
patrol_success = 114 # Cruise completed
463+
patrol_fail = 115 # Cruise failed
464+
pet_patrol_success = 116 # Pet found
465+
pet_patrol_fail = 117 # Pet found failed
466+
467+
468+
class RoborockInCleaning(RoborockEnum):
469+
complete = 0
470+
global_clean_not_complete = 1
471+
zone_clean_not_complete = 2
472+
segment_clean_not_complete = 3
473+
474+
475+
class RoborockCleanType(RoborockEnum):
476+
all_zone = 1
477+
draw_zone = 2
478+
select_zone = 3
479+
quick_build = 4
480+
video_patrol = 5
481+
pet_patrol = 6
482+
483+
484+
class RoborockStartType(RoborockEnum):
485+
button = 1
486+
app = 2
487+
schedule = 3
488+
mi_home = 4
489+
quick_start = 5
490+
voice_control = 13
491+
routines = 101
492+
alexa = 801
493+
google = 802
494+
ifttt = 803
495+
yandex = 804
496+
homekit = 805
497+
xiaoai = 806
498+
tmall_genie = 807
499+
duer = 808
500+
dingdong = 809
501+
siri = 810
502+
clova = 811
503+
wechat = 901
504+
alipay = 902
505+
aqara = 903
506+
hisense = 904
507+
huawei = 905
508+
widget_launch = 820
509+
smart_watch = 821
510+
511+
418512
class DyadSelfCleanMode(RoborockEnum):
419513
self_clean = 1
420514
self_clean_and_dry = 2

roborock/const.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@
4242
ROBOROCK_C1 = "roborock.vacuum.c1"
4343
ROBOROCK_S8_PRO_ULTRA = "roborock.vacuum.a70"
4444
ROBOROCK_S8 = "roborock.vacuum.a51"
45-
ROBOROCK_P10 = "roborock.vacuum.a75"
45+
ROBOROCK_P10 = "roborock.vacuum.a75" # also known as q_revo
4646
ROBOROCK_S8_MAXV_ULTRA = "roborock.vacuum.a97"
47+
ROBOROCK_QREVO_S = "roborock.vacuum.a104"
48+
ROBOROCK_QREVO_PRO = "roborock.vacuum.a101"
49+
ROBOROCK_QREVO_MAXV = "roborock.vacuum.a87"
4750

4851
ROBOROCK_DYAD_AIR = "roborock.wetdryvac.a107"
4952
ROBOROCK_DYAD_PRO_COMBO = "roborock.wetdryvac.a83"

roborock/containers.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from .code_mappings import (
1515
RoborockCategory,
16+
RoborockCleanType,
1617
RoborockDockDustCollectionModeCode,
1718
RoborockDockErrorCode,
1819
RoborockDockTypeCode,
@@ -25,6 +26,8 @@
2526
RoborockFanSpeedS7,
2627
RoborockFanSpeedS7MaxV,
2728
RoborockFanSpeedS8MaxVUltra,
29+
RoborockFinishReason,
30+
RoborockInCleaning,
2831
RoborockMopIntensityCode,
2932
RoborockMopIntensityP10,
3033
RoborockMopIntensityS5Max,
@@ -36,6 +39,7 @@
3639
RoborockMopModeS7,
3740
RoborockMopModeS8MaxVUltra,
3841
RoborockMopModeS8ProUltra,
42+
RoborockStartType,
3943
RoborockStateCode,
4044
)
4145
from .const import (
@@ -47,6 +51,9 @@
4751
ROBOROCK_G10S_PRO,
4852
ROBOROCK_P10,
4953
ROBOROCK_Q7_MAX,
54+
ROBOROCK_QREVO_MAXV,
55+
ROBOROCK_QREVO_PRO,
56+
ROBOROCK_QREVO_S,
5057
ROBOROCK_S4_MAX,
5158
ROBOROCK_S5_MAX,
5259
ROBOROCK_S6,
@@ -408,7 +415,7 @@ class Status(RoborockBase):
408415
square_meter_clean_area: float | None = None
409416
error_code: RoborockErrorCode | None = None
410417
map_present: int | None = None
411-
in_cleaning: int | None = None
418+
in_cleaning: RoborockInCleaning | None = None
412419
in_returning: int | None = None
413420
in_fresh_state: int | None = None
414421
lab_status: int | None = None
@@ -574,6 +581,12 @@ class S8MaxvUltraStatus(Status):
574581
ROBOROCK_S8_PRO_ULTRA: S8ProUltraStatus,
575582
ROBOROCK_G10S_PRO: S7MaxVStatus,
576583
ROBOROCK_P10: P10Status,
584+
# These likely are not correct,
585+
# but i am currently unable to do my typical reverse engineering/ get any data from users on this,
586+
# so this will be here in the mean time.
587+
ROBOROCK_QREVO_S: P10Status,
588+
ROBOROCK_QREVO_MAXV: P10Status,
589+
ROBOROCK_QREVO_PRO: P10Status,
577590
ROBOROCK_S8_MAXV_ULTRA: S8MaxvUltraStatus,
578591
}
579592

@@ -613,9 +626,9 @@ class CleanRecord(RoborockBase):
613626
square_meter_area: float | None = None
614627
error: int | None = None
615628
complete: int | None = None
616-
start_type: int | None = None
617-
clean_type: int | None = None
618-
finish_reason: int | None = None
629+
start_type: RoborockStartType | None = None
630+
clean_type: RoborockCleanType | None = None
631+
finish_reason: RoborockFinishReason | None = None
619632
dust_collection_status: int | None = None
620633
avoid_count: int | None = None
621634
wash_count: int | None = None

0 commit comments

Comments
 (0)