aioamazondevices 6.5.1__py3-none-any.whl → 6.5.3__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.5.1"
3
+ __version__ = "6.5.3"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
aioamazondevices/api.py CHANGED
@@ -62,6 +62,7 @@ from .const import (
62
62
  REQUEST_AGENT,
63
63
  SAVE_PATH,
64
64
  SENSORS,
65
+ SPEAKER_GROUP_FAMILY,
65
66
  URI_DEVICES,
66
67
  URI_DND,
67
68
  URI_NEXUS_GRAPHQL,
@@ -629,8 +630,7 @@ class AmazonEchoApi:
629
630
  json_data=True,
630
631
  )
631
632
 
632
- sensors_state = await self._response_to_json(raw_resp)
633
- _LOGGER.debug("Sensor data - %s", sensors_state)
633
+ sensors_state = await self._response_to_json(raw_resp, "sensors")
634
634
 
635
635
  if await self._format_human_error(sensors_state):
636
636
  # Explicit error in returned data
@@ -712,14 +712,16 @@ class AmazonEchoApi:
712
712
  _LOGGER.debug(
713
713
  "error in sensor %s - %s - %s", name, error_type, error_msg
714
714
  )
715
- device_sensors[name] = AmazonDeviceSensor(
716
- name,
717
- value,
718
- error,
719
- error_type,
720
- error_msg,
721
- scale,
722
- )
715
+
716
+ if error_type != "NOT_FOUND":
717
+ device_sensors[name] = AmazonDeviceSensor(
718
+ name,
719
+ value,
720
+ error,
721
+ error_type,
722
+ error_msg,
723
+ scale,
724
+ )
723
725
 
724
726
  return device_sensors
725
727
 
@@ -737,7 +739,7 @@ class AmazonEchoApi:
737
739
  json_data=True,
738
740
  )
739
741
 
740
- endpoint_data = await self._response_to_json(raw_resp)
742
+ endpoint_data = await self._response_to_json(raw_resp, "endpoint")
741
743
 
742
744
  if not (data := endpoint_data.get("data")) or not data.get("listEndpoints"):
743
745
  await self._format_human_error(endpoint_data)
@@ -757,7 +759,9 @@ class AmazonEchoApi:
757
759
 
758
760
  return devices_endpoints
759
761
 
760
- async def _response_to_json(self, raw_resp: ClientResponse) -> dict[str, Any]:
762
+ async def _response_to_json(
763
+ self, raw_resp: ClientResponse, description: str | None = None
764
+ ) -> dict[str, Any]:
761
765
  """Convert response to JSON, if possible."""
762
766
  try:
763
767
  data = await raw_resp.json(loads=orjson.loads)
@@ -768,6 +772,8 @@ class AmazonEchoApi:
768
772
  # if anonymous array is returned wrap it inside
769
773
  # generated key to convert list to dict
770
774
  data = {ARRAY_WRAPPER: data}
775
+ if description:
776
+ _LOGGER.debug("JSON '%s' data: %s", description, scrub_fields(data))
771
777
  return cast("dict[str, Any]", data)
772
778
  except ContentTypeError as exc:
773
779
  raise ValueError("Response not in JSON format") from exc
@@ -781,7 +787,9 @@ class AmazonEchoApi:
781
787
  HTTPMethod.GET,
782
788
  url=f"https://alexa.amazon.{self._domain}{URI_NOTIFICATIONS}",
783
789
  )
784
- notifications = await self._response_to_json(raw_resp)
790
+
791
+ notifications = await self._response_to_json(raw_resp, "notifications")
792
+
785
793
  for schedule in notifications["notifications"]:
786
794
  schedule_type: str = schedule["type"]
787
795
  schedule_device_serial = schedule["deviceSerialNumber"]
@@ -866,7 +874,11 @@ class AmazonEchoApi:
866
874
  continue
867
875
 
868
876
  if recurring_rule not in RECURRING_PATTERNS:
869
- _LOGGER.warning("Unknown recurring rule: %s", recurring_rule)
877
+ _LOGGER.warning(
878
+ "Unknown recurring rule <%s> for schedule type <%s>",
879
+ recurring_rule,
880
+ schedule["type"],
881
+ )
870
882
  return None
871
883
 
872
884
  # Adjust recurring rules for country specific weekend exceptions
@@ -1139,9 +1151,14 @@ class AmazonEchoApi:
1139
1151
  else:
1140
1152
  for device_sensor in device.sensors.values():
1141
1153
  device_sensor.error = True
1142
- if device_dnd := dnd_sensors.get(device.serial_number):
1154
+ if (
1155
+ device_dnd := dnd_sensors.get(device.serial_number)
1156
+ ) and device.device_family != SPEAKER_GROUP_FAMILY:
1143
1157
  device.sensors["dnd"] = device_dnd
1144
1158
 
1159
+ # Clear old notifications to handle cancelled ones
1160
+ device.notifications = {}
1161
+
1145
1162
  # Update notifications
1146
1163
  device_notifications = notifications.get(device.serial_number, {})
1147
1164
 
@@ -1183,9 +1200,7 @@ class AmazonEchoApi:
1183
1200
  url=f"https://alexa.amazon.{self._domain}{URI_DEVICES}",
1184
1201
  )
1185
1202
 
1186
- json_data = await self._response_to_json(raw_resp)
1187
-
1188
- _LOGGER.debug("JSON devices data: %s", scrub_fields(json_data))
1203
+ json_data = await self._response_to_json(raw_resp, "devices")
1189
1204
 
1190
1205
  for data in json_data["devices"]:
1191
1206
  dev_serial = data.get("serialNumber")
@@ -1208,11 +1223,20 @@ class AmazonEchoApi:
1208
1223
  if not device or (device.get("deviceType") in DEVICE_TO_IGNORE):
1209
1224
  continue
1210
1225
 
1226
+ account_name: str = device["accountName"]
1227
+ capabilities: list[str] = device["capabilities"]
1228
+ # Skip devices that cannot be used with voice features
1229
+ if "MICROPHONE" not in capabilities:
1230
+ _LOGGER.debug(
1231
+ "Skipping device without microphone capabilities: %s", account_name
1232
+ )
1233
+ continue
1234
+
1211
1235
  serial_number: str = device["serialNumber"]
1212
1236
 
1213
1237
  final_devices_list[serial_number] = AmazonDevice(
1214
- account_name=device["accountName"],
1215
- capabilities=device["capabilities"],
1238
+ account_name=account_name,
1239
+ capabilities=capabilities,
1216
1240
  device_family=device["deviceFamily"],
1217
1241
  device_type=device["deviceType"],
1218
1242
  device_owner_customer_id=device["deviceOwnerCustomerId"],
@@ -1524,8 +1548,7 @@ class AmazonEchoApi:
1524
1548
  _LOGGER.debug("Failed to refresh data")
1525
1549
  return False, {}
1526
1550
 
1527
- json_response = await self._response_to_json(raw_resp)
1528
- _LOGGER.debug("Refresh data json:\n%s ", json_response)
1551
+ json_response = await self._response_to_json(raw_resp, data_type)
1529
1552
 
1530
1553
  if data_type == REFRESH_ACCESS_TOKEN and (
1531
1554
  new_token := json_response.get(REFRESH_ACCESS_TOKEN)
@@ -1549,8 +1572,7 @@ class AmazonEchoApi:
1549
1572
  url=f"https://alexa.amazon.{self._domain}{URI_DND}",
1550
1573
  )
1551
1574
 
1552
- dnd_data = await self._response_to_json(raw_resp)
1553
- _LOGGER.debug("DND data: %s", dnd_data)
1575
+ dnd_data = await self._response_to_json(raw_resp, "dnd")
1554
1576
 
1555
1577
  for dnd in dnd_data.get("doNotDisturbDeviceStatusList", {}):
1556
1578
  dnd_status[dnd.get("deviceSerialNumber")] = AmazonDeviceSensor(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aioamazondevices
3
- Version: 6.5.1
3
+ Version: 6.5.3
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=F9PVHDhnnAwbsRZGVQ6jRtVcKcvPsK2zm7IZVRX_p64,276
2
- aioamazondevices/api.py,sha256=4ut_LNMO4nHD1Fw92XP7hXzTdcOnnYeQC5GynqvSbqk,58409
1
+ aioamazondevices/__init__.py,sha256=cMUz1u0sAxf-PC4DbUYkcVDs1oMHY1cxiiBn9bYGZck,276
2
+ aioamazondevices/api.py,sha256=O-ICuOIUcD-Gw12DDW-kF2PTqAIK882otyQGZtJ4CmE,59197
3
3
  aioamazondevices/const.py,sha256=EUoGr9gqqwoSz01gk56Nhw_-1Tdmv0Yjyh9cJb3ofbs,13556
4
4
  aioamazondevices/exceptions.py,sha256=gRYrxNAJnrV6uRuMx5e76VMvtNKyceXd09q84pDBBrI,638
5
5
  aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  aioamazondevices/query.py,sha256=xVgXF1PIiH7uu33Q_iVfCtdH9hqLOAGdCNnAxTZ76UE,1883
7
7
  aioamazondevices/sounds.py,sha256=CXMDk-KoKVFxBdVAw3MeOClqgpzcVDxvQhFOJp7qX-Y,1896
8
8
  aioamazondevices/utils.py,sha256=RzuKRhnq_8ymCoJMoQJ2vBYyuew06RSWpqQWmqdNczE,2019
9
- aioamazondevices-6.5.1.dist-info/METADATA,sha256=2XGsEjNlJpCKx4ffTMoEO_WjRnEuuU693ST-pRE0y1Q,7679
10
- aioamazondevices-6.5.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
11
- aioamazondevices-6.5.1.dist-info/licenses/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
12
- aioamazondevices-6.5.1.dist-info/RECORD,,
9
+ aioamazondevices-6.5.3.dist-info/METADATA,sha256=7xIx9PG22o3LDQhnQEc9Gmg1yejw_3ixHACpr60aesM,7679
10
+ aioamazondevices-6.5.3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
11
+ aioamazondevices-6.5.3.dist-info/licenses/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
12
+ aioamazondevices-6.5.3.dist-info/RECORD,,