|
5 | 5 | import logging
|
6 | 6 | from dataclasses import dataclass, field
|
7 | 7 | from datetime import datetime, timedelta
|
8 |
| -from enum import IntEnum |
| 8 | +from typing import cast |
9 | 9 |
|
10 | 10 | from mashumaro import DataClassDictMixin, field_options
|
11 | 11 | from mashumaro.types import SerializationStrategy
|
12 | 12 |
|
13 | 13 | from ...feature import Feature
|
14 |
| -from ..smartmodule import SmartModule |
| 14 | +from ..smartmodule import Module, SmartModule |
| 15 | +from .clean import AreaUnit, Clean |
15 | 16 |
|
16 | 17 | _LOGGER = logging.getLogger(__name__)
|
17 | 18 |
|
18 | 19 |
|
19 |
| -class AreaUnit(IntEnum): |
20 |
| - """Area unit.""" |
21 |
| - |
22 |
| - Sqm = 0 |
23 |
| - Sqft = 1 |
24 |
| - Ping = 2 |
25 |
| - |
26 |
| - |
27 | 20 | @dataclass
|
28 | 21 | class LatestRecord(DataClassDictMixin):
|
29 | 22 | """Stats from last clean."""
|
@@ -131,7 +124,7 @@ class VacuumRecords(SmartModule):
|
131 | 124 |
|
132 | 125 | async def _post_update_hook(self) -> None:
|
133 | 126 | """Cache parsed data after an update."""
|
134 |
| - self._parsed_data = Records.from_dict(self.data["getCleanRecords"]) |
| 127 | + self._parsed_data = Records.from_dict(self.data) |
135 | 128 |
|
136 | 129 | def _initialize_features(self) -> None:
|
137 | 130 | """Initialize features."""
|
@@ -186,7 +179,6 @@ def query(self) -> dict:
|
186 | 179 | """Query to execute during the update cycle."""
|
187 | 180 | return {
|
188 | 181 | "getCleanRecords": {},
|
189 |
| - "getAreaUnit": {}, |
190 | 182 | }
|
191 | 183 |
|
192 | 184 | @property
|
@@ -222,7 +214,8 @@ def last_clean_timestamp(self) -> datetime:
|
222 | 214 | @property
|
223 | 215 | def area_unit(self) -> AreaUnit:
|
224 | 216 | """Return area unit."""
|
225 |
| - return AreaUnit(self.data["getAreaUnit"]["area_unit"]) |
| 217 | + clean = cast(Clean, self._device._modules[Module.Clean]) |
| 218 | + return clean.area_unit |
226 | 219 |
|
227 | 220 | @property
|
228 | 221 | def parsed_data(self) -> Records:
|
|
0 commit comments