aioamazondevices 6.2.6__py3-none-any.whl → 6.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.
Potentially problematic release.
This version of aioamazondevices might be problematic. Click here for more details.
- aioamazondevices/__init__.py +1 -1
- aioamazondevices/api.py +33 -23
- aioamazondevices/const.py +0 -3
- aioamazondevices/query.py +1 -1
- {aioamazondevices-6.2.6.dist-info → aioamazondevices-6.2.8.dist-info}/METADATA +1 -1
- aioamazondevices-6.2.8.dist-info/RECORD +12 -0
- {aioamazondevices-6.2.6.dist-info → aioamazondevices-6.2.8.dist-info}/WHEEL +1 -1
- aioamazondevices-6.2.6.dist-info/RECORD +0 -12
- {aioamazondevices-6.2.6.dist-info → aioamazondevices-6.2.8.dist-info}/licenses/LICENSE +0 -0
aioamazondevices/__init__.py
CHANGED
aioamazondevices/api.py
CHANGED
|
@@ -40,8 +40,6 @@ from .const import (
|
|
|
40
40
|
AMAZON_DEVICE_TYPE,
|
|
41
41
|
BIN_EXTENSION,
|
|
42
42
|
CSRF_COOKIE,
|
|
43
|
-
DEFAULT_AGENT,
|
|
44
|
-
DEFAULT_ASSOC_HANDLE,
|
|
45
43
|
DEFAULT_HEADERS,
|
|
46
44
|
DEFAULT_SITE,
|
|
47
45
|
DEVICE_TO_IGNORE,
|
|
@@ -88,6 +86,7 @@ class AmazonDevice:
|
|
|
88
86
|
device_family: str
|
|
89
87
|
device_type: str
|
|
90
88
|
device_owner_customer_id: str
|
|
89
|
+
household_device: bool
|
|
91
90
|
device_cluster_members: list[str]
|
|
92
91
|
online: bool
|
|
93
92
|
serial_number: str
|
|
@@ -138,6 +137,7 @@ class AmazonEchoApi:
|
|
|
138
137
|
self._save_raw_data = False
|
|
139
138
|
self._login_stored_data = login_data or {}
|
|
140
139
|
self._serial = self._serial_number()
|
|
140
|
+
self._account_owner_customer_id: str | None = None
|
|
141
141
|
self._list_for_clusters: dict[str, str] = {}
|
|
142
142
|
|
|
143
143
|
self._session = client_session
|
|
@@ -254,9 +254,9 @@ class AmazonEchoApi:
|
|
|
254
254
|
oauth_params = {
|
|
255
255
|
"openid.return_to": "https://www.amazon.com/ap/maplanding",
|
|
256
256
|
"openid.oa2.code_challenge_method": "S256",
|
|
257
|
-
"openid.assoc_handle":
|
|
257
|
+
"openid.assoc_handle": "amzn_dp_project_dee_ios",
|
|
258
258
|
"openid.identity": "http://specs.openid.net/auth/2.0/identifier_select",
|
|
259
|
-
"pageId":
|
|
259
|
+
"pageId": "amzn_dp_project_dee_ios",
|
|
260
260
|
"accountStatusPolicy": "P1",
|
|
261
261
|
"openid.claimed_id": "http://specs.openid.net/auth/2.0/identifier_select",
|
|
262
262
|
"openid.mode": "checkid_setup",
|
|
@@ -339,7 +339,6 @@ class AmazonEchoApi:
|
|
|
339
339
|
url: str,
|
|
340
340
|
input_data: dict[str, Any] | None = None,
|
|
341
341
|
json_data: bool = False,
|
|
342
|
-
amazon_user_agent: bool = True,
|
|
343
342
|
) -> tuple[BeautifulSoup, ClientResponse]:
|
|
344
343
|
"""Return request response context data."""
|
|
345
344
|
_LOGGER.debug(
|
|
@@ -352,9 +351,7 @@ class AmazonEchoApi:
|
|
|
352
351
|
|
|
353
352
|
headers = DEFAULT_HEADERS.copy()
|
|
354
353
|
headers.update({"Accept-Language": self._language})
|
|
355
|
-
|
|
356
|
-
_LOGGER.debug("Changing User-Agent to %s", DEFAULT_AGENT)
|
|
357
|
-
headers.update({"User-Agent": DEFAULT_AGENT})
|
|
354
|
+
|
|
358
355
|
if self._csrf_cookie:
|
|
359
356
|
csrf = {CSRF_COOKIE: self._csrf_cookie}
|
|
360
357
|
_LOGGER.debug("Adding to headers: %s", csrf)
|
|
@@ -370,14 +367,6 @@ class AmazonEchoApi:
|
|
|
370
367
|
)
|
|
371
368
|
self._session.cookie_jar.update_cookies(_cookies, URL(f"amazon.{self._domain}"))
|
|
372
369
|
|
|
373
|
-
if url.endswith("/auth/token"):
|
|
374
|
-
headers.update(
|
|
375
|
-
{
|
|
376
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
377
|
-
"x-amzn-identity-auth-domain": "api.amazon.com",
|
|
378
|
-
}
|
|
379
|
-
)
|
|
380
|
-
|
|
381
370
|
resp: ClientResponse | None = None
|
|
382
371
|
for delay in [0, 1, 2, 5, 8, 12, 21]:
|
|
383
372
|
if delay:
|
|
@@ -444,7 +433,7 @@ class AmazonEchoApi:
|
|
|
444
433
|
mimetypes.guess_extension(content_type.split(";")[0]) or ".raw",
|
|
445
434
|
)
|
|
446
435
|
|
|
447
|
-
return BeautifulSoup(await resp.read(), "html.parser"), resp
|
|
436
|
+
return BeautifulSoup(await resp.read() or "", "html.parser"), resp
|
|
448
437
|
|
|
449
438
|
async def _save_to_file(
|
|
450
439
|
self,
|
|
@@ -613,7 +602,19 @@ class AmazonEchoApi:
|
|
|
613
602
|
devices_sensors: dict[str, dict[str, AmazonDeviceSensor]] = {}
|
|
614
603
|
devices_endpoints: dict[str, dict[str, Any]] = {}
|
|
615
604
|
|
|
616
|
-
|
|
605
|
+
if error := devices_state.get("errors"):
|
|
606
|
+
if isinstance(error, list):
|
|
607
|
+
error = error[0]
|
|
608
|
+
msg = error.get("message", "Unknown error")
|
|
609
|
+
path = error.get("path", "Unknown path")
|
|
610
|
+
_LOGGER.error("Error retrieving devices state: %s for path %s", msg, path)
|
|
611
|
+
return {}, {}
|
|
612
|
+
|
|
613
|
+
if not (data := devices_state.get("data")) or not data.get("listEndpoints"):
|
|
614
|
+
_LOGGER.error("Malformed devices state data received: %s", devices_state)
|
|
615
|
+
return {}, {}
|
|
616
|
+
|
|
617
|
+
endpoints = data["listEndpoints"]
|
|
617
618
|
for endpoint in endpoints.get("endpoints"):
|
|
618
619
|
serial_number = (
|
|
619
620
|
endpoint["serialNumber"]["value"]["text"]
|
|
@@ -856,9 +857,14 @@ class AmazonEchoApi:
|
|
|
856
857
|
|
|
857
858
|
_LOGGER.debug("JSON devices data: %s", scrub_fields(json_data))
|
|
858
859
|
|
|
860
|
+
this_device_serial = self._login_stored_data["device_info"][
|
|
861
|
+
"device_serial_number"
|
|
862
|
+
]
|
|
859
863
|
for data in json_data["devices"]:
|
|
860
864
|
dev_serial = data.get("serialNumber")
|
|
861
865
|
self._devices[dev_serial] = data
|
|
866
|
+
if dev_serial == this_device_serial:
|
|
867
|
+
self._account_owner_customer_id = data["deviceOwnerCustomerId"]
|
|
862
868
|
|
|
863
869
|
devices_endpoints, devices_sensors = await self._get_sensors_states()
|
|
864
870
|
|
|
@@ -879,6 +885,8 @@ class AmazonEchoApi:
|
|
|
879
885
|
device_family=device["deviceFamily"],
|
|
880
886
|
device_type=device["deviceType"],
|
|
881
887
|
device_owner_customer_id=device["deviceOwnerCustomerId"],
|
|
888
|
+
household_device=device["deviceOwnerCustomerId"]
|
|
889
|
+
== self._account_owner_customer_id,
|
|
882
890
|
device_cluster_members=(device["clusterMembers"] or [serial_number]),
|
|
883
891
|
online=device["online"],
|
|
884
892
|
serial_number=serial_number,
|
|
@@ -953,7 +961,7 @@ class AmazonEchoApi:
|
|
|
953
961
|
"deviceType": device.device_type,
|
|
954
962
|
"deviceSerialNumber": device.serial_number,
|
|
955
963
|
"locale": self._language,
|
|
956
|
-
"customerId":
|
|
964
|
+
"customerId": self._account_owner_customer_id,
|
|
957
965
|
}
|
|
958
966
|
|
|
959
967
|
payload: dict[str, Any]
|
|
@@ -962,7 +970,7 @@ class AmazonEchoApi:
|
|
|
962
970
|
**base_payload,
|
|
963
971
|
"textToSpeak": message_body,
|
|
964
972
|
"target": {
|
|
965
|
-
"customerId":
|
|
973
|
+
"customerId": self._account_owner_customer_id,
|
|
966
974
|
"devices": [
|
|
967
975
|
{
|
|
968
976
|
"deviceSerialNumber": device.serial_number,
|
|
@@ -999,7 +1007,7 @@ class AmazonEchoApi:
|
|
|
999
1007
|
}
|
|
1000
1008
|
],
|
|
1001
1009
|
"target": {
|
|
1002
|
-
"customerId":
|
|
1010
|
+
"customerId": self._account_owner_customer_id,
|
|
1003
1011
|
"devices": playback_devices,
|
|
1004
1012
|
},
|
|
1005
1013
|
"skillId": "amzn1.ask.1p.routines.messaging",
|
|
@@ -1171,9 +1179,11 @@ class AmazonEchoApi:
|
|
|
1171
1179
|
"domain": f"www.amazon.{self._domain}",
|
|
1172
1180
|
}
|
|
1173
1181
|
|
|
1174
|
-
raw_resp = await self.
|
|
1182
|
+
_, raw_resp = await self._session_request(
|
|
1183
|
+
HTTPMethod.POST,
|
|
1175
1184
|
"https://api.amazon.com/auth/token",
|
|
1176
|
-
|
|
1185
|
+
input_data=data,
|
|
1186
|
+
json_data=False,
|
|
1177
1187
|
)
|
|
1178
1188
|
_LOGGER.debug(
|
|
1179
1189
|
"Refresh data response %s with payload %s",
|
aioamazondevices/const.py
CHANGED
|
@@ -4,8 +4,6 @@ import logging
|
|
|
4
4
|
|
|
5
5
|
_LOGGER = logging.getLogger(__package__)
|
|
6
6
|
|
|
7
|
-
DEFAULT_ASSOC_HANDLE = "amzn_dp_project_dee_ios"
|
|
8
|
-
|
|
9
7
|
HTTP_ERROR_199 = 199
|
|
10
8
|
HTTP_ERROR_299 = 299
|
|
11
9
|
|
|
@@ -48,7 +46,6 @@ DEFAULT_HEADERS = {
|
|
|
48
46
|
"Accept-Encoding": "gzip",
|
|
49
47
|
"Connection": "keep-alive",
|
|
50
48
|
}
|
|
51
|
-
DEFAULT_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0" # noqa: E501
|
|
52
49
|
CSRF_COOKIE = "csrf"
|
|
53
50
|
|
|
54
51
|
REFRESH_ACCESS_TOKEN = "access_token" # noqa: S105
|
aioamazondevices/query.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
QUERY_DEVICE_STATE = """
|
|
4
4
|
query getDevicesState ($latencyTolerance: LatencyToleranceValue) {
|
|
5
|
-
listEndpoints(listEndpointsInput: {}) {
|
|
5
|
+
listEndpoints(listEndpointsInput: { includeHouseholdDevices: true }) {
|
|
6
6
|
endpoints {
|
|
7
7
|
endpointId: id
|
|
8
8
|
friendlyNameObject { value { text } }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
aioamazondevices/__init__.py,sha256=fC_cVxoQ9UV0g3MPcq9xo24JwXEXPPXuU1x5i1IA00o,276
|
|
2
|
+
aioamazondevices/api.py,sha256=xJyDMmWDizrr4k8cpoUtr3FMb7A0K3y-ls9sbh3x0lw,44084
|
|
3
|
+
aioamazondevices/const.py,sha256=pPjMhNABj3rN8uvHzqj41tDiGPx-C50QRcSckvzX9z8,11561
|
|
4
|
+
aioamazondevices/exceptions.py,sha256=gRYrxNAJnrV6uRuMx5e76VMvtNKyceXd09q84pDBBrI,638
|
|
5
|
+
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
aioamazondevices/query.py,sha256=qLCuNyVlSbvVQmckZUsmftsz8s04GIukdidsOo4BrD0,2084
|
|
7
|
+
aioamazondevices/sounds.py,sha256=CXMDk-KoKVFxBdVAw3MeOClqgpzcVDxvQhFOJp7qX-Y,1896
|
|
8
|
+
aioamazondevices/utils.py,sha256=RzuKRhnq_8ymCoJMoQJ2vBYyuew06RSWpqQWmqdNczE,2019
|
|
9
|
+
aioamazondevices-6.2.8.dist-info/METADATA,sha256=HM04uPbCYPajVoqRxnrnywFsqV7YUmHDEupi0qWLd1k,7656
|
|
10
|
+
aioamazondevices-6.2.8.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
11
|
+
aioamazondevices-6.2.8.dist-info/licenses/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
|
12
|
+
aioamazondevices-6.2.8.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
aioamazondevices/__init__.py,sha256=2rkrcsrHU_OkLuxwVmHbM2zQIokytaNz17RY5Sme80U,276
|
|
2
|
-
aioamazondevices/api.py,sha256=h3LVTzj4f2unlD8PPyezBT0OsbF5viICIK8YhT2MoIU,43533
|
|
3
|
-
aioamazondevices/const.py,sha256=laRFapeQRpg3aGi10iCOH5OzBi1cnaPJX0s1phSl21w,11769
|
|
4
|
-
aioamazondevices/exceptions.py,sha256=gRYrxNAJnrV6uRuMx5e76VMvtNKyceXd09q84pDBBrI,638
|
|
5
|
-
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
aioamazondevices/query.py,sha256=AGHHzefzfYzB7RLWPtlFxYc_rpUZdoeApsU2jYz3urQ,2053
|
|
7
|
-
aioamazondevices/sounds.py,sha256=CXMDk-KoKVFxBdVAw3MeOClqgpzcVDxvQhFOJp7qX-Y,1896
|
|
8
|
-
aioamazondevices/utils.py,sha256=RzuKRhnq_8ymCoJMoQJ2vBYyuew06RSWpqQWmqdNczE,2019
|
|
9
|
-
aioamazondevices-6.2.6.dist-info/METADATA,sha256=us19gN-RKVrY6ICis6RkboCyMzStX5jHSTWbbfKfAXc,7656
|
|
10
|
-
aioamazondevices-6.2.6.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
|
|
11
|
-
aioamazondevices-6.2.6.dist-info/licenses/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
|
12
|
-
aioamazondevices-6.2.6.dist-info/RECORD,,
|
|
File without changes
|