aioamazondevices 6.2.0__py3-none-any.whl → 6.2.2__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.0"
3
+ __version__ = "6.2.2"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
aioamazondevices/api.py CHANGED
@@ -75,6 +75,7 @@ class AmazonDeviceSensor:
75
75
 
76
76
  name: str
77
77
  value: str | int | float
78
+ error: bool
78
79
  scale: str | None
79
80
 
80
81
 
@@ -278,7 +279,7 @@ class AmazonEchoApi:
278
279
  form = soup.find("form", {"name": "signIn"}) or soup.find("form")
279
280
 
280
281
  if not isinstance(form, Tag):
281
- raise TypeError("Unable to find form in login response")
282
+ raise CannotAuthenticate("Unable to find form in login response")
282
283
 
283
284
  inputs = {}
284
285
  for field in form.find_all("input"):
@@ -296,7 +297,7 @@ class AmazonEchoApi:
296
297
  url = form.get("action")
297
298
  if isinstance(method, str) and isinstance(url, str):
298
299
  return method, url
299
- raise TypeError("Unable to extract form data from response")
300
+ raise CannotAuthenticate("Unable to extract form data from response")
300
301
 
301
302
  def _extract_code_from_url(self, url: URL) -> str:
302
303
  """Extract the access token from url query after login."""
@@ -307,7 +308,9 @@ class AmazonEchoApi:
307
308
  for key, value in url.query.items():
308
309
  parsed_url[key] = [value]
309
310
  else:
310
- raise TypeError(f"Unable to extract authorization code from url: {url}")
311
+ raise CannotAuthenticate(
312
+ f"Unable to extract authorization code from url: {url}"
313
+ )
311
314
  return parsed_url["openid.oa2.authorization_code"][0]
312
315
 
313
316
  async def _ignore_ap_signin_error(self, response: ClientResponse) -> bool:
@@ -628,30 +631,31 @@ class AmazonEchoApi:
628
631
  self, endpoint: dict[str, Any]
629
632
  ) -> dict[str, AmazonDeviceSensor]:
630
633
  device_sensors: dict[str, AmazonDeviceSensor] = {}
631
- if (
632
- endpoint_dnd := endpoint.get("settings", {}).get("doNotDisturb")
633
- ) and not endpoint_dnd["error"]:
634
+ if endpoint_dnd := endpoint.get("settings", {}).get("doNotDisturb"):
634
635
  device_sensors["dnd"] = AmazonDeviceSensor(
635
- "dnd", endpoint_dnd.get("toggleValue"), None
636
+ name="dnd",
637
+ value=endpoint_dnd.get("toggleValue"),
638
+ error=bool(endpoint_dnd.get("error")),
639
+ scale=None,
636
640
  )
637
641
  for feature in endpoint.get("features", {}):
638
642
  first_property = (feature.get("properties") or [None])[0] or {}
639
- if (
640
- first_property.get("type") != "RETRIEVABLE"
641
- or (sensor := SENSORS.get(feature["name"])) is None
642
- ):
643
+ if (sensor := SENSORS.get(feature["name"])) is None:
644
+ # Skip sensors that are not in the predefined list
643
645
  continue
644
646
 
645
647
  if not (name := sensor["name"]):
646
- raise TypeError("Unable to read sensor template")
648
+ raise CannotRetrieveData("Unable to read sensor template")
647
649
 
648
650
  value = first_property[sensor["key"]]
649
651
  scale = value["scale"] if sensor["scale"] else None
652
+ error = bool(sensor.get("error"))
650
653
  if subkey := sensor["subkey"]:
651
654
  value = value[subkey]
652
655
  device_sensors[name] = AmazonDeviceSensor(
653
656
  name,
654
657
  value,
658
+ error,
655
659
  scale,
656
660
  )
657
661
 
@@ -12,7 +12,7 @@ class CannotConnect(AmazonError):
12
12
 
13
13
 
14
14
  class CannotAuthenticate(AmazonError):
15
- """Exception raised when credentials are incorrect."""
15
+ """Exception raised when authentication fails."""
16
16
 
17
17
 
18
18
  class CannotRetrieveData(AmazonError):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: aioamazondevices
3
- Version: 6.2.0
3
+ Version: 6.2.2
4
4
  Summary: Python library to control Amazon devices
5
5
  License: Apache-2.0
6
6
  Author: Simone Chemelli
@@ -0,0 +1,12 @@
1
+ aioamazondevices/__init__.py,sha256=l0tkEG98GzFalrlMdpBFSWhd8fhDSGHylEp0K3q8hPU,276
2
+ aioamazondevices/api.py,sha256=bZi4BVRa5BV5AZV3rWrzsu-viVzOHtlKbINQUNaPYVA,42147
3
+ aioamazondevices/const.py,sha256=38dhNRpwEJf0FgFQGjt3ONhLdQxjiNrnlcrmQ1AY8oU,11306
4
+ aioamazondevices/exceptions.py,sha256=gRYrxNAJnrV6uRuMx5e76VMvtNKyceXd09q84pDBBrI,638
5
+ aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ aioamazondevices/query.py,sha256=AGHHzefzfYzB7RLWPtlFxYc_rpUZdoeApsU2jYz3urQ,2053
7
+ aioamazondevices/sounds.py,sha256=CXMDk-KoKVFxBdVAw3MeOClqgpzcVDxvQhFOJp7qX-Y,1896
8
+ aioamazondevices/utils.py,sha256=RzuKRhnq_8ymCoJMoQJ2vBYyuew06RSWpqQWmqdNczE,2019
9
+ aioamazondevices-6.2.2.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
10
+ aioamazondevices-6.2.2.dist-info/METADATA,sha256=I-3gSjc6vAZkmqU3KStRg7d-p268Xl4haeDBEeM42iQ,7623
11
+ aioamazondevices-6.2.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
12
+ aioamazondevices-6.2.2.dist-info/RECORD,,
@@ -1,12 +0,0 @@
1
- aioamazondevices/__init__.py,sha256=oT6YOexUE4rV5rAbI-rUuZ6XGk2jXwetnm_lzg-wTSU,276
2
- aioamazondevices/api.py,sha256=spUjgxRW9qPKVzV9RwIX4QzkxrqwCrvM-MbdSxAE6u4,41973
3
- aioamazondevices/const.py,sha256=38dhNRpwEJf0FgFQGjt3ONhLdQxjiNrnlcrmQ1AY8oU,11306
4
- aioamazondevices/exceptions.py,sha256=JDnSFi_7oEhqK31sHXf0S_cyMoMjiRJuLp4ow7mYgLY,643
5
- aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- aioamazondevices/query.py,sha256=AGHHzefzfYzB7RLWPtlFxYc_rpUZdoeApsU2jYz3urQ,2053
7
- aioamazondevices/sounds.py,sha256=CXMDk-KoKVFxBdVAw3MeOClqgpzcVDxvQhFOJp7qX-Y,1896
8
- aioamazondevices/utils.py,sha256=RzuKRhnq_8ymCoJMoQJ2vBYyuew06RSWpqQWmqdNczE,2019
9
- aioamazondevices-6.2.0.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
10
- aioamazondevices-6.2.0.dist-info/METADATA,sha256=HLWbqGs_h6-Jb-Ck5ojVO3S87c_KLT8MiuIbxAsOiU8,7623
11
- aioamazondevices-6.2.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
12
- aioamazondevices-6.2.0.dist-info/RECORD,,