aioamazondevices 6.2.5__py3-none-any.whl → 6.2.7__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.

@@ -1,6 +1,6 @@
1
1
  """aioamazondevices library."""
2
2
 
3
- __version__ = "6.2.5"
3
+ __version__ = "6.2.7"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
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": DEFAULT_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": DEFAULT_ASSOC_HANDLE,
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
- if not amazon_user_agent:
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,
@@ -653,7 +642,7 @@ class AmazonEchoApi:
653
642
 
654
643
  value: str | int | float = "n/a"
655
644
  scale: str | None = None
656
- error = bool(sensor_template.get("error"))
645
+ error = bool(feature_property.get("error"))
657
646
  if not error:
658
647
  try:
659
648
  value_raw = feature_property[sensor_template["key"]]
@@ -856,9 +845,14 @@ class AmazonEchoApi:
856
845
 
857
846
  _LOGGER.debug("JSON devices data: %s", scrub_fields(json_data))
858
847
 
848
+ this_device_serial = self._login_stored_data["device_info"][
849
+ "device_serial_number"
850
+ ]
859
851
  for data in json_data["devices"]:
860
852
  dev_serial = data.get("serialNumber")
861
853
  self._devices[dev_serial] = data
854
+ if dev_serial == this_device_serial:
855
+ self._account_owner_customer_id = data["deviceOwnerCustomerId"]
862
856
 
863
857
  devices_endpoints, devices_sensors = await self._get_sensors_states()
864
858
 
@@ -879,6 +873,8 @@ class AmazonEchoApi:
879
873
  device_family=device["deviceFamily"],
880
874
  device_type=device["deviceType"],
881
875
  device_owner_customer_id=device["deviceOwnerCustomerId"],
876
+ household_device=device["deviceOwnerCustomerId"]
877
+ == self._account_owner_customer_id,
882
878
  device_cluster_members=(device["clusterMembers"] or [serial_number]),
883
879
  online=device["online"],
884
880
  serial_number=serial_number,
@@ -953,7 +949,7 @@ class AmazonEchoApi:
953
949
  "deviceType": device.device_type,
954
950
  "deviceSerialNumber": device.serial_number,
955
951
  "locale": self._language,
956
- "customerId": device.device_owner_customer_id,
952
+ "customerId": self._account_owner_customer_id,
957
953
  }
958
954
 
959
955
  payload: dict[str, Any]
@@ -962,7 +958,7 @@ class AmazonEchoApi:
962
958
  **base_payload,
963
959
  "textToSpeak": message_body,
964
960
  "target": {
965
- "customerId": device.device_owner_customer_id,
961
+ "customerId": self._account_owner_customer_id,
966
962
  "devices": [
967
963
  {
968
964
  "deviceSerialNumber": device.serial_number,
@@ -999,7 +995,7 @@ class AmazonEchoApi:
999
995
  }
1000
996
  ],
1001
997
  "target": {
1002
- "customerId": device.device_owner_customer_id,
998
+ "customerId": self._account_owner_customer_id,
1003
999
  "devices": playback_devices,
1004
1000
  },
1005
1001
  "skillId": "amzn1.ask.1p.routines.messaging",
@@ -1171,9 +1167,11 @@ class AmazonEchoApi:
1171
1167
  "domain": f"www.amazon.{self._domain}",
1172
1168
  }
1173
1169
 
1174
- raw_resp = await self._session.post(
1170
+ _, raw_resp = await self._session_request(
1171
+ HTTPMethod.POST,
1175
1172
  "https://api.amazon.com/auth/token",
1176
- data=data,
1173
+ input_data=data,
1174
+ json_data=False,
1177
1175
  )
1178
1176
  _LOGGER.debug(
1179
1177
  "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 } }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aioamazondevices
3
- Version: 6.2.5
3
+ Version: 6.2.7
4
4
  Summary: Python library to control Amazon devices
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
@@ -0,0 +1,12 @@
1
+ aioamazondevices/__init__.py,sha256=7ypbsqEYHFGm1dMAGooQibrUEoO6tovsrqDr7KH7WwE,276
2
+ aioamazondevices/api.py,sha256=6F4UwDNuQXsdfVxpZKXSWVIKsoNgoFJ2whguJxT0hEM,43558
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.7.dist-info/METADATA,sha256=Ap2Tr3-p6e0kSf3IEdz9Vj-cqrp_EmA97IFsRb54weg,7656
10
+ aioamazondevices-6.2.7.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
11
+ aioamazondevices-6.2.7.dist-info/licenses/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
12
+ aioamazondevices-6.2.7.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.2.0
2
+ Generator: poetry-core 2.2.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,12 +0,0 @@
1
- aioamazondevices/__init__.py,sha256=BjC2P6bfkOZOf5BeNfaDDWt5y19EmbbqizU4ioUrR0Q,276
2
- aioamazondevices/api.py,sha256=xuzQuiOpU6D-Hn_tyNXZga-Il3p2Hcs7tjW6zVWzAUY,43532
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.5.dist-info/METADATA,sha256=CLL5EieLkEcN4Q4bP-dKW9Ooa4_2xxfKlZk2pyht8yo,7656
10
- aioamazondevices-6.2.5.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
11
- aioamazondevices-6.2.5.dist-info/licenses/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
12
- aioamazondevices-6.2.5.dist-info/RECORD,,