Skip to content

Commit fa058bd

Browse files
committed
refactor: Make V1TraitDataConverter an abstract base class, use a dedicated LedStatusConverter, and fix a typo in Rooms.
1 parent 64162ba commit fa058bd

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

roborock/devices/traits/v1/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
V1ResponseData = dict | list | int | str
1919

2020

21-
class V1TraitDataConverter:
21+
class V1TraitDataConverter(ABC):
2222
"""Converts responses to RoborockBase objects.
2323
2424
This is an internal class and should not be used directly by consumers.

roborock/devices/traits/v1/device_features.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self, product: HomeDataProduct) -> None:
1818
def convert(self, response: common.V1ResponseData) -> DeviceFeatures:
1919
"""Parse the response from the device into a MapContentTrait instance."""
2020
if not isinstance(response, list):
21-
raise ValueError(f"Unexpected AppInitStatus response format: {type(response)}")
21+
raise ValueError(f"Unexpected AppInitStatus response format: {type(response)}: {response!r}")
2222
app_status = AppInitStatus.from_dict(response[0])
2323
return DeviceFeatures.from_feature_flags(
2424
new_feature_info=app_status.new_feature_info,

roborock/devices/traits/v1/led_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class LedStatusTrait(LedStatus, common.V1TraitMixin, common.RoborockSwitchBase):
2626
"""Trait for controlling the LED status of a Roborock device."""
2727

2828
command = RoborockCommand.GET_LED_STATUS
29-
converter = common.DefaultConverter(LedStatus)
29+
converter = LedStatusConverter()
3030
requires_feature = "is_led_status_switch_supported"
3131

3232
@property

roborock/devices/traits/v1/rooms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def room_map(self) -> dict[int, NamedRoomMapping]:
2525
return {}
2626
return {room.segment_id: room for room in self.rooms}
2727

28-
def with_rooom_names(self, name_map: dict[str, str]) -> "Rooms":
28+
def with_room_names(self, name_map: dict[str, str]) -> "Rooms":
2929
"""Create a new Rooms object with updated room names."""
3030
return Rooms(
3131
rooms=[
@@ -102,7 +102,7 @@ async def refresh(self) -> None:
102102
segment_map = self.converter.extract_segment_map(response)
103103
await self._populate_missing_home_data_rooms(segment_map)
104104
rooms = self.converter.convert(response)
105-
rooms = rooms.with_rooom_names(self._iot_id_room_name_map)
105+
rooms = rooms.with_room_names(self._iot_id_room_name_map)
106106
common.merge_trait_values(self, rooms)
107107

108108
@property

0 commit comments

Comments
 (0)