Skip to content

Commit 97fb0b7

Browse files
authored
feat: improvements to B01 for HA integration (#678)
1 parent 3cf1a9a commit 97fb0b7

File tree

2 files changed

+81
-1
lines changed

2 files changed

+81
-1
lines changed

roborock/data/b01_q7/b01_q7_containers.py

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
from dataclasses import dataclass, field
22

33
from ..containers import RoborockBase
4-
from .b01_q7_code_mappings import B01Fault, SCWindMapping, WorkModeMapping, WorkStatusMapping
4+
from .b01_q7_code_mappings import (
5+
B01Fault,
6+
SCWindMapping,
7+
WorkModeMapping,
8+
WorkStatusMapping,
9+
)
510

611

712
@dataclass
@@ -128,3 +133,73 @@ class B01Props(RoborockBase):
128133
serial_number: str | None = None
129134
recommend: Recommend | None = None
130135
add_sweep_status: int | None = None
136+
137+
@property
138+
def main_brush_time_left(self) -> int | None:
139+
"""
140+
Returns estimated remaining life of the main brush in minutes.
141+
Total life is 300 hours (18000 minutes).
142+
"""
143+
if self.main_brush is None:
144+
return None
145+
return max(0, 18000 - self.main_brush)
146+
147+
@property
148+
def side_brush_time_left(self) -> int | None:
149+
"""
150+
Returns estimated remaining life of the side brush in minutes.
151+
Total life is 200 hours (12000 minutes).
152+
"""
153+
if self.side_brush is None:
154+
return None
155+
return max(0, 12000 - self.side_brush)
156+
157+
@property
158+
def filter_time_left(self) -> int | None:
159+
"""
160+
Returns estimated remaining life of the filter (hypa) in minutes.
161+
Total life is 150 hours (9000 minutes).
162+
"""
163+
if self.hypa is None:
164+
return None
165+
return max(0, 9000 - self.hypa)
166+
167+
@property
168+
def mop_life_time_left(self) -> int | None:
169+
"""
170+
Returns estimated remaining life of the mop in minutes.
171+
Total life is 180 hours (10800 minutes).
172+
"""
173+
if self.mop_life is None:
174+
return None
175+
return max(0, 10800 - self.mop_life)
176+
177+
@property
178+
def sensor_dirty_time_left(self) -> int | None:
179+
"""
180+
Returns estimated time until sensors need cleaning in minutes.
181+
Maintenance interval is typically 30 hours (1800 minutes).
182+
"""
183+
if self.main_sensor is None:
184+
return None
185+
return max(0, 1800 - self.main_sensor)
186+
187+
@property
188+
def status_name(self) -> str | None:
189+
"""Returns the name of the current status."""
190+
return self.status.name if self.status is not None else None
191+
192+
@property
193+
def fault_name(self) -> str | None:
194+
"""Returns the name of the current fault."""
195+
return self.fault.name if self.fault is not None else None
196+
197+
@property
198+
def wind_name(self) -> str | None:
199+
"""Returns the name of the current fan speed (wind)."""
200+
return self.wind.name if self.wind is not None else None
201+
202+
@property
203+
def work_mode_name(self) -> str | None:
204+
"""Returns the name of the current work mode."""
205+
return self.work_mode.name if self.work_mode is not None else None

roborock/data/code_mappings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ def from_code(cls, code: int):
7070
return member
7171
raise ValueError(f"{code} is not a valid code for {cls.__name__}")
7272

73+
@classmethod
74+
def keys(cls) -> list[str]:
75+
"""Returns a list of all member names."""
76+
return [member.name for member in cls]
77+
7378

7479
ProductInfo = namedtuple("ProductInfo", ["nickname", "short_models"])
7580

0 commit comments

Comments
 (0)