Skip to content

Commit b9a6619

Browse files
authored
Add additional sensors and settings to Roborock vacuums (#1585)
Add additional sensors and improve the already implemented sensors for the Roborock S7 MaxV. Controls added: - Mop routing (enum) - Mop scrub intensity (enum) - Auto dust collection (switch) Also, splits enums into a separate file to prevent circular imports
1 parent 10464c9 commit b9a6619

File tree

4 files changed

+401
-132
lines changed

4 files changed

+401
-132
lines changed

miio/integrations/vacuum/roborock/tests/test_vacuum.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ def __init__(self, *args, **kwargs):
6262
1487548800,
6363
],
6464
]
65+
self.dummies["dnd_timer"] = [
66+
{
67+
"enabled": 1,
68+
"start_minute": 0,
69+
"end_minute": 0,
70+
"start_hour": 22,
71+
"end_hour": 8,
72+
}
73+
]
6574

6675
self.return_values = {
6776
"get_status": lambda x: [self.state],
@@ -75,6 +84,8 @@ def __init__(self, *args, **kwargs):
7584
"app_zoned_clean": lambda x: self.change_mode("zoned clean"),
7685
"app_charge": lambda x: self.change_mode("charge"),
7786
"miIO.info": "dummy info",
87+
"get_clean_record": lambda x: [[1488347071, 1488347123, 16, 0, 0, 0]],
88+
"get_dnd_timer": lambda x: self.dummies["dnd_timer"],
7889
}
7990

8091
super().__init__(args, kwargs)

miio/integrations/vacuum/roborock/vacuum.py

Lines changed: 25 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import contextlib
22
import datetime
3-
import enum
43
import json
54
import logging
65
import math
@@ -24,6 +23,22 @@
2423
from miio.exceptions import DeviceInfoUnavailableException, UnsupportedFeatureException
2524
from miio.interfaces import FanspeedPresets, VacuumInterface
2625

26+
from .vacuum_enums import (
27+
CarpetCleaningMode,
28+
Consumable,
29+
DustCollectionMode,
30+
FanspeedE2,
31+
FanspeedEnum,
32+
FanspeedS7,
33+
FanspeedS7_Maxv,
34+
FanspeedV1,
35+
FanspeedV2,
36+
FanspeedV3,
37+
MopIntensity,
38+
MopMode,
39+
TimerState,
40+
WaterFlow,
41+
)
2742
from .vacuumcontainers import (
2843
CarpetModeStatus,
2944
CleaningDetails,
@@ -39,112 +54,6 @@
3954
_LOGGER = logging.getLogger(__name__)
4055

4156

42-
class TimerState(enum.Enum):
43-
On = "on"
44-
Off = "off"
45-
46-
47-
class Consumable(enum.Enum):
48-
MainBrush = "main_brush_work_time"
49-
SideBrush = "side_brush_work_time"
50-
Filter = "filter_work_time"
51-
SensorDirty = "sensor_dirty_time"
52-
53-
54-
class FanspeedEnum(enum.Enum):
55-
pass
56-
57-
58-
class FanspeedV1(FanspeedEnum):
59-
Silent = 38
60-
Standard = 60
61-
Medium = 77
62-
Turbo = 90
63-
64-
65-
class FanspeedV2(FanspeedEnum):
66-
Silent = 101
67-
Standard = 102
68-
Medium = 103
69-
Turbo = 104
70-
Gentle = 105
71-
Auto = 106
72-
73-
74-
class FanspeedV3(FanspeedEnum):
75-
Silent = 38
76-
Standard = 60
77-
Medium = 75
78-
Turbo = 100
79-
80-
81-
class FanspeedE2(FanspeedEnum):
82-
# Original names from the app: Gentle, Silent, Standard, Strong, Max
83-
Gentle = 41
84-
Silent = 50
85-
Standard = 68
86-
Medium = 79
87-
Turbo = 100
88-
89-
90-
class FanspeedS7(FanspeedEnum):
91-
Silent = 101
92-
Standard = 102
93-
Medium = 103
94-
Turbo = 104
95-
96-
97-
class FanspeedS7_Maxv(FanspeedEnum):
98-
Silent = 101
99-
Standard = 102
100-
Medium = 103
101-
Turbo = 104
102-
Max = 108
103-
104-
105-
class WaterFlow(enum.Enum):
106-
"""Water flow strength on s5 max."""
107-
108-
Minimum = 200
109-
Low = 201
110-
High = 202
111-
Maximum = 203
112-
113-
114-
class MopMode(enum.Enum):
115-
"""Mop routing on S7."""
116-
117-
Standard = 300
118-
Deep = 301
119-
120-
121-
class MopIntensity(enum.Enum):
122-
"""Mop scrub intensity on S7 + S7MAXV."""
123-
124-
Close = 200
125-
Mild = 201
126-
Moderate = 202
127-
Intense = 203
128-
129-
130-
class CarpetCleaningMode(enum.Enum):
131-
"""Type of carpet cleaning/avoidance."""
132-
133-
Avoid = 0
134-
Rise = 1
135-
Ignore = 2
136-
137-
138-
class DustCollectionMode(enum.Enum):
139-
"""Auto emptying mode (S7 + S7MAXV only)"""
140-
141-
Smart = 0
142-
Quick = 1
143-
Daily = 2
144-
Strong = 3
145-
Max = 4
146-
147-
14857
ROCKROBO_V1 = "rockrobo.vacuum.v1"
14958
ROCKROBO_S4 = "roborock.vacuum.s4"
15059
ROCKROBO_S4_MAX = "roborock.vacuum.a19"
@@ -410,11 +319,17 @@ def manual_control(
410319
@command()
411320
def status(self) -> VacuumStatus:
412321
"""Return status of the vacuum."""
413-
status = VacuumStatus(self.send("get_status")[0])
322+
status = self.vacuum_status()
414323
status.embed(self.consumable_status())
415324
status.embed(self.clean_history())
325+
status.embed(self.dnd_status())
416326
return status
417327

328+
@command()
329+
def vacuum_status(self) -> VacuumStatus:
330+
"""Return only status of the vacuum."""
331+
return VacuumStatus(self.send("get_status")[0])
332+
418333
def enable_log_upload(self):
419334
raise NotImplementedError("unknown parameters")
420335
# return self.send("enable_log_upload")
@@ -964,7 +879,7 @@ def set_mop_mode(self, mop_mode: MopMode):
964879
@command()
965880
def mop_intensity(self) -> MopIntensity:
966881
"""Get mop scrub intensity setting."""
967-
if self.model != ROCKROBO_S7:
882+
if self.model not in [ROCKROBO_S7, ROCKROBO_S7_MAXV]:
968883
raise UnsupportedFeatureException(
969884
"Mop scrub intensity not supported by %s", self.model
970885
)
@@ -974,7 +889,7 @@ def mop_intensity(self) -> MopIntensity:
974889
@command(click.argument("mop_intensity", type=EnumType(MopIntensity)))
975890
def set_mop_intensity(self, mop_intensity: MopIntensity):
976891
"""Set mop scrub intensity setting."""
977-
if self.model != ROCKROBO_S7:
892+
if self.model not in [ROCKROBO_S7, ROCKROBO_S7_MAXV]:
978893
raise UnsupportedFeatureException(
979894
"Mop scrub intensity not supported by %s", self.model
980895
)
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import enum
2+
3+
4+
class TimerState(enum.Enum):
5+
On = "on"
6+
Off = "off"
7+
8+
9+
class Consumable(enum.Enum):
10+
MainBrush = "main_brush_work_time"
11+
SideBrush = "side_brush_work_time"
12+
Filter = "filter_work_time"
13+
SensorDirty = "sensor_dirty_time"
14+
15+
16+
class FanspeedEnum(enum.Enum):
17+
pass
18+
19+
20+
class FanspeedV1(FanspeedEnum):
21+
Silent = 38
22+
Standard = 60
23+
Medium = 77
24+
Turbo = 90
25+
26+
27+
class FanspeedV2(FanspeedEnum):
28+
Silent = 101
29+
Standard = 102
30+
Medium = 103
31+
Turbo = 104
32+
Gentle = 105
33+
Auto = 106
34+
35+
36+
class FanspeedV3(FanspeedEnum):
37+
Silent = 38
38+
Standard = 60
39+
Medium = 75
40+
Turbo = 100
41+
42+
43+
class FanspeedE2(FanspeedEnum):
44+
# Original names from the app: Gentle, Silent, Standard, Strong, Max
45+
Gentle = 41
46+
Silent = 50
47+
Standard = 68
48+
Medium = 79
49+
Turbo = 100
50+
51+
52+
class FanspeedS7(FanspeedEnum):
53+
Silent = 101
54+
Standard = 102
55+
Medium = 103
56+
Turbo = 104
57+
58+
59+
class FanspeedS7_Maxv(FanspeedEnum):
60+
# Original names from the app: Quiet, Balanced, Turbo, Max, Max+
61+
Off = 105
62+
Silent = 101
63+
Standard = 102
64+
Medium = 103
65+
Turbo = 104
66+
Max = 108
67+
68+
69+
class WaterFlow(enum.Enum):
70+
"""Water flow strength on s5 max."""
71+
72+
Minimum = 200
73+
Low = 201
74+
High = 202
75+
Maximum = 203
76+
77+
78+
class MopMode(enum.Enum):
79+
"""Mop routing on S7 + S7MAXV."""
80+
81+
Standard = 300
82+
Deep = 301
83+
DeepPlus = 303
84+
85+
86+
class MopIntensity(enum.Enum):
87+
"""Mop scrub intensity on S7 + S7MAXV."""
88+
89+
Off = 200
90+
Mild = 201
91+
Moderate = 202
92+
Intense = 203
93+
94+
95+
class CarpetCleaningMode(enum.Enum):
96+
"""Type of carpet cleaning/avoidance."""
97+
98+
Avoid = 0
99+
Rise = 1
100+
Ignore = 2
101+
102+
103+
class DustCollectionMode(enum.Enum):
104+
"""Auto emptying mode (S7 + S7MAXV only)"""
105+
106+
Smart = 0
107+
Quick = 1
108+
Daily = 2
109+
Strong = 3
110+
Max = 4

0 commit comments

Comments
 (0)