1
- """Implementation of vacuum records for experimental vacuum support ."""
1
+ """Implementation of vacuum cleaning records ."""
2
2
3
3
from __future__ import annotations
4
4
5
5
import logging
6
+ from dataclasses import dataclass
6
7
from datetime import datetime
7
8
8
- from pydantic . v1 import BaseModel
9
+ from mashumaro import DataClassDictMixin
9
10
10
11
from ...feature import Feature
11
12
from ..smartmodule import SmartModule
12
13
13
14
_LOGGER = logging .getLogger (__name__ )
14
15
15
16
16
- class LatestRecord (BaseModel ):
17
+ @dataclass
18
+ class LatestRecord (DataClassDictMixin ):
17
19
"""Stats from last clean.
18
20
19
21
TODO: this is just a list-formatted Record, with only some fields being available.
@@ -25,7 +27,8 @@ class LatestRecord(BaseModel):
25
27
error : int # most likely
26
28
27
29
28
- class Record (BaseModel ):
30
+ @dataclass
31
+ class Record (DataClassDictMixin ):
29
32
"""Historical cleanup result.
30
33
31
34
Example:
@@ -55,7 +58,8 @@ class Record(BaseModel):
55
58
record_index : int
56
59
57
60
58
- class Records (BaseModel ):
61
+ @dataclass
62
+ class Records (DataClassDictMixin ):
59
63
"""Response payload for getCleanRecords.
60
64
61
65
Example:
@@ -85,30 +89,30 @@ class Records(BaseModel):
85
89
86
90
87
91
class VacuumRecords (SmartModule ):
88
- """Implementation of vacuum records for experimental vacuum support ."""
92
+ """Implementation of vacuum cleaning records ."""
89
93
90
94
REQUIRED_COMPONENT = "consumables"
91
95
QUERY_GETTER_NAME = "getCleanRecords"
92
96
93
- def _initialize_features (self ):
97
+ def _initialize_features (self ) -> None :
94
98
"""Initialize features."""
95
99
self ._add_feature (
96
100
Feature (
97
101
self ._device ,
98
- "total_clean_area" ,
99
- "Total area cleaned" ,
102
+ id = "total_clean_area" ,
103
+ name = "Total area cleaned" ,
100
104
container = self ,
101
105
attribute_getter = "total_clean_area" ,
102
- unit = "sqm" ,
106
+ unit_getter = lambda : "sqm" ,
103
107
category = Feature .Category .Info ,
104
108
type = Feature .Type .Sensor ,
105
109
)
106
110
)
107
111
self ._add_feature (
108
112
Feature (
109
113
self ._device ,
110
- "total_clean_time" ,
111
- "Total time cleaned" ,
114
+ id = "total_clean_time" ,
115
+ name = "Total time cleaned" ,
112
116
container = self ,
113
117
attribute_getter = "total_clean_time" ,
114
118
category = Feature .Category .Info ,
@@ -118,8 +122,8 @@ def _initialize_features(self):
118
122
self ._add_feature (
119
123
Feature (
120
124
self ._device ,
121
- "total_clean_count" ,
122
- "Total clean count" ,
125
+ id = "total_clean_count" ,
126
+ name = "Total clean count" ,
123
127
container = self ,
124
128
attribute_getter = "total_clean_count" ,
125
129
category = Feature .Category .Debug ,
0 commit comments