aioamazondevices 3.2.6__py3-none-any.whl → 3.2.8__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.
- aioamazondevices/__init__.py +1 -1
- aioamazondevices/api.py +38 -17
- {aioamazondevices-3.2.6.dist-info → aioamazondevices-3.2.8.dist-info}/METADATA +1 -1
- {aioamazondevices-3.2.6.dist-info → aioamazondevices-3.2.8.dist-info}/RECORD +6 -6
- {aioamazondevices-3.2.6.dist-info → aioamazondevices-3.2.8.dist-info}/LICENSE +0 -0
- {aioamazondevices-3.2.6.dist-info → aioamazondevices-3.2.8.dist-info}/WHEEL +0 -0
aioamazondevices/__init__.py
CHANGED
aioamazondevices/api.py
CHANGED
@@ -84,6 +84,7 @@ class AmazonDevice:
|
|
84
84
|
device_type: str
|
85
85
|
device_owner_customer_id: str
|
86
86
|
device_cluster_members: list[str]
|
87
|
+
device_locale: str
|
87
88
|
online: bool
|
88
89
|
serial_number: str
|
89
90
|
software_version: str
|
@@ -338,6 +339,14 @@ class AmazonEchoApi:
|
|
338
339
|
)
|
339
340
|
return False
|
340
341
|
|
342
|
+
async def _ignore_phoenix_error(self, response: ClientResponse) -> bool:
|
343
|
+
"""Return true if error is due to phoenix endpoint."""
|
344
|
+
# Endpoint URI_IDS replies with error 199 or 299
|
345
|
+
# during maintenance
|
346
|
+
return response.status in [HTTP_ERROR_199, HTTP_ERROR_299] and (
|
347
|
+
URI_IDS in response.url.path
|
348
|
+
)
|
349
|
+
|
341
350
|
async def _http_phrase_error(self, error: int) -> str:
|
342
351
|
"""Convert numeric error in human phrase."""
|
343
352
|
if error == HTTP_ERROR_199:
|
@@ -413,10 +422,12 @@ class AmazonEchoApi:
|
|
413
422
|
HTTPStatus.PROXY_AUTHENTICATION_REQUIRED,
|
414
423
|
HTTPStatus.UNAUTHORIZED,
|
415
424
|
]:
|
416
|
-
raise CannotAuthenticate(self._http_phrase_error(resp.status))
|
417
|
-
if not await self._ignore_ap_signin_error(
|
425
|
+
raise CannotAuthenticate(await self._http_phrase_error(resp.status))
|
426
|
+
if not await self._ignore_ap_signin_error(
|
427
|
+
resp
|
428
|
+
) and not await self._ignore_phoenix_error(resp):
|
418
429
|
raise CannotRetrieveData(
|
419
|
-
f"Request failed: {self._http_phrase_error(resp.status)}"
|
430
|
+
f"Request failed: {await self._http_phrase_error(resp.status)}"
|
420
431
|
)
|
421
432
|
|
422
433
|
await self._save_to_file(
|
@@ -527,7 +538,9 @@ class AmazonEchoApi:
|
|
527
538
|
obfuscate_email(self._login_email),
|
528
539
|
msg,
|
529
540
|
)
|
530
|
-
raise CannotRegisterDevice(
|
541
|
+
raise CannotRegisterDevice(
|
542
|
+
f"{await self._http_phrase_error(resp.status)}: {msg}"
|
543
|
+
)
|
531
544
|
|
532
545
|
success_response = resp_json["response"]["success"]
|
533
546
|
|
@@ -572,20 +585,19 @@ class AmazonEchoApi:
|
|
572
585
|
|
573
586
|
resp_me_json = await resp_me.json()
|
574
587
|
market = resp_me_json["marketPlaceDomainName"]
|
575
|
-
language = resp_me_json["marketPlaceLocale"]
|
576
588
|
|
577
589
|
_domain = f"https://www.amazon.{self._domain}"
|
578
590
|
|
579
|
-
if market != _domain
|
580
|
-
_LOGGER.
|
581
|
-
"Selected country <%s> doesn't matches Amazon
|
591
|
+
if market != _domain:
|
592
|
+
_LOGGER.warning(
|
593
|
+
"Selected country <%s> doesn't matches Amazon API reply:\n%s\n vs \n%s",
|
582
594
|
self._login_country_code.upper(),
|
583
|
-
{"site ": _domain
|
584
|
-
{"market": market
|
595
|
+
{"site ": _domain},
|
596
|
+
{"market": market},
|
585
597
|
)
|
586
598
|
raise WrongCountry
|
587
599
|
|
588
|
-
_LOGGER.debug("User selected country matches Amazon
|
600
|
+
_LOGGER.debug("User selected country matches Amazon API one")
|
589
601
|
|
590
602
|
async def _get_devices_ids(self) -> list[dict[str, str]]:
|
591
603
|
"""Retrieve devices entityId and applianceId."""
|
@@ -594,6 +606,16 @@ class AmazonEchoApi:
|
|
594
606
|
url=f"https://alexa.amazon.{self._domain}{URI_IDS}",
|
595
607
|
amazon_user_agent=False,
|
596
608
|
)
|
609
|
+
|
610
|
+
# Sensors data not available
|
611
|
+
if raw_resp.status != HTTPStatus.OK:
|
612
|
+
_LOGGER.warning(
|
613
|
+
"Sensors data not available [%s error '%s'], skipping",
|
614
|
+
URI_IDS,
|
615
|
+
await self._http_phrase_error(raw_resp.status),
|
616
|
+
)
|
617
|
+
return []
|
618
|
+
|
597
619
|
json_data = await raw_resp.json()
|
598
620
|
|
599
621
|
network_detail = orjson.loads(json_data["networkDetail"])
|
@@ -830,7 +852,7 @@ class AmazonEchoApi:
|
|
830
852
|
if not devices_node or (devices_node.get("deviceType") in DEVICE_TO_IGNORE):
|
831
853
|
continue
|
832
854
|
|
833
|
-
preferences_node = device.get(NODE_PREFERENCES)
|
855
|
+
preferences_node = device.get(NODE_PREFERENCES, {})
|
834
856
|
do_not_disturb_node = device[NODE_DO_NOT_DISTURB]
|
835
857
|
bluetooth_node = device[NODE_BLUETOOTH]
|
836
858
|
identifier_node = device.get(NODE_IDENTIFIER, {})
|
@@ -852,13 +874,12 @@ class AmazonEchoApi:
|
|
852
874
|
device_cluster_members=(
|
853
875
|
devices_node["clusterMembers"] or [serial_number]
|
854
876
|
),
|
877
|
+
device_locale=preferences_node.get("locale", self._language),
|
855
878
|
online=devices_node["online"],
|
856
879
|
serial_number=serial_number,
|
857
880
|
software_version=devices_node["softwareVersion"],
|
858
881
|
do_not_disturb=do_not_disturb_node["enabled"],
|
859
|
-
response_style=(
|
860
|
-
preferences_node["responseStyle"] if preferences_node else None
|
861
|
-
),
|
882
|
+
response_style=preferences_node.get("responseStyle"),
|
862
883
|
bluetooth_state=bluetooth_node["online"],
|
863
884
|
entity_id=identifier_node.get("entityId"),
|
864
885
|
appliance_id=identifier_node.get("applianceId"),
|
@@ -925,7 +946,7 @@ class AmazonEchoApi:
|
|
925
946
|
base_payload = {
|
926
947
|
"deviceType": device.device_type,
|
927
948
|
"deviceSerialNumber": device.serial_number,
|
928
|
-
"locale":
|
949
|
+
"locale": device.device_locale,
|
929
950
|
"customerId": device.device_owner_customer_id,
|
930
951
|
}
|
931
952
|
|
@@ -960,7 +981,7 @@ class AmazonEchoApi:
|
|
960
981
|
"expireAfter": "PT5S",
|
961
982
|
"content": [
|
962
983
|
{
|
963
|
-
"locale":
|
984
|
+
"locale": device.device_locale,
|
964
985
|
"display": {
|
965
986
|
"title": "Home Assistant",
|
966
987
|
"body": message_body,
|
@@ -1,11 +1,11 @@
|
|
1
|
-
aioamazondevices/__init__.py,sha256=
|
2
|
-
aioamazondevices/api.py,sha256=
|
1
|
+
aioamazondevices/__init__.py,sha256=W7DER8aV-e-yKCMzNIRzrK4atTh5CSbPVGmumiVNPlc,276
|
2
|
+
aioamazondevices/api.py,sha256=jDXVTwR4yA-yPskCqpmeT9CCN-EGuHQqQmjVwcU9L1o,40399
|
3
3
|
aioamazondevices/const.py,sha256=mgPTTRLLets0vU8MTvVA3pGWGHCgVLMBRZWsIVtCG8s,9043
|
4
4
|
aioamazondevices/exceptions.py,sha256=CfOFKDvE_yl5BFoFcpTOuDfgRi_2oAtKk-nNJgfWBAs,726
|
5
5
|
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
aioamazondevices/sounds.py,sha256=01pVCDFIuhrLypXInw4JNuHsC6zjMLsuKocet1R6we8,13409
|
7
7
|
aioamazondevices/utils.py,sha256=RzuKRhnq_8ymCoJMoQJ2vBYyuew06RSWpqQWmqdNczE,2019
|
8
|
-
aioamazondevices-3.2.
|
9
|
-
aioamazondevices-3.2.
|
10
|
-
aioamazondevices-3.2.
|
11
|
-
aioamazondevices-3.2.
|
8
|
+
aioamazondevices-3.2.8.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
9
|
+
aioamazondevices-3.2.8.dist-info/METADATA,sha256=nsCTEGVeOr37isIHVQgDCUrV72xuUMn7wtFLwc3WhlY,5234
|
10
|
+
aioamazondevices-3.2.8.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
11
|
+
aioamazondevices-3.2.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|