Skip to content

Commit 2fdfe1d

Browse files
Merge pull request #3 from Lash-L/code_mappings
2 parents fa934ab + 7489a98 commit 2fdfe1d

File tree

3 files changed

+106
-2
lines changed

3 files changed

+106
-2
lines changed

roborock/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
from roborock.containers import *
55
from roborock.exceptions import *
66
from roborock.typing import *
7+
from roborock.code_mappings import *

roborock/code_mappings.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
STATE_CODE_TO_STATUS = {
2+
1: "starting",
3+
2: "charger_disconnected",
4+
3: "idle",
5+
4: "remote_control_active",
6+
5: "cleaning",
7+
6: "returning_home",
8+
7: "manual_mode",
9+
8: "charging",
10+
9: "charging_problem",
11+
10: "paused",
12+
11: "spot_cleaning",
13+
12: "error",
14+
13: "shutting_down",
15+
14: "updating",
16+
15: "docking",
17+
16: "going_to_target",
18+
17: "zoned_cleaning",
19+
18: "segment_cleaning",
20+
22: "emptying_the_bin", # on s7+, see #1189
21+
23: "washing_the_mop", # on a46, #1435
22+
26: "going_to_wash_the_mop", # on a46, #1435
23+
100: "charging_complete",
24+
101: "device_offline",
25+
}
26+
27+
ERROR_CODE_TO_TEXT = {
28+
0: "None",
29+
1: "LiDAR turret or laser blocked. Check for obstruction and retry.",
30+
2: "Bumper stuck. Clean it and lightly tap to release it.",
31+
3: "Wheels suspended. Move robot and restart.",
32+
4: "Cliff sensor error. Clean cliff sensors, move robot away from drops and restart.",
33+
5: "Main brush jammed. Clean main brush and bearings.",
34+
6: "Side brush jammed. Remove and clean side brush.",
35+
7: "Wheels jammed. Move the robot and restart.",
36+
8: "Robot trapped. Clear obstacles surrounding robot.",
37+
9: "No dustbin. Install dustbin and filter.",
38+
12: "Low battery. Recharge and retry.",
39+
13: "Charging error. Clean charging contacts and retry.",
40+
14: "Battery error.",
41+
15: "Wall sensor dirty. Clean wall sensor.",
42+
16: "Robot tilted. Move to level ground and restart.",
43+
17: "Side brush error. Reset robot.",
44+
18: "Fan error. Reset robot.",
45+
21: "Vertical bumper pressed. Move robot and retry.",
46+
22: "Dock locator error. Clean and retry.",
47+
23: "Could not return to dock. Clean dock location beacon and retry.",
48+
24: "No-go zone or invisible wall detected. Move the robot.",
49+
27: "VibraRise system jammed. Check for obstructions.",
50+
28: "Robot on carpet. Move robot to floor and retry.",
51+
29: "Filter blocked or wet. Clean, dry, and retry.",
52+
30: "No-go zone or Invisible Wall detected. Move robot from this area.",
53+
31: "Cannot cross carpet. Move robot across carpet and restart.",
54+
32: "Internal error. Reset the robot.",
55+
}
56+
57+
FAN_SPEED_CODES = {
58+
105: "off",
59+
101: "silent",
60+
102: "balanced",
61+
103: "turbo",
62+
104: "max",
63+
108: "max_plus",
64+
106: "custom",
65+
}
66+
67+
MOP_MODE_CODES = {
68+
300: "standard",
69+
301: "deep",
70+
303: "deep_plus",
71+
302: "custom",
72+
}
73+
74+
MOP_INTENSITY_CODES = {
75+
200: "off",
76+
201: "mild",
77+
202: "moderate",
78+
203: "intense",
79+
204: "custom",
80+
}

roborock/containers.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from enum import Enum
22

3+
from roborock.code_mappings import STATE_CODE_TO_STATUS, ERROR_CODE_TO_TEXT, FAN_SPEED_CODES, MOP_MODE_CODES, \
4+
MOP_INTENSITY_CODES
5+
36

47
class UserDataRRiotReferenceField(str, Enum):
58
REGION = "r"
@@ -629,6 +632,10 @@ def msg_ver(self) -> int:
629632
def msg_seq(self) -> int:
630633
return self.get(StatusField.MSG_SEQ)
631634

635+
@property
636+
def status(self) -> str:
637+
return STATE_CODE_TO_STATUS.get(self.state)
638+
632639
@property
633640
def state(self) -> int:
634641
return self.get(StatusField.STATE)
@@ -649,6 +656,10 @@ def clean_area(self) -> int:
649656
def error_code(self) -> int:
650657
return self.get(StatusField.ERROR_CODE)
651658

659+
@property
660+
def error(self) -> str:
661+
return ERROR_CODE_TO_TEXT.get(self.error_code)
662+
652663
@property
653664
def map_present(self) -> int:
654665
return self.get(StatusField.MAP_PRESENT)
@@ -686,9 +697,13 @@ def wash_ready(self) -> int:
686697
return self.get(StatusField.WASH_READY)
687698

688699
@property
689-
def fan_power(self) -> int:
700+
def fan_power_code(self) -> int:
690701
return self.get(StatusField.FAN_POWER)
691702

703+
@property
704+
def fan_power(self) -> str:
705+
return FAN_SPEED_CODES.get(self.fan_power_code)
706+
692707
@property
693708
def dnd_enabled(self) -> int:
694709
return self.get(StatusField.DND_ENABLED)
@@ -709,6 +724,10 @@ def lock_status(self) -> int:
709724
def water_box_mode(self) -> int:
710725
return self.get(StatusField.WATER_BOX_MODE)
711726

727+
@property
728+
def mop_intensity(self) -> str:
729+
return MOP_INTENSITY_CODES.get(self.water_box_mode)
730+
712731
@property
713732
def water_box_carriage_status(self) -> int:
714733
return self.get(StatusField.WATER_BOX_CARRIAGE_STATUS)
@@ -758,9 +777,13 @@ def avoid_count(self) -> int:
758777
return self.get(StatusField.AVOID_COUNT)
759778

760779
@property
761-
def mop_mode(self) -> int:
780+
def mop_mode_code(self) -> int:
762781
return self.get(StatusField.MOP_MODE)
763782

783+
@property
784+
def mop_mode(self) -> str:
785+
return MOP_MODE_CODES.get(self.mop_mode_code)
786+
764787
@property
765788
def debug_mode(self) -> int:
766789
return self.get(StatusField.DEBUG_MODE)

0 commit comments

Comments
 (0)