python-roborock 7.8.0__py3-none-any.whl → 7.8.2__py3-none-any.whl

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.5
2
2
  Name: python-roborock
3
- Version: 7.8.0
3
+ Version: 7.8.2
4
4
  Summary: A package to control Roborock vacuums.
5
5
  Project-URL: Repository, https://github.com/python-roborock/python-roborock
6
6
  Project-URL: Documentation, https://python-roborock.readthedocs.io/
@@ -11,7 +11,7 @@ roborock/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  roborock/roborock_message.py,sha256=VWsytnm7nQqOMBj7oYbiqPPqwE9qClDSI03CFuHXsds,11822
12
12
  roborock/roborock_typing.py,sha256=xppavdf57-Cu6elj3MP403uT75Tjw5Zs6bLGPLQmZf4,15483
13
13
  roborock/util.py,sha256=4zibjn2MgPrLCiha66LUXZj907LOXUtNzugbbb0NIlo,1634
14
- roborock/web_api.py,sha256=ypW9e11U0jNXnyIQO9UN0DnIdz4c6AxtJlUJmjuEl-o,40514
14
+ roborock/web_api.py,sha256=-igt3Y4-kOoWX4mKkjt-P-7t7uHxNGkOm11-_W2ge0c,42065
15
15
  roborock/data/__init__.py,sha256=jSZHOrd-LfVN-TdBkjNW334ef99rGBz4-hPT_7KvoLs,278
16
16
  roborock/data/code_mappings.py,sha256=j-ZZRtQQdIMJQAgEwDAxWKreNhD6U36oIhBKr_nLbis,9783
17
17
  roborock/data/containers.py,sha256=ePz1tmhNY1QpgiVlyc8j6PH5kjU6fkZYtBByCFj2wzU,17896
@@ -126,8 +126,8 @@ roborock/testing/channel.py,sha256=vjulT5MHBe8lAq6XITUqcxJVcCILWx7ZEcw5imTx0Tk,7
126
126
  roborock/testing/cloud.py,sha256=L2L0KlZDYaMuoV19KUQUoq5EAUDeNQ1lJ8Ew5YaOgjo,11946
127
127
  roborock/testing/simulator.py,sha256=g8ZUWVSjgAzuRRxWOCeOq-7deodyEItwUpqEw9RzCmQ,4347
128
128
  roborock/testing/v1_simulator.py,sha256=_LX_vsBMcB2Uu2QDt8QnQymgtVtbnwD5Xa7tmhiPAnY,14439
129
- python_roborock-7.8.0.dist-info/METADATA,sha256=oab4MAQUTzua8lpKUIFMyFlMK0ihrRYSJ1xdVY5B1Bw,5278
130
- python_roborock-7.8.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
131
- python_roborock-7.8.0.dist-info/entry_points.txt,sha256=EvC1nMqi9ZXKgZnqlNXA33v_3nzgPNjnM0mzWlrehnY,47
132
- python_roborock-7.8.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
133
- python_roborock-7.8.0.dist-info/RECORD,,
129
+ python_roborock-7.8.2.dist-info/METADATA,sha256=gGL_22pmtd_9mGvWO7QMZm5qAqivJqNpeXrBzhYdEYA,5278
130
+ python_roborock-7.8.2.dist-info/WHEEL,sha256=THafob7ofN-NsuMN7Mg4qZyHaQI7KkD-QlcQatYhXPo,87
131
+ python_roborock-7.8.2.dist-info/entry_points.txt,sha256=EvC1nMqi9ZXKgZnqlNXA33v_3nzgPNjnM0mzWlrehnY,47
132
+ python_roborock-7.8.2.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
133
+ python_roborock-7.8.2.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.32.0
2
+ Generator: hatchling 1.32.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
roborock/web_api.py CHANGED
@@ -38,6 +38,10 @@ BASE_URLS = [
38
38
  "https://ruiot.roborock.com",
39
39
  ]
40
40
 
41
+ # Fallback user agreement version, used only if the latest version cannot be fetched.
42
+ DEFAULT_AGREEMENT_MAJOR_VERSION = 14
43
+ DEFAULT_AGREEMENT_MINOR_VERSION = 0
44
+
41
45
 
42
46
  @dataclass
43
47
  class IotLoginInfo:
@@ -292,6 +296,34 @@ class RoborockApiClient:
292
296
 
293
297
  return code_response["data"]["k"]
294
298
 
299
+ async def _get_agreement_version(self, country: str) -> dict[str, int]:
300
+ """Get the latest user agreement version for the given country.
301
+
302
+ The login endpoint rejects a stale agreement version with code 3006. The
303
+ current version differs per server and per country, so it must be looked
304
+ up rather than hardcoded. Falls back to the previously hardcoded values
305
+ if the lookup fails so that login is never blocked by this request.
306
+ """
307
+ try:
308
+ base_url = await self.base_url
309
+ agreement_request = PreparedRequest(base_url, self.session, {"header_clientlang": "en"})
310
+ response = await agreement_request.request(
311
+ "get",
312
+ "/api/v3/app/agreement/latest",
313
+ params={"country": country},
314
+ )
315
+ if response is not None and response.get("code") == 200:
316
+ data = response.get("data") or {}
317
+ major = data.get("majorVersion")
318
+ minor = data.get("minorVersion")
319
+ if isinstance(major, int) and isinstance(minor, int):
320
+ _LOGGER.debug("Using user agreement version %s.%s for %s", major, minor, country)
321
+ return {"majorVersion": major, "minorVersion": minor}
322
+ _LOGGER.debug("Unexpected agreement version response: %s", response)
323
+ except RoborockException as err:
324
+ _LOGGER.debug("Could not fetch latest user agreement version: %s", err)
325
+ return {"majorVersion": DEFAULT_AGREEMENT_MAJOR_VERSION, "minorVersion": DEFAULT_AGREEMENT_MINOR_VERSION}
326
+
295
327
  async def code_login_v4(
296
328
  self, code: int | str, country: str | None = None, country_code: int | None = None
297
329
  ) -> UserData:
@@ -334,10 +366,7 @@ class RoborockApiClient:
334
366
  "countryCode": country_code,
335
367
  "email": self._username,
336
368
  "code": code,
337
- # Major and minor version are the user agreement version, we will need to see if this needs to be
338
- # dynamic https://usiot.roborock.com/api/v3/app/agreement/latest?country=US
339
- "majorVersion": 14,
340
- "minorVersion": 0,
369
+ **await self._get_agreement_version(country),
341
370
  },
342
371
  )
343
372
  if login_response is None: