Skip to content

Commit 2d4a191

Browse files
author
NOisi-X
committed
refactor(zeo): replace raw integer fields with enum types
Update ZeoStartParams, ZeoCustomMode, and ZeoDryerCustomMode to use typed enum fields (ZeoMode, ZeoProgram, ZeoTemperature, etc.) instead of raw int, aligning with the V1 container pattern in v1_containers.py. Rename shorthand fields (rinse_times→rinse, spin_level→spin) for consistency across all three classes. Unify drying-mode field naming.
1 parent 9077983 commit 2d4a191

1 file changed

Lines changed: 46 additions & 45 deletions

File tree

roborock/data/zeo/zeo_containers.py

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
from dataclasses import dataclass
44

55
from ..containers import RoborockBase
6+
from .zeo_code_mappings import (
7+
ZeoDryAndCare,
8+
ZeoDryingMethod,
9+
ZeoDryingMode,
10+
ZeoMode,
11+
ZeoProgram,
12+
ZeoRinse,
13+
ZeoSoak,
14+
ZeoSpin,
15+
ZeoSteamVolume,
16+
ZeoTemperature,
17+
)
618

719

820
@dataclass
@@ -14,23 +26,12 @@ class ZeoStartParams(RoborockBase):
1426
included when the device reports a non-None value.
1527
"""
1628

17-
mode: int
18-
"""Wash mode (e.g. wash, wash-and-dry, dry, treatment)."""
19-
20-
program: int
21-
"""Wash program (e.g. standard, quick, wool)."""
22-
23-
temp: int | None = None
24-
"""Water temperature (always ``None`` for dryers)."""
25-
26-
rinse_times: int | None = None
27-
"""Number of rinse cycles (always ``None`` for dryers)."""
28-
29-
spin_level: int | None = None
30-
"""Spin speed in RPM (always ``None`` for dryers)."""
31-
32-
drying_mode: int | None = None
33-
"""Drying mode (e.g. quick, iron, store)."""
29+
mode: ZeoMode
30+
program: ZeoProgram
31+
temperature: ZeoTemperature | None = None
32+
rinse: ZeoRinse | None = None
33+
spin: ZeoSpin | None = None
34+
drying_mode: ZeoDryingMode | None = None
3435

3536

3637
# ── DP 222 (LoadCloudProgram) bitfield decoder ──────────────────────────
@@ -48,31 +49,31 @@ class ZeoCustomMode(RoborockBase):
4849
always non-negative).
4950
"""
5051

51-
program: int
52+
program: ZeoProgram
5253
"""Wash program (bits 0-7)."""
5354

54-
mode: int
55+
mode: ZeoMode
5556
"""Wash mode (bits 8-9)."""
5657

57-
temperature: int
58+
temperature: ZeoTemperature
5859
"""Temperature (bits 10-12)."""
5960

60-
rinse: int
61+
rinse: ZeoRinse
6162
"""Rinse cycle (bits 13-15)."""
6263

63-
spin: int
64+
spin: ZeoSpin
6465
"""Spin speed (bits 16-18)."""
6566

66-
dry: int
67+
drying_mode: ZeoDryingMode
6768
"""Drying mode (bits 19-21)."""
6869

69-
soak: int
70+
soak: ZeoSoak
7071
"""Soak (bits 22-24)."""
7172

72-
dry_care_mode: int
73+
dry_and_care: ZeoDryAndCare
7374
"""Dry-care mode (bits 25-27)."""
7475

75-
steam_volume: int
76+
steam_volume: ZeoSteamVolume
7677
"""Steam volume (bits 28-30)."""
7778

7879
total_time_min: int = 0
@@ -82,15 +83,15 @@ class ZeoCustomMode(RoborockBase):
8283
def from_raw(cls, raw: int, total_time_min: int | None = None) -> "ZeoCustomMode":
8384
"""Decode a raw 32-bit custom-programme value."""
8485
return cls(
85-
program=(raw & 0xFF),
86-
mode=(raw >> 8) & 0x3,
87-
temperature=(raw >> 10) & 0x7,
88-
rinse=(raw >> 13) & 0x7,
89-
spin=(raw >> 16) & 0x7,
90-
dry=(raw >> 19) & 0x7,
91-
soak=(raw >> 22) & 0x7,
92-
dry_care_mode=(raw >> 25) & 0x7,
93-
steam_volume=(raw >> 28) & 0x7,
86+
program=ZeoProgram(raw & 0xFF),
87+
mode=ZeoMode((raw >> 8) & 0x3),
88+
temperature=ZeoTemperature((raw >> 10) & 0x7),
89+
rinse=ZeoRinse((raw >> 13) & 0x7),
90+
spin=ZeoSpin((raw >> 16) & 0x7),
91+
drying_mode=ZeoDryingMode((raw >> 19) & 0x7),
92+
soak=ZeoSoak((raw >> 22) & 0x7),
93+
dry_and_care=ZeoDryAndCare((raw >> 25) & 0x7),
94+
steam_volume=ZeoSteamVolume((raw >> 28) & 0x7),
9495
total_time_min=total_time_min or 0,
9596
)
9697

@@ -104,19 +105,19 @@ class ZeoDryerCustomMode(RoborockBase):
104105
in module 725 of the plugin bundle.
105106
"""
106107

107-
program: int
108+
program: ZeoProgram
108109
"""Drying program (bits 0-7)."""
109110

110-
mode: int
111+
mode: ZeoMode
111112
"""Drying mode (bits 8-10)."""
112113

113-
dry: int
114+
drying_mode: ZeoDryingMode
114115
"""Drying level (bits 11-13)."""
115116

116-
dry_method: int
117+
drying_method: ZeoDryingMethod
117118
"""Drying method (bits 14-16)."""
118119

119-
steam_volume: int
120+
steam_volume: ZeoSteamVolume
120121
"""Steam volume (bits 17-19)."""
121122

122123
total_time_min: int = 0
@@ -126,14 +127,14 @@ class ZeoDryerCustomMode(RoborockBase):
126127
def from_raw(cls, raw: int, total_time_min: int | None = None) -> "ZeoDryerCustomMode":
127128
"""Decode a raw 32-bit dryer custom-programme value."""
128129
return cls(
129-
program=(raw & 0xFF),
130+
program=ZeoProgram(raw & 0xFF),
130131
# Dryer mode spans bits 8-10 (0x700, 3 bits) because the
131132
# temperature field is absent from the dryer bitfield and
132133
# bit 10 is re-allocated to mode. Washer uses 2 bits
133134
# (0x300, bits 8-9) to make room for temperature at 10-12.
134-
mode=(raw >> 8) & 0x7,
135-
dry=(raw >> 11) & 0x7,
136-
dry_method=(raw >> 14) & 0x7,
137-
steam_volume=(raw >> 17) & 0x7,
135+
mode=ZeoMode((raw >> 8) & 0x7),
136+
drying_mode=ZeoDryingMode((raw >> 11) & 0x7),
137+
drying_method=ZeoDryingMethod((raw >> 14) & 0x7),
138+
steam_volume=ZeoSteamVolume((raw >> 17) & 0x7),
138139
total_time_min=total_time_min or 0,
139140
)

0 commit comments

Comments
 (0)