Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions roborock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from roborock.containers import *
from roborock.exceptions import *
from roborock.typing import *
from roborock.code_mappings import *
80 changes: 80 additions & 0 deletions roborock/code_mappings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
STATE_CODE_TO_STATUS = {
1: "starting",
2: "charger_disconnected",
3: "idle",
4: "remote_control_active",
5: "cleaning",
6: "returning_home",
7: "manual_mode",
8: "charging",
9: "charging_problem",
10: "paused",
11: "spot_cleaning",
12: "error",
13: "shutting_down",
14: "updating",
15: "docking",
16: "going_to_target",
17: "zoned_cleaning",
18: "segment_cleaning",
22: "emptying_the_bin", # on s7+, see #1189
23: "washing_the_mop", # on a46, #1435
26: "going_to_wash_the_mop", # on a46, #1435
100: "charging_complete",
101: "device_offline",
}

ERROR_CODE_TO_TEXT = {
0: "None",
1: "LiDAR turret or laser blocked. Check for obstruction and retry.",
2: "Bumper stuck. Clean it and lightly tap to release it.",
3: "Wheels suspended. Move robot and restart.",
4: "Cliff sensor error. Clean cliff sensors, move robot away from drops and restart.",
5: "Main brush jammed. Clean main brush and bearings.",
6: "Side brush jammed. Remove and clean side brush.",
7: "Wheels jammed. Move the robot and restart.",
8: "Robot trapped. Clear obstacles surrounding robot.",
9: "No dustbin. Install dustbin and filter.",
12: "Low battery. Recharge and retry.",
13: "Charging error. Clean charging contacts and retry.",
14: "Battery error.",
15: "Wall sensor dirty. Clean wall sensor.",
16: "Robot tilted. Move to level ground and restart.",
17: "Side brush error. Reset robot.",
18: "Fan error. Reset robot.",
21: "Vertical bumper pressed. Move robot and retry.",
22: "Dock locator error. Clean and retry.",
23: "Could not return to dock. Clean dock location beacon and retry.",
24: "No-go zone or invisible wall detected. Move the robot.",
27: "VibraRise system jammed. Check for obstructions.",
28: "Robot on carpet. Move robot to floor and retry.",
29: "Filter blocked or wet. Clean, dry, and retry.",
30: "No-go zone or Invisible Wall detected. Move robot from this area.",
31: "Cannot cross carpet. Move robot across carpet and restart.",
32: "Internal error. Reset the robot.",
}

FAN_SPEED_CODES = {
105: "off",
101: "silent",
102: "balanced",
103: "turbo",
104: "max",
108: "max_plus",
106: "custom",
}

MOP_MODE_CODES = {
300: "standard",
301: "deep",
303: "deep_plus",
302: "custom",
}

MOP_INTENSITY_CODES = {
200: "off",
201: "mild",
202: "moderate",
203: "intense",
204: "custom",
}
27 changes: 25 additions & 2 deletions roborock/containers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from enum import Enum

from roborock.code_mappings import STATE_CODE_TO_STATUS, ERROR_CODE_TO_TEXT, FAN_SPEED_CODES, MOP_MODE_CODES, \
MOP_INTENSITY_CODES


class UserDataRRiotReferenceField(str, Enum):
REGION = "r"
Expand Down Expand Up @@ -629,6 +632,10 @@ def msg_ver(self) -> int:
def msg_seq(self) -> int:
return self.get(StatusField.MSG_SEQ)

@property
def status(self) -> str:
return STATE_CODE_TO_STATUS.get(self.state)

@property
def state(self) -> int:
return self.get(StatusField.STATE)
Expand All @@ -649,6 +656,10 @@ def clean_area(self) -> int:
def error_code(self) -> int:
return self.get(StatusField.ERROR_CODE)

@property
def error(self) -> str:
return ERROR_CODE_TO_TEXT.get(self.error_code)

@property
def map_present(self) -> int:
return self.get(StatusField.MAP_PRESENT)
Expand Down Expand Up @@ -686,9 +697,13 @@ def wash_ready(self) -> int:
return self.get(StatusField.WASH_READY)

@property
def fan_power(self) -> int:
def fan_power_code(self) -> int:
return self.get(StatusField.FAN_POWER)

@property
def fan_power(self) -> str:
return FAN_SPEED_CODES.get(self.fan_power_code)

@property
def dnd_enabled(self) -> int:
return self.get(StatusField.DND_ENABLED)
Expand All @@ -709,6 +724,10 @@ def lock_status(self) -> int:
def water_box_mode(self) -> int:
return self.get(StatusField.WATER_BOX_MODE)

@property
def mop_intensity(self) -> str:
return MOP_INTENSITY_CODES.get(self.water_box_mode)

@property
def water_box_carriage_status(self) -> int:
return self.get(StatusField.WATER_BOX_CARRIAGE_STATUS)
Expand Down Expand Up @@ -758,9 +777,13 @@ def avoid_count(self) -> int:
return self.get(StatusField.AVOID_COUNT)

@property
def mop_mode(self) -> int:
def mop_mode_code(self) -> int:
return self.get(StatusField.MOP_MODE)

@property
def mop_mode(self) -> str:
return MOP_MODE_CODES.get(self.mop_mode_code)

@property
def debug_mode(self) -> int:
return self.get(StatusField.DEBUG_MODE)
Expand Down