aioamazondevices 6.2.7__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.
- aioamazondevices/__init__.py +1 -1
- aioamazondevices/api.py +53 -13
- {aioamazondevices-6.2.7.dist-info → aioamazondevices-6.2.9.dist-info}/METADATA +1 -1
- {aioamazondevices-6.2.7.dist-info → aioamazondevices-6.2.9.dist-info}/RECORD +6 -6
- {aioamazondevices-6.2.7.dist-info → aioamazondevices-6.2.9.dist-info}/WHEEL +0 -0
- {aioamazondevices-6.2.7.dist-info → aioamazondevices-6.2.9.dist-info}/licenses/LICENSE +0 -0
aioamazondevices/__init__.py
CHANGED
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,21 +594,33 @@ 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()
|
|
602
601
|
devices_sensors: dict[str, dict[str, AmazonDeviceSensor]] = {}
|
|
603
602
|
devices_endpoints: dict[str, dict[str, Any]] = {}
|
|
604
603
|
|
|
605
|
-
|
|
604
|
+
if error := devices_state.get("errors"):
|
|
605
|
+
if isinstance(error, list):
|
|
606
|
+
error = error[0]
|
|
607
|
+
msg = error.get("message", "Unknown error")
|
|
608
|
+
path = error.get("path", "Unknown path")
|
|
609
|
+
_LOGGER.error("Error retrieving devices state: %s for path %s", msg, path)
|
|
610
|
+
return {}, {}
|
|
611
|
+
|
|
612
|
+
if not (data := devices_state.get("data")) or not data.get("listEndpoints"):
|
|
613
|
+
_LOGGER.error("Malformed devices state data received: %s", devices_state)
|
|
614
|
+
return {}, {}
|
|
615
|
+
|
|
616
|
+
endpoints = data["listEndpoints"]
|
|
606
617
|
for endpoint in endpoints.get("endpoints"):
|
|
607
618
|
serial_number = (
|
|
608
619
|
endpoint["serialNumber"]["value"]["text"]
|
|
609
620
|
if endpoint["serialNumber"]
|
|
610
621
|
else None
|
|
611
622
|
)
|
|
612
|
-
if serial_number in
|
|
623
|
+
if serial_number in devices:
|
|
613
624
|
devices_sensors[serial_number] = self._get_device_sensor_state(
|
|
614
625
|
endpoint, serial_number
|
|
615
626
|
)
|
|
@@ -831,11 +842,33 @@ class AmazonEchoApi:
|
|
|
831
842
|
self._country_specific_data(user_domain)
|
|
832
843
|
await self._refresh_auth_cookies()
|
|
833
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
|
+
|
|
834
867
|
async def get_devices_data(
|
|
835
868
|
self,
|
|
836
869
|
) -> dict[str, AmazonDevice]:
|
|
837
870
|
"""Get Amazon devices data."""
|
|
838
|
-
|
|
871
|
+
devices = {}
|
|
839
872
|
_, raw_resp = await self._session_request(
|
|
840
873
|
method=HTTPMethod.GET,
|
|
841
874
|
url=f"https://alexa.amazon.{self._domain}{URI_DEVICES}",
|
|
@@ -845,19 +878,26 @@ class AmazonEchoApi:
|
|
|
845
878
|
|
|
846
879
|
_LOGGER.debug("JSON devices data: %s", scrub_fields(json_data))
|
|
847
880
|
|
|
848
|
-
this_device_serial = self._login_stored_data["device_info"][
|
|
849
|
-
"device_serial_number"
|
|
850
|
-
]
|
|
851
881
|
for data in json_data["devices"]:
|
|
852
882
|
dev_serial = data.get("serialNumber")
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
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")
|
|
856
896
|
|
|
857
|
-
devices_endpoints, devices_sensors = await self._get_sensors_states()
|
|
897
|
+
devices_endpoints, devices_sensors = await self._get_sensors_states(devices)
|
|
858
898
|
|
|
859
899
|
final_devices_list: dict[str, AmazonDevice] = {}
|
|
860
|
-
for device in
|
|
900
|
+
for device in devices.values():
|
|
861
901
|
# Remove stale, orphaned and virtual devices
|
|
862
902
|
if not device or (device.get("deviceType") in DEVICE_TO_IGNORE):
|
|
863
903
|
continue
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
aioamazondevices/__init__.py,sha256=
|
|
2
|
-
aioamazondevices/api.py,sha256=
|
|
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.
|
|
10
|
-
aioamazondevices-6.2.
|
|
11
|
-
aioamazondevices-6.2.
|
|
12
|
-
aioamazondevices-6.2.
|
|
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,,
|
|
File without changes
|
|
File without changes
|