aioamazondevices 0.7.3__tar.gz → 0.9.0__tar.gz
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-0.7.3 → aioamazondevices-0.9.0}/PKG-INFO +2 -3
- {aioamazondevices-0.7.3 → aioamazondevices-0.9.0}/pyproject.toml +3 -3
- {aioamazondevices-0.7.3 → aioamazondevices-0.9.0}/src/aioamazondevices/__init__.py +1 -1
- {aioamazondevices-0.7.3 → aioamazondevices-0.9.0}/src/aioamazondevices/api.py +23 -11
- {aioamazondevices-0.7.3 → aioamazondevices-0.9.0}/src/aioamazondevices/const.py +5 -5
- {aioamazondevices-0.7.3 → aioamazondevices-0.9.0}/LICENSE +0 -0
- {aioamazondevices-0.7.3 → aioamazondevices-0.9.0}/README.md +0 -0
- {aioamazondevices-0.7.3 → aioamazondevices-0.9.0}/src/aioamazondevices/exceptions.py +0 -0
- {aioamazondevices-0.7.3 → aioamazondevices-0.9.0}/src/aioamazondevices/py.typed +0 -0
@@ -1,19 +1,18 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: aioamazondevices
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.9.0
|
4
4
|
Summary: Python library to control Amazon devices
|
5
5
|
Home-page: https://github.com/chemelli74/aioamazondevices
|
6
6
|
License: Apache-2.0
|
7
7
|
Author: Simone Chemelli
|
8
8
|
Author-email: simone.chemelli@gmail.com
|
9
|
-
Requires-Python: >=3.
|
9
|
+
Requires-Python: >=3.12,<4.0
|
10
10
|
Classifier: Development Status :: 2 - Pre-Alpha
|
11
11
|
Classifier: Intended Audience :: Developers
|
12
12
|
Classifier: License :: OSI Approved :: Apache Software License
|
13
13
|
Classifier: Natural Language :: English
|
14
14
|
Classifier: Operating System :: OS Independent
|
15
15
|
Classifier: Programming Language :: Python :: 3
|
16
|
-
Classifier: Programming Language :: Python :: 3.11
|
17
16
|
Classifier: Programming Language :: Python :: 3.12
|
18
17
|
Classifier: Programming Language :: Python :: 3.13
|
19
18
|
Classifier: Topic :: Software Development :: Libraries
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "aioamazondevices"
|
3
|
-
version = "0.
|
3
|
+
version = "0.9.0"
|
4
4
|
description = "Python library to control Amazon devices"
|
5
5
|
authors = ["Simone Chemelli <simone.chemelli@gmail.com>"]
|
6
6
|
license = "Apache-2.0"
|
@@ -22,7 +22,7 @@ packages = [
|
|
22
22
|
"Changelog" = "https://github.com/chemelli74/aioamazondevices/blob/main/CHANGELOG.md"
|
23
23
|
|
24
24
|
[tool.poetry.dependencies]
|
25
|
-
python = "^3.
|
25
|
+
python = "^3.12"
|
26
26
|
beautifulsoup4 = "*"
|
27
27
|
colorlog = "*"
|
28
28
|
httpx = "*"
|
@@ -30,7 +30,7 @@ orjson = "*"
|
|
30
30
|
|
31
31
|
[tool.poetry.group.dev.dependencies]
|
32
32
|
pytest = "^8.1"
|
33
|
-
pytest-cov = "
|
33
|
+
pytest-cov = ">=5,<7"
|
34
34
|
|
35
35
|
[tool.semantic_release]
|
36
36
|
version_toml = ["pyproject.toml:tool.poetry.version"]
|
@@ -28,6 +28,7 @@ from .const import (
|
|
28
28
|
AMAZON_DEVICE_TYPE,
|
29
29
|
DEFAULT_ASSOC_HANDLE,
|
30
30
|
DEFAULT_HEADERS,
|
31
|
+
DEVICES,
|
31
32
|
DOMAIN_BY_COUNTRY,
|
32
33
|
HTML_EXTENSION,
|
33
34
|
JSON_EXTENSION,
|
@@ -58,7 +59,7 @@ class AmazonEchoApi:
|
|
58
59
|
login_country_code: str,
|
59
60
|
login_email: str,
|
60
61
|
login_password: str,
|
61
|
-
|
62
|
+
save_raw_data: bool = False,
|
62
63
|
) -> None:
|
63
64
|
"""Initialize the scanner."""
|
64
65
|
# Force country digits as lower case
|
@@ -79,7 +80,7 @@ class AmazonEchoApi:
|
|
79
80
|
self._url = f"https://www.amazon.{domain}"
|
80
81
|
self._cookies = self._build_init_cookies()
|
81
82
|
self._headers = DEFAULT_HEADERS
|
82
|
-
self.
|
83
|
+
self._save_raw_data = save_raw_data
|
83
84
|
self._serial = self._serial_number()
|
84
85
|
|
85
86
|
self.session: AsyncClient
|
@@ -235,7 +236,7 @@ class AmazonEchoApi:
|
|
235
236
|
output_path: str = SAVE_PATH,
|
236
237
|
) -> None:
|
237
238
|
"""Save response data to disk."""
|
238
|
-
if not self.
|
239
|
+
if not self._save_raw_data:
|
239
240
|
return
|
240
241
|
|
241
242
|
output_dir = Path(output_path)
|
@@ -441,7 +442,7 @@ class AmazonEchoApi:
|
|
441
442
|
self,
|
442
443
|
) -> dict[str, Any]:
|
443
444
|
"""Get Amazon devices data."""
|
444
|
-
devices = {}
|
445
|
+
devices: dict[str, Any] = {}
|
445
446
|
for key in URI_QUERIES:
|
446
447
|
_, raw_resp = await self._session_request(
|
447
448
|
"GET",
|
@@ -457,10 +458,21 @@ class AmazonEchoApi:
|
|
457
458
|
|
458
459
|
_LOGGER.debug("JSON data: |%s|", json_data)
|
459
460
|
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
461
|
+
for data in json_data[key]:
|
462
|
+
dev_serial = data.get("serialNumber") or data.get("deviceSerialNumber")
|
463
|
+
if previous_data := devices.get(dev_serial):
|
464
|
+
devices[dev_serial] = previous_data | {key: data}
|
465
|
+
else:
|
466
|
+
devices[dev_serial] = {key: data}
|
467
|
+
|
468
|
+
# Remove stale, orphaned and virtual devices
|
469
|
+
final_devices_list: dict[str, Any] = devices.copy()
|
470
|
+
for serial in devices:
|
471
|
+
device = devices[serial]
|
472
|
+
if (
|
473
|
+
DEVICES not in device
|
474
|
+
or device[DEVICES].get("deviceType") == AMAZON_DEVICE_TYPE
|
475
|
+
):
|
476
|
+
final_devices_list.pop(serial)
|
477
|
+
|
478
|
+
return final_devices_list
|
@@ -35,12 +35,12 @@ DEFAULT_HEADERS = {
|
|
35
35
|
"Accept-Encoding": "gzip",
|
36
36
|
}
|
37
37
|
|
38
|
+
DEVICES = "devices"
|
38
39
|
URI_QUERIES = {
|
39
|
-
|
40
|
-
"
|
41
|
-
"
|
42
|
-
"
|
43
|
-
"bluetooth": "/api/bluetooth",
|
40
|
+
DEVICES: "/api/devices-v2/device",
|
41
|
+
"doNotDisturbDeviceStatusList": "/api/dnd/device-status-list",
|
42
|
+
"devicePreferences": "/api/device-preferences",
|
43
|
+
"bluetoothStates": "/api/bluetooth",
|
44
44
|
}
|
45
45
|
|
46
46
|
# Amazon APP info
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|