aioamazondevices 6.2.4__py3-none-any.whl → 6.2.6__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.4"
3
+ __version__ = "6.2.6"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
aioamazondevices/api.py CHANGED
@@ -142,7 +142,6 @@ class AmazonEchoApi:
142
142
 
143
143
  self._session = client_session
144
144
  self._devices: dict[str, Any] = {}
145
- self._sensors_available: bool = True
146
145
 
147
146
  _LOGGER.debug("Initialize library v%s", __version__)
148
147
 
@@ -622,13 +621,15 @@ class AmazonEchoApi:
622
621
  else None
623
622
  )
624
623
  if serial_number in self._devices:
625
- devices_sensors[serial_number] = self._get_device_sensor_state(endpoint)
624
+ devices_sensors[serial_number] = self._get_device_sensor_state(
625
+ endpoint, serial_number
626
+ )
626
627
  devices_endpoints[serial_number] = endpoint
627
628
 
628
629
  return devices_endpoints, devices_sensors
629
630
 
630
631
  def _get_device_sensor_state(
631
- self, endpoint: dict[str, Any]
632
+ self, endpoint: dict[str, Any], serial_number: str
632
633
  ) -> dict[str, AmazonDeviceSensor]:
633
634
  device_sensors: dict[str, AmazonDeviceSensor] = {}
634
635
  if endpoint_dnd := endpoint.get("settings", {}).get("doNotDisturb"):
@@ -639,22 +640,49 @@ class AmazonEchoApi:
639
640
  scale=None,
640
641
  )
641
642
  for feature in endpoint.get("features", {}):
642
- if (sensor := SENSORS.get(feature["name"])) is None:
643
+ if (sensor_template := SENSORS.get(feature["name"])) is None:
643
644
  # Skip sensors that are not in the predefined list
644
645
  continue
645
646
 
646
- if not (name := sensor["name"]):
647
+ if not (name := sensor_template["name"]):
647
648
  raise CannotRetrieveData("Unable to read sensor template")
648
649
 
649
650
  for feature_property in feature.get("properties"):
650
- if sensor["name"] != feature_property.get("name"):
651
+ if sensor_template["name"] != feature_property.get("name"):
651
652
  continue
652
653
 
653
- value = feature_property[sensor["key"]]
654
- scale = value["scale"] if sensor["scale"] else None
655
- error = bool(sensor.get("error"))
656
- if subkey := sensor["subkey"]:
657
- value = value[subkey]
654
+ value: str | int | float = "n/a"
655
+ scale: str | None = None
656
+ error = bool(feature_property.get("error"))
657
+ if not error:
658
+ try:
659
+ value_raw = feature_property[sensor_template["key"]]
660
+ if not value_raw:
661
+ _LOGGER.warning(
662
+ "Sensor %s [device %s] ignored due to empty value",
663
+ name,
664
+ serial_number,
665
+ )
666
+ continue
667
+ scale = (
668
+ value_raw[scale_template]
669
+ if (scale_template := sensor_template["scale"])
670
+ else None
671
+ )
672
+ value = (
673
+ value_raw[subkey_template]
674
+ if (subkey_template := sensor_template["subkey"])
675
+ else value_raw
676
+ )
677
+
678
+ except (KeyError, ValueError) as exc:
679
+ _LOGGER.warning(
680
+ "Sensor %s [device %s] ignored due to errors in feature %s: %s", # noqa: E501
681
+ name,
682
+ serial_number,
683
+ feature_property,
684
+ repr(exc),
685
+ )
658
686
  device_sensors[name] = AmazonDeviceSensor(
659
687
  name,
660
688
  value,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aioamazondevices
3
- Version: 6.2.4
3
+ Version: 6.2.6
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=O5sZcBW6O16XeV2LlY-nIVk5ugcMwgXzmtB7xKMd0wo,276
2
- aioamazondevices/api.py,sha256=zE7q03ok3CoIlKiClAA3tFch3oWdJEu4s61S4ZUEfBw,42277
1
+ aioamazondevices/__init__.py,sha256=2rkrcsrHU_OkLuxwVmHbM2zQIokytaNz17RY5Sme80U,276
2
+ aioamazondevices/api.py,sha256=h3LVTzj4f2unlD8PPyezBT0OsbF5viICIK8YhT2MoIU,43533
3
3
  aioamazondevices/const.py,sha256=laRFapeQRpg3aGi10iCOH5OzBi1cnaPJX0s1phSl21w,11769
4
4
  aioamazondevices/exceptions.py,sha256=gRYrxNAJnrV6uRuMx5e76VMvtNKyceXd09q84pDBBrI,638
5
5
  aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  aioamazondevices/query.py,sha256=AGHHzefzfYzB7RLWPtlFxYc_rpUZdoeApsU2jYz3urQ,2053
7
7
  aioamazondevices/sounds.py,sha256=CXMDk-KoKVFxBdVAw3MeOClqgpzcVDxvQhFOJp7qX-Y,1896
8
8
  aioamazondevices/utils.py,sha256=RzuKRhnq_8ymCoJMoQJ2vBYyuew06RSWpqQWmqdNczE,2019
9
- aioamazondevices-6.2.4.dist-info/METADATA,sha256=indV-n8QQZYkmaRmhsWVx4DDipUTxNiMgz4nm6DN7Rg,7656
10
- aioamazondevices-6.2.4.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
11
- aioamazondevices-6.2.4.dist-info/licenses/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
12
- aioamazondevices-6.2.4.dist-info/RECORD,,
9
+ aioamazondevices-6.2.6.dist-info/METADATA,sha256=us19gN-RKVrY6ICis6RkboCyMzStX5jHSTWbbfKfAXc,7656
10
+ aioamazondevices-6.2.6.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
11
+ aioamazondevices-6.2.6.dist-info/licenses/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
12
+ aioamazondevices-6.2.6.dist-info/RECORD,,