python-roborock 4.0.1__tar.gz → 4.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_roborock-4.0.1 → python_roborock-4.1.0}/PKG-INFO +1 -1
- {python_roborock-4.0.1 → python_roborock-4.1.0}/pyproject.toml +1 -1
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/code_mappings.py +18 -5
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/device_manager.py +3 -1
- python_roborock-4.1.0/roborock/protocols/b01_q10_protocol.py +88 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/.gitignore +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/LICENSE +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/README.md +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/broadcast_protocol.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/callbacks.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/cli.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/const.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/b01_q10/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/b01_q10/b01_q10_code_mappings.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/b01_q10/b01_q10_containers.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/b01_q7/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/b01_q7/b01_q7_code_mappings.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/b01_q7/b01_q7_containers.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/containers.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/dyad/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/dyad/dyad_code_mappings.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/dyad/dyad_containers.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/v1/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/v1/v1_clean_modes.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/v1/v1_code_mappings.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/v1/v1_containers.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/zeo/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/zeo/zeo_code_mappings.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/zeo/zeo_containers.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/device_features.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/README.md +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/a01_channel.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/b01_q7_channel.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/cache.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/channel.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/device.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/file_cache.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/local_channel.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/mqtt_channel.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/a01/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/b01/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/b01/q10/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/b01/q7/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/traits_mixin.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/child_lock.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/clean_summary.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/command.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/common.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/consumeable.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/device_features.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/do_not_disturb.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/dust_collection_mode.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/flow_led_status.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/home.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/led_status.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/map_content.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/maps.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/network_info.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/rooms.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/routines.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/smart_wash_params.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/status.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/valley_electricity_timer.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/volume.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/wash_towel_mode.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/v1_channel.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/diagnostics.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/exceptions.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/map/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/map/map_parser.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/mqtt/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/mqtt/health_manager.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/mqtt/roborock_session.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/mqtt/session.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/protocol.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/protocols/__init__.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/protocols/a01_protocol.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/protocols/b01_q7_protocol.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/protocols/v1_protocol.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/py.typed +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/roborock_message.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/roborock_typing.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/util.py +0 -0
- {python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/web_api.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-roborock
|
|
3
|
-
Version: 4.0
|
|
3
|
+
Version: 4.1.0
|
|
4
4
|
Summary: A package to control Roborock vacuums.
|
|
5
5
|
Project-URL: Repository, https://github.com/humbertogontijo/python-roborock
|
|
6
6
|
Project-URL: Documentation, https://python-roborock.readthedocs.io/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "python-roborock"
|
|
3
|
-
version = "4.0
|
|
3
|
+
version = "4.1.0"
|
|
4
4
|
description = "A package to control Roborock vacuums."
|
|
5
5
|
authors = [{ name = "humbertogontijo", email = "humbertogontijo@users.noreply.github.com" }, {name="Lash-L"}, {name="allenporter"}]
|
|
6
6
|
requires-python = ">=3.11, <4"
|
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import logging
|
|
4
4
|
from collections import namedtuple
|
|
5
5
|
from enum import Enum, IntEnum, StrEnum
|
|
6
|
+
from typing import Self
|
|
6
7
|
|
|
7
8
|
_LOGGER = logging.getLogger(__name__)
|
|
8
9
|
completed_warnings = set()
|
|
@@ -55,8 +56,9 @@ class RoborockModeEnum(StrEnum):
|
|
|
55
56
|
"""A custom StrEnum that also stores an integer code for each member."""
|
|
56
57
|
|
|
57
58
|
code: int
|
|
59
|
+
"""The integer code associated with the enum member."""
|
|
58
60
|
|
|
59
|
-
def __new__(cls, value: str, code: int) ->
|
|
61
|
+
def __new__(cls, value: str, code: int) -> Self:
|
|
60
62
|
"""Creates a new enum member."""
|
|
61
63
|
member = str.__new__(cls, value)
|
|
62
64
|
member._value_ = value
|
|
@@ -64,14 +66,25 @@ class RoborockModeEnum(StrEnum):
|
|
|
64
66
|
return member
|
|
65
67
|
|
|
66
68
|
@classmethod
|
|
67
|
-
def from_code(cls, code: int) ->
|
|
69
|
+
def from_code(cls, code: int) -> Self:
|
|
68
70
|
for member in cls:
|
|
69
71
|
if member.code == code:
|
|
70
72
|
return member
|
|
71
|
-
|
|
73
|
+
message = f"{code} is not a valid code for {cls.__name__}"
|
|
74
|
+
if message not in completed_warnings:
|
|
75
|
+
completed_warnings.add(message)
|
|
76
|
+
_LOGGER.warning(message)
|
|
77
|
+
raise ValueError(message)
|
|
72
78
|
|
|
73
79
|
@classmethod
|
|
74
|
-
def
|
|
80
|
+
def from_code_optional(cls, code: int) -> RoborockModeEnum | None:
|
|
81
|
+
try:
|
|
82
|
+
return cls.from_code(code)
|
|
83
|
+
except ValueError:
|
|
84
|
+
return None
|
|
85
|
+
|
|
86
|
+
@classmethod
|
|
87
|
+
def from_value(cls, value: str) -> Self:
|
|
75
88
|
"""Find enum member by string value (case-insensitive)."""
|
|
76
89
|
for member in cls:
|
|
77
90
|
if member.value.lower() == value.lower():
|
|
@@ -79,7 +92,7 @@ class RoborockModeEnum(StrEnum):
|
|
|
79
92
|
raise ValueError(f"{value} is not a valid value for {cls.__name__}")
|
|
80
93
|
|
|
81
94
|
@classmethod
|
|
82
|
-
def from_name(cls, name: str) ->
|
|
95
|
+
def from_name(cls, name: str) -> Self:
|
|
83
96
|
"""Find enum member by name (case-insensitive)."""
|
|
84
97
|
for member in cls:
|
|
85
98
|
if member.name.lower() == name.lower():
|
|
@@ -186,6 +186,7 @@ async def create_device_manager(
|
|
|
186
186
|
session: aiohttp.ClientSession | None = None,
|
|
187
187
|
ready_callback: DeviceReadyCallback | None = None,
|
|
188
188
|
mqtt_session_unauthorized_hook: SessionUnauthorizedHook | None = None,
|
|
189
|
+
prefer_cache: bool = True,
|
|
189
190
|
) -> DeviceManager:
|
|
190
191
|
"""Convenience function to create and initialize a DeviceManager.
|
|
191
192
|
|
|
@@ -198,6 +199,7 @@ async def create_device_manager(
|
|
|
198
199
|
mqtt_session_unauthorized_hook: Optional hook for MQTT session unauthorized
|
|
199
200
|
events which may indicate rate limiting or revoked credentials. The
|
|
200
201
|
caller may use this to refresh authentication tokens as needed.
|
|
202
|
+
prefer_cache: Whether to prefer cached device data over always fetching it from the API.
|
|
201
203
|
|
|
202
204
|
Returns:
|
|
203
205
|
An initialized DeviceManager with discovered devices.
|
|
@@ -259,5 +261,5 @@ async def create_device_manager(
|
|
|
259
261
|
return dev
|
|
260
262
|
|
|
261
263
|
manager = DeviceManager(web_api, device_creator, mqtt_session=mqtt_session, cache=cache, diagnostics=diagnostics)
|
|
262
|
-
await manager.discover_devices()
|
|
264
|
+
await manager.discover_devices(prefer_cache)
|
|
263
265
|
return manager
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""Roborock B01 Protocol encoding and decoding."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import logging
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from roborock.data.b01_q10.b01_q10_code_mappings import B01_Q10_DP
|
|
8
|
+
from roborock.exceptions import RoborockException
|
|
9
|
+
from roborock.roborock_message import (
|
|
10
|
+
RoborockMessage,
|
|
11
|
+
RoborockMessageProtocol,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
_LOGGER = logging.getLogger(__name__)
|
|
15
|
+
|
|
16
|
+
B01_VERSION = b"B01"
|
|
17
|
+
ParamsType = list | dict | int | None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def encode_mqtt_payload(command: B01_Q10_DP, params: ParamsType) -> RoborockMessage:
|
|
21
|
+
"""Encode payload for B01 Q10 commands over MQTT.
|
|
22
|
+
|
|
23
|
+
This does not perform any special encoding for the command parameters and expects
|
|
24
|
+
them to already be in a request specific format.
|
|
25
|
+
"""
|
|
26
|
+
dps_data = {
|
|
27
|
+
"dps": {
|
|
28
|
+
# Important: some commands use falsy values so only default to `{}` when params is actually None.
|
|
29
|
+
command.code: params if params is not None else {},
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return RoborockMessage(
|
|
33
|
+
protocol=RoborockMessageProtocol.RPC_REQUEST,
|
|
34
|
+
version=B01_VERSION,
|
|
35
|
+
payload=json.dumps(dps_data).encode("utf-8"),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _convert_datapoints(datapoints: dict[str, Any], message: RoborockMessage) -> dict[B01_Q10_DP, Any]:
|
|
40
|
+
"""Convert the 'dps' dictionary keys from strings to B01_Q10_DP enums."""
|
|
41
|
+
result: dict[B01_Q10_DP, Any] = {}
|
|
42
|
+
for key, value in datapoints.items():
|
|
43
|
+
try:
|
|
44
|
+
code = int(key)
|
|
45
|
+
except ValueError as e:
|
|
46
|
+
raise ValueError(f"dps key is not a valid integer: {e} for {message.payload!r}") from e
|
|
47
|
+
if (dps := B01_Q10_DP.from_code_optional(code)) is not None:
|
|
48
|
+
# Update from_code to use `Self` on newer python version to remove this type ignore
|
|
49
|
+
result[dps] = value # type: ignore[index]
|
|
50
|
+
return result
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def decode_rpc_response(message: RoborockMessage) -> dict[B01_Q10_DP, Any]:
|
|
54
|
+
"""Decode a B01 Q10 RPC_RESPONSE message.
|
|
55
|
+
|
|
56
|
+
This does not perform any special decoding for the response body, but does
|
|
57
|
+
convert the 'dps' keys from strings to B01_Q10_DP enums.
|
|
58
|
+
"""
|
|
59
|
+
if not message.payload:
|
|
60
|
+
raise RoborockException("Invalid B01 message format: missing payload")
|
|
61
|
+
try:
|
|
62
|
+
payload = json.loads(message.payload.decode())
|
|
63
|
+
except (json.JSONDecodeError, UnicodeDecodeError) as e:
|
|
64
|
+
raise RoborockException(f"Invalid B01 json payload: {e} for {message.payload!r}") from e
|
|
65
|
+
|
|
66
|
+
if (datapoints := payload.get("dps")) is None:
|
|
67
|
+
raise RoborockException(f"Invalid B01 json payload: missing 'dps' for {message.payload!r}")
|
|
68
|
+
if not isinstance(datapoints, dict):
|
|
69
|
+
raise RoborockException(f"Invalid B01 message format: 'dps' should be a dictionary for {message.payload!r}")
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
result = _convert_datapoints(datapoints, message)
|
|
73
|
+
except ValueError as e:
|
|
74
|
+
raise RoborockException(f"Invalid B01 message format: {e}") from e
|
|
75
|
+
|
|
76
|
+
# The COMMON response contains nested datapoints need conversion. To simplify
|
|
77
|
+
# response handling at higher levels we flatten these into the main result.
|
|
78
|
+
if B01_Q10_DP.COMMON in result:
|
|
79
|
+
common_result = result.pop(B01_Q10_DP.COMMON)
|
|
80
|
+
if not isinstance(common_result, dict):
|
|
81
|
+
raise RoborockException(f"Invalid dpCommon format: expected dict, got {type(common_result).__name__}")
|
|
82
|
+
try:
|
|
83
|
+
common_dps_result = _convert_datapoints(common_result, message)
|
|
84
|
+
except ValueError as e:
|
|
85
|
+
raise RoborockException(f"Invalid dpCommon format: {e}") from e
|
|
86
|
+
result.update(common_dps_result)
|
|
87
|
+
|
|
88
|
+
return result
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/b01_q10/b01_q10_code_mappings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/data/b01_q7/b01_q7_code_mappings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/device_features.py
RENAMED
|
File without changes
|
{python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/do_not_disturb.py
RENAMED
|
File without changes
|
{python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/dust_collection_mode.py
RENAMED
|
File without changes
|
{python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/flow_led_status.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/smart_wash_params.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_roborock-4.0.1 → python_roborock-4.1.0}/roborock/devices/traits/v1/wash_towel_mode.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|