8000 Use areaunit from clean module · python-kasa/python-kasa@5a551ce · GitHub
[go: up one dir, main page]

Skip to content

Commit 5a551ce

Browse files
committed
Use areaunit from clean module
1 parent d4ef31d commit 5a551ce

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

kasa/smart/modules/vacuumrecords.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,18 @@
55
import logging
66
from dataclasses import dataclass, field
77
from datetime import datetime, timedelta
8-
from enum import IntEnum
8+
from typing import cast
99

1010
from mashumaro import DataClassDictMixin, field_options
1111
from mashumaro.types import SerializationStrategy
1212

1313
from ...feature import Feature
14-
from ..smartmodule import SmartModule
14+
from ..smartmodule import Module, SmartModule
15+
from .clean import AreaUnit, Clean
1516

1617
_LOGGER = logging.getLogger(__name__)
1718

1819

19-
class AreaUnit(IntEnum):
20-
"""Area unit."""
21-
22-
Sqm = 0
23-
Sqft = 1
24-
Ping = 2
25-
26-
2720
@dataclass
2821
class LatestRecord(DataClassDictMixin):
2922
"""Stats from last clean."""
@@ -131,7 +124,7 @@ class VacuumRecords(SmartModule):
131124

132125
async def _post_update_hook(self) -> None:
133126
"""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)
135128

136129
def _initialize_features(self) -> None:
137130
"""Initialize features."""
@@ -186,7 +179,6 @@ def query(self) -> dict:
186179
"""Query to execute during the update cycle."""
187180
return {
188181
"getCleanRecords": {},
189-
"getAreaUnit": {},
190182
}
191183

192184
@property
@@ -222,7 +214,8 @@ def last_clean_timestamp(self) -> datetime:
222214
@property
223215
def area_unit(self) -> AreaUnit:
224216
"""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
226219

227220
@property
228221
def parsed_data(self) -> Records:

0 commit comments

Comments
 (0)
0