Skip to content

Commit 8e2a06e

Browse files
committed
fix: clean up some naming
1 parent 2f3ee9c commit 8e2a06e

File tree

8 files changed

+41
-40
lines changed

8 files changed

+41
-40
lines changed

roborock/devices/device_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ def device_creator(home_data: HomeData, device: HomeDataDevice, product: HomeDat
201201
f"Device {device.name} has unsupported version B01_{product.model.strip('.')[-1]}"
202202
)
203203
elif "sc" in product.model.strip(".")[-1]:
204-
trait = b01.sc.create(channel)
204+
# Q7 devices start with 'sc' in their model naming.
205+
trait = b01.q7.create(channel)
205206
case _:
206207
raise NotImplementedError(f"Device {device.name} has unsupported version {device.pv}")
207208
return RoborockDevice(device, product, channel, trait)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Traits for B01 devices."""
22

3-
from .sc import PropertiesApi
3+
from .q7 import Q7PropertiesApi
44

5-
__all__ = ["PropertiesApi", "sc", "ss"]
5+
__all__ = ["q&PropertiesApi", "q7", "q10"]
File renamed without changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""Traits for Q7 B01 devices.
2+
Potentially other devices may fall into this category in the future."""
3+
4+
from roborock.devices.b01_channel import send_decoded_command
5+
from roborock.devices.mqtt_channel import MqttChannel
6+
from roborock.devices.traits import Trait
7+
from roborock.roborock_message import RoborockB01Props
8+
from roborock.roborock_typing import RoborockB01Q7Methods
9+
10+
__all__ = [
11+
"Q7PropertiesApi",
12+
]
13+
14+
15+
class Q7PropertiesApi(Trait):
16+
"""API for interacting with Q7 B01 devices."""
17+
18+
def __init__(self, channel: MqttChannel) -> None:
19+
"""Initialize the B01Props API."""
20+
self._channel = channel
21+
22+
async def query_values(self, props: list[RoborockB01Props]) -> None:
23+
"""Query the device for the values of the given Q7 protocols."""
24+
await send_decoded_command(
25+
self._channel, dps=10000, command=RoborockB01Q7Methods.GET_PROP, params={"property": props}
26+
)
27+
28+
29+
def create(channel: MqttChannel) -> Q7PropertiesApi:
30+
"""Create traits for B01 devices."""
31+
return Q7PropertiesApi(channel)

roborock/devices/traits/b01/sc/__init__.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

roborock/devices/traits/traits_mixin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class TraitsMixin:
3131
zeo: a01.ZeoApi | None = None
3232
"""Zeo API, if supported."""
3333

34-
b01_properties: b01.PropertiesApi | None = None
35-
"""B01 properties trait, if supported."""
34+
b01_q7_properties: b01.Q7PropertiesApi | None = None
35+
"""B01 Q7 properties trait, if supported."""
3636

3737
def __init__(self, trait: Trait) -> None:
3838
"""Initialize the TraitsMixin with the given trait.

roborock/protocols/b01_protocol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from Crypto.Cipher import AES
88
from Crypto.Util.Padding import pad, unpad
99

10-
from roborock import RoborockB01Methods
10+
from roborock import RoborockB01Q7Methods
1111
from roborock.exceptions import RoborockException
1212
from roborock.roborock_message import (
1313
RoborockMessage,
@@ -18,7 +18,7 @@
1818
_LOGGER = logging.getLogger(__name__)
1919

2020
B01_VERSION = b"B01"
21-
CommandType = RoborockB01Methods | str
21+
CommandType = RoborockB01Q7Methods | str
2222
ParamsType = list | dict | int | None
2323

2424

roborock/roborock_typing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ class RoborockCommand(str, Enum):
271271
APP_GET_ROBOT_SETTING = "app_get_robot_setting"
272272

273273

274-
class RoborockB01Methods(StrEnum):
275-
"""Methods used by the Roborock B01 model."""
274+
class RoborockB01Q7Methods(StrEnum):
275+
"""Methods used by the Roborock Q7 model."""
276276

277277
GET_PROP = "prop.get"
278278
GET_MAP_LIST = "service.get_map_list"

0 commit comments

Comments
 (0)