aioamazondevices 3.1.19__tar.gz → 3.1.22__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: aioamazondevices
3
- Version: 3.1.19
3
+ Version: 3.1.22
4
4
  Summary: Python library to control Amazon devices
5
5
  License: Apache-2.0
6
6
  Author: Simone Chemelli
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aioamazondevices"
3
- version = "3.1.19"
3
+ version = "3.1.22"
4
4
  requires-python = ">=3.12"
5
5
  description = "Python library to control Amazon devices"
6
6
  authors = [
@@ -38,7 +38,7 @@ pytest = "^8.4"
38
38
  pytest-cov = ">=5,<7"
39
39
 
40
40
  [tool.semantic_release]
41
- version_toml = ["pyproject.toml:tool.poetry.version"]
41
+ version_toml = ["pyproject.toml:project.version"]
42
42
  version_variables = [
43
43
  "src/aioamazondevices/__init__.py:__version__",
44
44
  ]
@@ -1,6 +1,6 @@
1
1
  """aioamazondevices library."""
2
2
 
3
- __version__ = "3.1.19"
3
+ __version__ = "3.1.22"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
@@ -479,11 +479,6 @@ class AmazonEchoApi:
479
479
  )
480
480
  raise CannotRegisterDevice(f"{HTTPStatus(resp.status).phrase}: {msg}")
481
481
 
482
- await self._save_to_file(
483
- await resp.text(),
484
- url=register_url,
485
- extension=JSON_EXTENSION,
486
- )
487
482
  success_response = resp_json["response"]["success"]
488
483
 
489
484
  tokens = success_response["tokens"]
@@ -530,16 +525,43 @@ class AmazonEchoApi:
530
525
  location_details = network_detail["locationDetails"]["locationDetails"]
531
526
  default_location = location_details["Default_Location"]
532
527
  amazon_bridge = default_location["amazonBridgeDetails"]["amazonBridgeDetails"]
533
- lambda_bridge = amazon_bridge.get("LambdaBridge_AAA/SonarCloudService")
534
- if not lambda_bridge:
535
- # Some very old devices lack the key for sensors data
536
- return []
537
- appliance_details = lambda_bridge["applianceDetails"]["applianceDetails"]
538
528
 
529
+ # New devices are based on LambdaBridge_AAA structure
530
+ lambda_bridge_aaa = amazon_bridge.get("LambdaBridge_AAA/SonarCloudService")
531
+ appliance_details_aaa = (
532
+ lambda_bridge_aaa["applianceDetails"]["applianceDetails"]
533
+ if lambda_bridge_aaa
534
+ else {}
535
+ )
536
+
537
+ entity_ids_list: list[dict[str, str]] = await self._get_entities_ids(
538
+ appliance_details_aaa, "AAA_SonarCloudService"
539
+ )
540
+
541
+ # Old devices are based on LambdaBridge_AlexaBridge structure
542
+ for bridge_key, bridge_value in amazon_bridge.items():
543
+ if "LambdaBridge_AlexaBridge/" in bridge_key:
544
+ # Value key: "LambdaBridge_AlexaBridge/XXXXXXXXXXXXXX@XXXXXXXXXXXXXX"
545
+ # Value subkey: "AlexaBridge_XXXXXXXXXXXXXX@XXXXXXXXXXXXXX_XXXXXXXXXXXX"
546
+ subkey = bridge_key.split("_")[1].replace("/", "_")
547
+
548
+ appliance_details_alexa = bridge_value["applianceDetails"][
549
+ "applianceDetails"
550
+ ]
551
+ entity_ids_list.extend(
552
+ await self._get_entities_ids(appliance_details_alexa, subkey)
553
+ )
554
+
555
+ return entity_ids_list
556
+
557
+ async def _get_entities_ids(
558
+ self, appliance_details: dict[str, Any], searchkey: str
559
+ ) -> list[dict[str, str]]:
560
+ """Extract entityId and applianceId."""
539
561
  entity_ids_list: list[dict[str, str]] = []
540
- # Process each appliance that starts with AAA_SonarCloudService
562
+ # Process each appliance that starts with "searchkey"
541
563
  for appliance_key, appliance_data in appliance_details.items():
542
- if not appliance_key.startswith("AAA_SonarCloudService"):
564
+ if not appliance_key.startswith(searchkey):
543
565
  continue
544
566
 
545
567
  entity_id = appliance_data["entityId"]
@@ -662,7 +684,7 @@ class AmazonEchoApi:
662
684
  register_device = await self._register_device(device_login_data)
663
685
  self._login_stored_data = register_device
664
686
 
665
- _LOGGER.info("Register device: %s", register_device)
687
+ _LOGGER.info("Register device: %s", scrub_fields(register_device))
666
688
  return register_device
667
689
 
668
690
  async def login_mode_stored_data(self) -> dict[str, Any]:
@@ -704,7 +726,6 @@ class AmazonEchoApi:
704
726
  _LOGGER.debug("Response code: |%s|", response_code)
705
727
 
706
728
  response_data = await raw_resp.text()
707
- _LOGGER.debug("Response data: |%s|", response_data)
708
729
 
709
730
  if not self._csrf_cookie:
710
731
  self._csrf_cookie = raw_resp.cookies.get(CSRF_COOKIE, Morsel()).value
@@ -712,7 +733,7 @@ class AmazonEchoApi:
712
733
 
713
734
  json_data = {} if len(response_data) == 0 else await raw_resp.json()
714
735
 
715
- _LOGGER.debug("JSON data: |%s|", json_data)
736
+ _LOGGER.debug("JSON data: |%s|", scrub_fields(json_data))
716
737
 
717
738
  for data in json_data[key]:
718
739
  dev_serial = data.get("serialNumber") or data.get("deviceSerialNumber")
@@ -7,11 +7,13 @@ _LOGGER = logging.getLogger(__package__)
7
7
  DEFAULT_ASSOC_HANDLE = "amzn_dp_project_dee_ios"
8
8
 
9
9
  TO_REDACT = {
10
+ "address",
10
11
  "address1",
11
12
  "address2",
12
13
  "address3",
13
14
  "city",
14
15
  "county",
16
+ "customerId",
15
17
  "deviceAccountId",
16
18
  "deviceAddress",
17
19
  "deviceOwnerCustomerId",
@@ -37,7 +37,9 @@ def scrub_fields(
37
37
  result = {}
38
38
  for k, v in obj.items():
39
39
  # If the key itself is sensitive → overwrite its value
40
- if k in field_names:
40
+ if k == "email":
41
+ result[k] = obfuscate_email(v)
42
+ elif k in field_names:
41
43
  result[k] = replacement
42
44
  else:
43
45
  # Otherwise keep walking