Skip to content

Commit 21d535a

Browse files
author
NOisi-X
committed
style(zeo): fix pre-commit findings (formatting, unused import, no-redef)
1 parent 6cf8d98 commit 21d535a

6 files changed

Lines changed: 25 additions & 67 deletions

File tree

‎roborock/data/zeo/zeo_containers.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Data containers for Zeo (washing machine / dryer) devices."""
22

33
from dataclasses import dataclass, field
4-
from typing import Any
54

65
from ..containers import RoborockBase
76
from .zeo_code_mappings import (

‎roborock/devices/traits/a01/__init__.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,7 @@ async def set_value(self, protocol: RoborockZeoProtocol, value: Any) -> dict[Rob
461461

462462
async def get_custom_mode(self) -> ZeoCustomMode | ZeoDryerCustomMode | None:
463463
"""Query and decode the current custom programme (DP 222)."""
464-
await self.query_values(
465-
[RoborockZeoProtocol.CUSTOM_PARAM_GET, RoborockZeoProtocol.TOTAL_TIME]
466-
)
464+
await self.query_values([RoborockZeoProtocol.CUSTOM_PARAM_GET, RoborockZeoProtocol.TOTAL_TIME])
467465
raw = self._dps_cache.get(int(RoborockZeoProtocol.CUSTOM_PARAM_GET))
468466
if raw is None:
469467
return None

‎roborock/devices/traits/a01/command.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
RoborockZeoProtocol.WASH_DRY_LINKED: ("wash_dry_linkage", "wash_dry_linked"),
2525
}
2626

27+
2728
class ZeoCommandTrait:
2829
"""Trait for sending commands to Zeo devices."""
2930

@@ -52,7 +53,7 @@ def __init__(
5253
async def start_with(self, params: ZeoStartParams) -> dict[RoborockZeoProtocol, Any]:
5354
"""Start the device with the given programme parameters.
5455
55-
This is the primary start API: the caller needs to provide the
56+
This is the primary start API: the caller needs to provide the
5657
parameters like mode/program/options/etc.
5758
5859
Returns the DPs that were actually sent.
@@ -110,7 +111,7 @@ async def start_with_custom_mode(self) -> dict[RoborockZeoProtocol, Any]:
110111
"""Start the device using its saved custom programme.
111112
112113
Reads the device's custom programme (DP 222, see
113-
:meth:`ZeoApi.get_custom_mode`) and starts with those parameters.
114+
:meth:`ZeoApi.get_custom_mode`) and starts with those parameters.
114115
115116
Raises :class:`ValueError` when the device has no saved custom
116117
programme.
@@ -138,14 +139,14 @@ async def preset_with(self, params: ZeoStartParams, minutes: int) -> dict[Roboro
138139
Returns the DPs that were sent.
139140
"""
140141
if minutes <= 0:
141-
dps: dict[RoborockZeoProtocol, Any] = {RoborockZeoProtocol.COUNTDOWN: 0}
142+
cancel_dps: dict[RoborockZeoProtocol, Any] = {RoborockZeoProtocol.COUNTDOWN: 0}
142143
await send_decoded_command(
143144
self._channel,
144-
dps,
145+
cancel_dps,
145146
qos=MqttQos.AT_LEAST_ONCE,
146147
value_encoder=lambda x: x,
147148
)
148-
return dps
149+
return cancel_dps
149150
dps: dict[RoborockZeoProtocol, Any] = {RoborockZeoProtocol.START: 1}
150151
dps.update(build_param_dps(params))
151152
dps.update(self._build_auto_dosing_dps())

‎roborock/devices/traits/a01/settings.py‎

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,7 @@ def auto_softener(self) -> bool | None:
182182
return self.softener_type is not None and self.softener_type != ZeoSoftenerType.empty
183183
return self.softener_set
184184

185-
async def _set_enum(
186-
self, dp: RoborockZeoProtocol, enum_cls: type[_T], value: _T
187-
) -> dict[RoborockZeoProtocol, Any]:
185+
async def _set_enum(self, dp: RoborockZeoProtocol, enum_cls: type[_T], value: _T) -> dict[RoborockZeoProtocol, Any]:
188186
"""Validate *value* against *enum_cls* and send it to the device."""
189187
if not isinstance(value, enum_cls):
190188
raise TypeError(f"Expected {enum_cls.__name__}, got {type(value).__name__}")
@@ -289,16 +287,12 @@ async def set_softener_type(self, softener_type: ZeoSoftenerType) -> dict[Roboro
289287
}
290288
return await self._send(dps)
291289

292-
async def set_detergent_box_type(
293-
self, expansion_type: ZeoDetergentExpansionType
294-
) -> dict[RoborockZeoProtocol, Any]:
290+
async def set_detergent_box_type(self, expansion_type: ZeoDetergentExpansionType) -> dict[RoborockZeoProtocol, Any]:
295291
"""Set the detergent expansion type (DP 248)."""
296292
dps = {RoborockZeoProtocol.DETERGENT_EXPANSION_TYPE: int(expansion_type)}
297293
return await self._send(dps)
298294

299-
async def set_softener_box_type(
300-
self, expansion_type: ZeoSoftenerExpansionType
301-
) -> dict[RoborockZeoProtocol, Any]:
295+
async def set_softener_box_type(self, expansion_type: ZeoSoftenerExpansionType) -> dict[RoborockZeoProtocol, Any]:
302296
"""Set the softener expansion type (DP 245)."""
303297
dps = {RoborockZeoProtocol.SOFTENER_EXPANSION_TYPE: int(expansion_type)}
304298
return await self._send(dps)
@@ -326,20 +320,12 @@ async def set_voice_volume(self, volume: int) -> dict[RoborockZeoProtocol, Any]:
326320

327321
async def set_voice_switch(self, enabled: bool) -> dict[RoborockZeoProtocol, Any]:
328322
"""Enable/disable voice assistant (DP 10301)."""
329-
dps = {
330-
RoborockZeoProtocol.VOICE_SWITCH: json.dumps(
331-
{"speech_switch": 1 if enabled else 0}
332-
)
333-
}
323+
dps = {RoborockZeoProtocol.VOICE_SWITCH: json.dumps({"speech_switch": 1 if enabled else 0})}
334324
return await self._send(dps)
335325

336326
async def delete_voice_record(self, record_id: str) -> dict[RoborockZeoProtocol, Any]:
337327
"""Delete a voice record by id (DP 10304)."""
338-
dps = {
339-
RoborockZeoProtocol.VOICE_RECORD_DELETE: json.dumps(
340-
{"dialog_delete": record_id}
341-
)
342-
}
328+
dps = {RoborockZeoProtocol.VOICE_RECORD_DELETE: json.dumps({"dialog_delete": record_id})}
343329
return await self._send(dps)
344330

345331
async def set_sound_package(self, package: dict[str, Any]) -> dict[RoborockZeoProtocol, Any]:

‎roborock/devices/traits/a01/status.py‎

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,20 @@ class ZeoStatusTrait(RoborockBase, TraitUpdateListener):
3737
state: ZeoState | None = field(default=None, metadata={"dps": RoborockZeoProtocol.STATE})
3838
error: ZeoError | None = field(default=None, metadata={"dps": RoborockZeoProtocol.ERROR})
3939
washing_left: int | None = field(default=None, metadata={"dps": RoborockZeoProtocol.WASHING_LEFT})
40-
doorlock_state: bool | None = field(
41-
default=None, metadata={"dps": RoborockZeoProtocol.DOORLOCK_STATE}
42-
)
43-
times_after_clean: int | None = field(
44-
default=None, metadata={"dps": RoborockZeoProtocol.TIMES_AFTER_CLEAN}
45-
)
46-
app_authorization: bool | None = field(
47-
default=None, metadata={"dps": RoborockZeoProtocol.APP_AUTHORIZATION}
48-
)
40+
doorlock_state: bool | None = field(default=None, metadata={"dps": RoborockZeoProtocol.DOORLOCK_STATE})
41+
times_after_clean: int | None = field(default=None, metadata={"dps": RoborockZeoProtocol.TIMES_AFTER_CLEAN})
42+
app_authorization: bool | None = field(default=None, metadata={"dps": RoborockZeoProtocol.APP_AUTHORIZATION})
4943

5044
# Washer-specific status (None on dryers).
5145
dirt_detection_status: ZeoDirtDetectionStatus | None = field(
5246
default=None, metadata={"dps": RoborockZeoProtocol.DIRT_DETECTION_STATUS}
5347
)
54-
detergent_empty: bool | None = field(
55-
default=None, metadata={"dps": RoborockZeoProtocol.DETERGENT_EMPTY}
56-
)
57-
softener_empty: bool | None = field(
58-
default=None, metadata={"dps": RoborockZeoProtocol.SOFTENER_EMPTY}
59-
)
48+
detergent_empty: bool | None = field(default=None, metadata={"dps": RoborockZeoProtocol.DETERGENT_EMPTY})
49+
softener_empty: bool | None = field(default=None, metadata={"dps": RoborockZeoProtocol.SOFTENER_EMPTY})
6050

6151
# Dryer-specific status (None on washers).
6252
total_time: int | None = field(default=None, metadata={"dps": RoborockZeoProtocol.TOTAL_TIME})
63-
cloth_put_in: bool | None = field(
64-
default=None, metadata={"dps": RoborockZeoProtocol.CLOTH_PUT_IN}
65-
)
53+
cloth_put_in: bool | None = field(default=None, metadata={"dps": RoborockZeoProtocol.CLOTH_PUT_IN})
6654
cloth_ready_to_dry_count_down: int | None = field(
6755
default=None, metadata={"dps": RoborockZeoProtocol.CLOTH_READY_TO_DRY_COUNT_DOWN}
6856
)
@@ -71,15 +59,11 @@ class ZeoStatusTrait(RoborockBase, TraitUpdateListener):
7159
)
7260

7361
# Smart-hosting status.
74-
smart_hosting_time: int | None = field(
75-
default=None, metadata={"dps": RoborockZeoProtocol.SMART_HOSTING_TIME}
76-
)
62+
smart_hosting_time: int | None = field(default=None, metadata={"dps": RoborockZeoProtocol.SMART_HOSTING_TIME})
7763
smart_hosting_waited_time: int | None = field(
7864
default=None, metadata={"dps": RoborockZeoProtocol.SMART_HOSTING_WAITED_TIME}
7965
)
80-
is_need_fluff_clean: bool | None = field(
81-
default=None, metadata={"dps": RoborockZeoProtocol.IS_NEED_FLUFF_CLEAN}
82-
)
66+
is_need_fluff_clean: bool | None = field(default=None, metadata={"dps": RoborockZeoProtocol.IS_NEED_FLUFF_CLEAN})
8367

8468
# Other read-only status.
8569
custom_program_cleaning_time: int | None = field(
@@ -91,20 +75,12 @@ class ZeoStatusTrait(RoborockBase, TraitUpdateListener):
9175
panel_timing_program_params: int | None = field(
9276
default=None, metadata={"dps": RoborockZeoProtocol.PANEL_TIMING_PROGRAM_PARAMS}
9377
)
94-
steam_care_time: int | None = field(
95-
default=None, metadata={"dps": RoborockZeoProtocol.STEAM_CARE_TIME}
96-
)
97-
device_bound: bool | None = field(
98-
default=None, metadata={"dps": RoborockZeoProtocol.DEVICE_BOUND}
99-
)
78+
steam_care_time: int | None = field(default=None, metadata={"dps": RoborockZeoProtocol.STEAM_CARE_TIME})
79+
device_bound: bool | None = field(default=None, metadata={"dps": RoborockZeoProtocol.DEVICE_BOUND})
10080

10181
# Meta — device-reported JSON documents (read-only).
102-
product_info: dict[str, Any] | None = field(
103-
default=None, metadata={"dps": RoborockZeoProtocol.PRODUCT_INFO}
104-
)
105-
washing_log: ZeoWashLog | None = field(
106-
default=None, metadata={"dps": RoborockZeoProtocol.WASHING_LOG}
107-
)
82+
product_info: dict[str, Any] | None = field(default=None, metadata={"dps": RoborockZeoProtocol.PRODUCT_INFO})
83+
washing_log: ZeoWashLog | None = field(default=None, metadata={"dps": RoborockZeoProtocol.WASHING_LOG})
10884

10985
def __init__(self) -> None:
11086
"""Initialize the status trait."""

‎roborock/roborock_message.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,7 @@ class RoborockZeoProtocol(RoborockEnum):
179179
SILENT_MODE_ON = 240 # rw [independent] use set_silent_mode() for bundled set
180180
SILENT_MODE_START_TIME = 241 # rw [independent] minute-of-day
181181
SILENT_MODE_END_TIME = 242 # rw [independent] minute-of-day
182-
UNKNOWN_243 = (
183-
243 # int, present in MQTT push from some devices, increments with each push
184-
)
182+
UNKNOWN_243 = 243 # int, present in MQTT push from some devices, increments with each push
185183
DRY_CARE_MODE = 244 # rw [startWith]
186184
SOFTENER_EXPANSION_TYPE = 245 # rw [independent]
187185
UNKNOWN_246 = 246

0 commit comments

Comments
 (0)