python-roborock 0.18.6__tar.gz → 0.18.8__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-roborock
3
- Version: 0.18.6
3
+ Version: 0.18.8
4
4
  Summary: A package to control Roborock vacuums.
5
5
  Home-page: https://github.com/humbertogontijo/python-roborock
6
6
  License: GPL-3.0-only
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-roborock"
3
- version = "0.18.6"
3
+ version = "0.18.8"
4
4
  description = "A package to control Roborock vacuums."
5
5
  authors = ["humbertogontijo <humbertogontijo@users.noreply.github.com>"]
6
6
  license = "GPL-3.0-only"
@@ -131,11 +131,11 @@ class RoborockFanSpeedV3(RoborockFanPowerCode):
131
131
 
132
132
 
133
133
  class RoborockFanSpeedE2(RoborockFanPowerCode):
134
- gentle = 41
135
- silent = 50
136
- standard = 68
137
- medium = 79
138
- turbo = 100
134
+ quiet = 101
135
+ balanced = 102
136
+ turbo = 103
137
+ max = 104
138
+ gentle = 105
139
139
 
140
140
 
141
141
  class RoborockFanSpeedS7(RoborockFanPowerCode):
@@ -9,7 +9,11 @@ import async_timeout
9
9
 
10
10
  from . import DeviceData
11
11
  from .api import COMMANDS_SECURED, QUEUE_TIMEOUT, RoborockClient
12
- from .exceptions import CommandVacuumError, RoborockConnectionException, RoborockException
12
+ from .exceptions import (
13
+ CommandVacuumError,
14
+ RoborockConnectionException,
15
+ RoborockException,
16
+ )
13
17
  from .protocol import MessageParser
14
18
  from .roborock_message import RoborockMessage, RoborockMessageProtocol
15
19
  from .roborock_typing import CommandInfoMap, RoborockCommand
@@ -47,10 +51,14 @@ class RoborockLocalClient(RoborockClient, asyncio.Protocol):
47
51
  return self.transport and self.transport.is_reading()
48
52
 
49
53
  async def keep_alive_func(self, _=None):
50
- await self.ping()
54
+ try:
55
+ await self.ping()
56
+ except RoborockException:
57
+ pass
51
58
  self.keep_alive_task = self.loop.call_later(10, lambda: asyncio.create_task(self.keep_alive_func()))
52
59
 
53
60
  async def async_connect(self) -> None:
61
+ should_ping = False
54
62
  async with self._mutex:
55
63
  try:
56
64
  if not self.is_connected():
@@ -61,10 +69,12 @@ class RoborockLocalClient(RoborockClient, asyncio.Protocol):
61
69
  lambda: self, self.host, 58867
62
70
  )
63
71
  _LOGGER.info(f"Connected to {self.host}")
64
- await self.hello()
65
- await self.keep_alive_func()
66
- except Exception as e:
72
+ should_ping = True
73
+ except BaseException as e:
67
74
  raise RoborockConnectionException(f"Failed connecting to {self.host}") from e
75
+ if should_ping:
76
+ await self.hello()
77
+ await self.keep_alive_func()
68
78
 
69
79
  def sync_disconnect(self) -> None:
70
80
  if self.transport and self.loop.is_running():
@@ -95,28 +105,33 @@ class RoborockLocalClient(RoborockClient, asyncio.Protocol):
95
105
  )
96
106
 
97
107
  async def hello(self):
98
- if self.is_connected():
99
- request_id = 1
100
- protocol = RoborockMessageProtocol.HELLO_REQUEST
101
- _LOGGER.debug(f"id={request_id} Requesting protocol {protocol.name}")
102
- try:
103
- return await self._send_message(
104
- RoborockMessage(protocol=protocol, payload=None, seq=request_id, version=b"1.0", random=22)
108
+ request_id = 1
109
+ protocol = RoborockMessageProtocol.HELLO_REQUEST
110
+ try:
111
+ return await self.send_message(
112
+ RoborockMessage(
113
+ protocol=protocol,
114
+ payload=None,
115
+ seq=request_id,
116
+ version=b"1.0",
117
+ random=22,
105
118
  )
106
- except Exception as e:
107
- _LOGGER.error(e)
119
+ )
120
+ except Exception as e:
121
+ _LOGGER.error(e)
108
122
 
109
123
  async def ping(self):
110
- if self.is_connected():
111
- request_id = 2
112
- protocol = RoborockMessageProtocol.PING_REQUEST
113
- _LOGGER.debug(f"id={request_id} Requesting protocol {protocol.name}")
114
- try:
115
- return await self._send_message(
116
- RoborockMessage(protocol=protocol, payload=None, seq=request_id, version=b"1.0", random=23)
117
- )
118
- except Exception as e:
119
- _LOGGER.error(e)
124
+ request_id = 2
125
+ protocol = RoborockMessageProtocol.PING_REQUEST
126
+ return await self.send_message(
127
+ RoborockMessage(
128
+ protocol=protocol,
129
+ payload=None,
130
+ seq=request_id,
131
+ version=b"1.0",
132
+ random=23,
133
+ )
134
+ )
120
135
 
121
136
  async def send_command(self, method: RoborockCommand, params: Optional[list | dict] = None):
122
137
  roborock_message = self.build_roborock_message(method, params)
@@ -136,12 +151,8 @@ class RoborockLocalClient(RoborockClient, asyncio.Protocol):
136
151
  (response, err) = await self._async_response(request_id, response_protocol)
137
152
  if err:
138
153
  raise CommandVacuumError("", err) from err
139
- method = (
140
- f"method {roborock_message.get_method()}"
141
- if roborock_message.protocol == 4
142
- else f"protocol {RoborockMessageProtocol(roborock_message.protocol).name}"
143
- )
144
- _LOGGER.debug(f"id={request_id} Response from {method}: {response}")
154
+ if roborock_message.protocol == 4:
155
+ _LOGGER.debug(f"id={request_id} Response from method {roborock_message.get_method()}: {response}")
145
156
  return response
146
157
 
147
158
  def _send_msg_raw(self, data: bytes):