|
13 | 13 | calibration, path placement and overlay placement remain inside the renderer. |
14 | 14 | """ |
15 | 15 |
|
16 | | -import dataclasses |
17 | 16 | import logging |
18 | 17 | from dataclasses import dataclass, field |
19 | | -from enum import Enum |
20 | 18 | from typing import Any |
21 | 19 |
|
22 | 20 | from roborock.data import RoborockBase |
23 | 21 | from roborock.data.b01_q10.b01_q10_code_mappings import B01_Q10_DP, YXDeviceState |
24 | | -from roborock.data.containers import _camelize |
25 | 22 | from roborock.devices.traits.common import DpsDataConverter, TraitUpdateListener |
26 | 23 | from roborock.exceptions import RoborockException |
27 | 24 | from roborock.map.b01_q10_map_parser import ( |
@@ -163,22 +160,11 @@ def _render(self) -> None: |
163 | 160 |
|
164 | 161 | def as_dict(self, exclude: set[str] | None = None) -> dict[str, Any]: |
165 | 162 | """Return the trait data as a dictionary, excluding large binary data.""" |
166 | | - |
167 | | - def _to_camel_dict(obj: Any) -> Any: |
168 | | - return dataclasses.asdict( |
169 | | - obj, |
170 | | - dict_factory=lambda _fields: { |
171 | | - _camelize(key): value.value if isinstance(value, Enum) else value |
172 | | - for (key, value) in _fields |
173 | | - if value is not None |
174 | | - }, |
175 | | - ) |
176 | | - |
177 | 163 | exclude_set = exclude or set() |
178 | 164 | data = { |
179 | | - "rooms": [_to_camel_dict(room) for room in self.rooms], |
180 | | - "path": [_to_camel_dict(point) for point in self.path], |
181 | | - "robotPosition": _to_camel_dict(self.robot_position) if self.robot_position is not None else None, |
| 165 | + "rooms": [room.as_dict() for room in self.rooms], |
| 166 | + "path": [point.as_dict() for point in self.path], |
| 167 | + "robotPosition": self.robot_position.as_dict() if self.robot_position is not None else None, |
182 | 168 | "robotHeading": self.robot_heading, |
183 | 169 | } |
184 | 170 | for key in exclude_set: |
|
0 commit comments