aioamazondevices 6.2.8__py3-none-any.whl → 6.2.9__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.8"
3
+ __version__ = "6.2.9"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
aioamazondevices/api.py CHANGED
@@ -141,7 +141,6 @@ class AmazonEchoApi:
141
141
  self._list_for_clusters: dict[str, str] = {}
142
142
 
143
143
  self._session = client_session
144
- self._devices: dict[str, Any] = {}
145
144
 
146
145
  _LOGGER.debug("Initialize library v%s", __version__)
147
146
 
@@ -595,7 +594,7 @@ class AmazonEchoApi:
595
594
  return await self._response_to_json(raw_resp)
596
595
 
597
596
  async def _get_sensors_states(
598
- self,
597
+ self, devices: dict[str, Any]
599
598
  ) -> tuple[dict[str, dict[str, Any]], dict[str, dict[str, AmazonDeviceSensor]]]:
600
599
  """Retrieve devices sensors states."""
601
600
  devices_state = await self._get_devices_state()
@@ -621,7 +620,7 @@ class AmazonEchoApi:
621
620
  if endpoint["serialNumber"]
622
621
  else None
623
622
  )
624
- if serial_number in self._devices:
623
+ if serial_number in devices:
625
624
  devices_sensors[serial_number] = self._get_device_sensor_state(
626
625
  endpoint, serial_number
627
626
  )
@@ -843,11 +842,33 @@ class AmazonEchoApi:
843
842
  self._country_specific_data(user_domain)
844
843
  await self._refresh_auth_cookies()
845
844
 
845
+ async def _get_account_owner_customer_id(self, data: dict[str, Any]) -> str | None:
846
+ """Get account owner customer ID."""
847
+ if data["deviceType"] != AMAZON_DEVICE_TYPE:
848
+ return None
849
+
850
+ account_owner_customer_id: str | None = None
851
+
852
+ this_device_serial = self._login_stored_data["device_info"][
853
+ "device_serial_number"
854
+ ]
855
+
856
+ for subdevice in data["appDeviceList"]:
857
+ if subdevice["serialNumber"] == this_device_serial:
858
+ account_owner_customer_id = data["deviceOwnerCustomerId"]
859
+ _LOGGER.debug(
860
+ "Setting account owner: %s",
861
+ account_owner_customer_id,
862
+ )
863
+ break
864
+
865
+ return account_owner_customer_id
866
+
846
867
  async def get_devices_data(
847
868
  self,
848
869
  ) -> dict[str, AmazonDevice]:
849
870
  """Get Amazon devices data."""
850
- self._devices = {}
871
+ devices = {}
851
872
  _, raw_resp = await self._session_request(
852
873
  method=HTTPMethod.GET,
853
874
  url=f"https://alexa.amazon.{self._domain}{URI_DEVICES}",
@@ -857,19 +878,26 @@ class AmazonEchoApi:
857
878
 
858
879
  _LOGGER.debug("JSON devices data: %s", scrub_fields(json_data))
859
880
 
860
- this_device_serial = self._login_stored_data["device_info"][
861
- "device_serial_number"
862
- ]
863
881
  for data in json_data["devices"]:
864
882
  dev_serial = data.get("serialNumber")
865
- self._devices[dev_serial] = data
866
- if dev_serial == this_device_serial:
867
- self._account_owner_customer_id = data["deviceOwnerCustomerId"]
883
+ if not dev_serial:
884
+ _LOGGER.warning(
885
+ "Skipping device without serial number: %s", data["accountName"]
886
+ )
887
+ continue
888
+ devices[dev_serial] = data
889
+ if not self._account_owner_customer_id:
890
+ self._account_owner_customer_id = (
891
+ await self._get_account_owner_customer_id(data)
892
+ )
893
+
894
+ if not self._account_owner_customer_id:
895
+ raise CannotRetrieveData("Cannot find account owner customer ID")
868
896
 
869
- devices_endpoints, devices_sensors = await self._get_sensors_states()
897
+ devices_endpoints, devices_sensors = await self._get_sensors_states(devices)
870
898
 
871
899
  final_devices_list: dict[str, AmazonDevice] = {}
872
- for device in self._devices.values():
900
+ for device in devices.values():
873
901
  # Remove stale, orphaned and virtual devices
874
902
  if not device or (device.get("deviceType") in DEVICE_TO_IGNORE):
875
903
  continue
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aioamazondevices
3
- Version: 6.2.8
3
+ Version: 6.2.9
4
4
  Summary: Python library to control Amazon devices
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
@@ -1,12 +1,12 @@
1
- aioamazondevices/__init__.py,sha256=fC_cVxoQ9UV0g3MPcq9xo24JwXEXPPXuU1x5i1IA00o,276
2
- aioamazondevices/api.py,sha256=xJyDMmWDizrr4k8cpoUtr3FMb7A0K3y-ls9sbh3x0lw,44084
1
+ aioamazondevices/__init__.py,sha256=uARWO02mQ70rgxwWyOTxs9HC8FjeynIm_FBuhCenQBk,276
2
+ aioamazondevices/api.py,sha256=B7KYropGmSwQl7sYzS7rTDDkiviIASsAszl1tsKDL70,45090
3
3
  aioamazondevices/const.py,sha256=pPjMhNABj3rN8uvHzqj41tDiGPx-C50QRcSckvzX9z8,11561
4
4
  aioamazondevices/exceptions.py,sha256=gRYrxNAJnrV6uRuMx5e76VMvtNKyceXd09q84pDBBrI,638
5
5
  aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  aioamazondevices/query.py,sha256=qLCuNyVlSbvVQmckZUsmftsz8s04GIukdidsOo4BrD0,2084
7
7
  aioamazondevices/sounds.py,sha256=CXMDk-KoKVFxBdVAw3MeOClqgpzcVDxvQhFOJp7qX-Y,1896
8
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,,
9
+ aioamazondevices-6.2.9.dist-info/METADATA,sha256=0ULxMwg8faUXH8FU6_-2qvBd9Oc3LRm2HRVif5JJh7A,7656
10
+ aioamazondevices-6.2.9.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
11
+ aioamazondevices-6.2.9.dist-info/licenses/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
12
+ aioamazondevices-6.2.9.dist-info/RECORD,,