aioamazondevices 3.2.2__py3-none-any.whl → 3.2.4__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
  """aioamazondevices library."""
2
2
 
3
- __version__ = "3.2.2"
3
+ __version__ = "3.2.4"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
aioamazondevices/api.py CHANGED
@@ -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,
@@ -148,9 +150,15 @@ class AmazonEchoApi:
148
150
  self.session: ClientSession
149
151
  self._devices: dict[str, Any] = {}
150
152
 
151
- lang_object = Language.make(territory=self._login_country_code.upper())
152
- lang_maximized = lang_object.maximize()
153
- self._language = f"{lang_maximized.language}-{lang_maximized.region}"
153
+ if locale and (lang := locale.get("language")):
154
+ language = lang
155
+ else:
156
+ lang_object = Language.make(territory=self._login_country_code.upper())
157
+ lang_maximized = lang_object.maximize()
158
+ language = f"{lang_maximized.language}-{lang_maximized.region}"
159
+
160
+ self._language = language
161
+
154
162
  _LOGGER.debug(
155
163
  "Initialize library with domain <%s> and language <%s>",
156
164
  self._domain,
@@ -330,6 +338,16 @@ class AmazonEchoApi:
330
338
  )
331
339
  return False
332
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
+
333
351
  async def _session_request(
334
352
  self,
335
353
  method: str,
@@ -395,10 +413,10 @@ class AmazonEchoApi:
395
413
  HTTPStatus.PROXY_AUTHENTICATION_REQUIRED,
396
414
  HTTPStatus.UNAUTHORIZED,
397
415
  ]:
398
- raise CannotAuthenticate(HTTPStatus(resp.status).phrase)
416
+ raise CannotAuthenticate(self._http_phrase_error(resp.status))
399
417
  if not await self._ignore_ap_signin_error(resp):
400
418
  raise CannotRetrieveData(
401
- f"Request failed: {HTTPStatus(resp.status).phrase}"
419
+ f"Request failed: {self._http_phrase_error(resp.status)}"
402
420
  )
403
421
 
404
422
  await self._save_to_file(
@@ -509,7 +527,7 @@ class AmazonEchoApi:
509
527
  obfuscate_email(self._login_email),
510
528
  msg,
511
529
  )
512
- raise CannotRegisterDevice(f"{HTTPStatus(resp.status).phrase}: {msg}")
530
+ raise CannotRegisterDevice(f"{self._http_phrase_error(resp.status)}: {msg}")
513
531
 
514
532
  success_response = resp_json["response"]["success"]
515
533
 
aioamazondevices/const.py CHANGED
@@ -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",
@@ -34,6 +37,7 @@ DOMAIN_BY_ISO3166_COUNTRY = {
34
37
  },
35
38
  "at": {
36
39
  "domain": "de",
40
+ "language": "en-US",
37
41
  "openid.assoc_handle": f"{DEFAULT_ASSOC_HANDLE}_de",
38
42
  },
39
43
  "au": {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: aioamazondevices
3
- Version: 3.2.2
3
+ Version: 3.2.4
4
4
  Summary: Python library to control Amazon devices
5
5
  License: Apache-2.0
6
6
  Author: Simone Chemelli
@@ -0,0 +1,11 @@
1
+ aioamazondevices/__init__.py,sha256=q9wQ9Tf4eUuqR8QchKhODo4PnwT1vb0SI5IAD9BWr7k,276
2
+ aioamazondevices/api.py,sha256=VCOcIufsCHYKRBAC-q5Yfwj5Cek8Wt-ZT7o2Lg0kzyU,39691
3
+ aioamazondevices/const.py,sha256=d2kBbZXOf-RF18c4C3hwrIqDqaXhL6KzO1iSSL9_ST4,8759
4
+ aioamazondevices/exceptions.py,sha256=CfOFKDvE_yl5BFoFcpTOuDfgRi_2oAtKk-nNJgfWBAs,726
5
+ aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ aioamazondevices/sounds.py,sha256=01pVCDFIuhrLypXInw4JNuHsC6zjMLsuKocet1R6we8,13409
7
+ aioamazondevices/utils.py,sha256=RzuKRhnq_8ymCoJMoQJ2vBYyuew06RSWpqQWmqdNczE,2019
8
+ aioamazondevices-3.2.4.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
9
+ aioamazondevices-3.2.4.dist-info/METADATA,sha256=uuwxpCyN_I64zyfIfTnzCv3pOCJrec9_3i6-Y9QpWlM,5234
10
+ aioamazondevices-3.2.4.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
11
+ aioamazondevices-3.2.4.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- aioamazondevices/__init__.py,sha256=qelvi3_OmLOGJDAwlKAmQe5biPKQ8p0sbMx3c2Tpif0,276
2
- aioamazondevices/api.py,sha256=yIU0w95V9v7fDlArNK26azOtogBX8yxJJKBJbA_UWKs,39169
3
- aioamazondevices/const.py,sha256=q2TlD1O4jPtQ-hIxCCZuD-uoXCFNudF11JSjSC2hClY,8687
4
- aioamazondevices/exceptions.py,sha256=CfOFKDvE_yl5BFoFcpTOuDfgRi_2oAtKk-nNJgfWBAs,726
5
- aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- aioamazondevices/sounds.py,sha256=01pVCDFIuhrLypXInw4JNuHsC6zjMLsuKocet1R6we8,13409
7
- aioamazondevices/utils.py,sha256=RzuKRhnq_8ymCoJMoQJ2vBYyuew06RSWpqQWmqdNczE,2019
8
- aioamazondevices-3.2.2.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
9
- aioamazondevices-3.2.2.dist-info/METADATA,sha256=JIkelm9RwNWUra00wyvNp_wR09BNskKA-NFF013cbHU,5234
10
- aioamazondevices-3.2.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
11
- aioamazondevices-3.2.2.dist-info/RECORD,,