aioamazondevices 3.2.3__tar.gz → 3.2.5__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.3
2
2
  Name: aioamazondevices
3
- Version: 3.2.3
3
+ Version: 3.2.5
4
4
  Summary: Python library to control Amazon devices
5
5
  License: Apache-2.0
6
6
  Author: Simone Chemelli
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aioamazondevices"
3
- version = "3.2.3"
3
+ version = "3.2.5"
4
4
  requires-python = ">=3.12"
5
5
  description = "Python library to control Amazon devices"
6
6
  authors = [
@@ -1,6 +1,6 @@
1
1
  """aioamazondevices library."""
2
2
 
3
- __version__ = "3.2.3"
3
+ __version__ = "3.2.5"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
@@ -39,6 +39,8 @@ from .const import (
39
39
  DEVICE_TYPE_TO_MODEL,
40
40
  DOMAIN_BY_ISO3166_COUNTRY,
41
41
  HTML_EXTENSION,
42
+ HTTP_ERROR_199,
43
+ HTTP_ERROR_299,
42
44
  JSON_EXTENSION,
43
45
  NODE_BLUETOOTH,
44
46
  NODE_DEVICES,
@@ -336,6 +338,16 @@ class AmazonEchoApi:
336
338
  )
337
339
  return False
338
340
 
341
+ async def _http_phrase_error(self, error: int) -> str:
342
+ """Convert numeric error in human phrase."""
343
+ if error == HTTP_ERROR_199:
344
+ return "Miscellaneous Warning"
345
+
346
+ if error == HTTP_ERROR_299:
347
+ return "Miscellaneous Persistent Warning"
348
+
349
+ return HTTPStatus(error).phrase
350
+
339
351
  async def _session_request(
340
352
  self,
341
353
  method: str,
@@ -401,10 +413,10 @@ class AmazonEchoApi:
401
413
  HTTPStatus.PROXY_AUTHENTICATION_REQUIRED,
402
414
  HTTPStatus.UNAUTHORIZED,
403
415
  ]:
404
- raise CannotAuthenticate(HTTPStatus(resp.status).phrase)
416
+ raise CannotAuthenticate(self._http_phrase_error(resp.status))
405
417
  if not await self._ignore_ap_signin_error(resp):
406
418
  raise CannotRetrieveData(
407
- f"Request failed: {HTTPStatus(resp.status).phrase}"
419
+ f"Request failed: {self._http_phrase_error(resp.status)}"
408
420
  )
409
421
 
410
422
  await self._save_to_file(
@@ -515,7 +527,7 @@ class AmazonEchoApi:
515
527
  obfuscate_email(self._login_email),
516
528
  msg,
517
529
  )
518
- raise CannotRegisterDevice(f"{HTTPStatus(resp.status).phrase}: {msg}")
530
+ raise CannotRegisterDevice(f"{self._http_phrase_error(resp.status)}: {msg}")
519
531
 
520
532
  success_response = resp_json["response"]["success"]
521
533
 
@@ -6,6 +6,9 @@ _LOGGER = logging.getLogger(__package__)
6
6
 
7
7
  DEFAULT_ASSOC_HANDLE = "amzn_dp_project_dee_ios"
8
8
 
9
+ HTTP_ERROR_199 = 199
10
+ HTTP_ERROR_299 = 299
11
+
9
12
  TO_REDACT = {
10
13
  "address",
11
14
  "address1",
@@ -51,6 +54,10 @@ DOMAIN_BY_ISO3166_COUNTRY = {
51
54
  "domain": "co.uk",
52
55
  "openid.assoc_handle": f"{DEFAULT_ASSOC_HANDLE}_uk",
53
56
  },
57
+ "il": {
58
+ "domain": "com",
59
+ "openid.assoc_handle": DEFAULT_ASSOC_HANDLE,
60
+ },
54
61
  "jp": {
55
62
  "domain": "co.jp",
56
63
  },