aioamazondevices 3.2.7__tar.gz → 3.2.8__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.2.7
3
+ Version: 3.2.8
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.2.7"
3
+ version = "3.2.8"
4
4
  requires-python = ">=3.12"
5
5
  description = "Python library to control Amazon devices"
6
6
  authors = [
@@ -1,6 +1,6 @@
1
1
  """aioamazondevices library."""
2
2
 
3
- __version__ = "3.2.7"
3
+ __version__ = "3.2.8"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
@@ -339,6 +339,14 @@ class AmazonEchoApi:
339
339
  )
340
340
  return False
341
341
 
342
+ async def _ignore_phoenix_error(self, response: ClientResponse) -> bool:
343
+ """Return true if error is due to phoenix endpoint."""
344
+ # Endpoint URI_IDS replies with error 199 or 299
345
+ # during maintenance
346
+ return response.status in [HTTP_ERROR_199, HTTP_ERROR_299] and (
347
+ URI_IDS in response.url.path
348
+ )
349
+
342
350
  async def _http_phrase_error(self, error: int) -> str:
343
351
  """Convert numeric error in human phrase."""
344
352
  if error == HTTP_ERROR_199:
@@ -415,7 +423,9 @@ class AmazonEchoApi:
415
423
  HTTPStatus.UNAUTHORIZED,
416
424
  ]:
417
425
  raise CannotAuthenticate(await self._http_phrase_error(resp.status))
418
- if not await self._ignore_ap_signin_error(resp):
426
+ if not await self._ignore_ap_signin_error(
427
+ resp
428
+ ) and not await self._ignore_phoenix_error(resp):
419
429
  raise CannotRetrieveData(
420
430
  f"Request failed: {await self._http_phrase_error(resp.status)}"
421
431
  )
@@ -596,6 +606,16 @@ class AmazonEchoApi:
596
606
  url=f"https://alexa.amazon.{self._domain}{URI_IDS}",
597
607
  amazon_user_agent=False,
598
608
  )
609
+
610
+ # Sensors data not available
611
+ if raw_resp.status != HTTPStatus.OK:
612
+ _LOGGER.warning(
613
+ "Sensors data not available [%s error '%s'], skipping",
614
+ URI_IDS,
615
+ await self._http_phrase_error(raw_resp.status),
616
+ )
617
+ return []
618
+
599
619
  json_data = await raw_resp.json()
600
620
 
601
621
  network_detail = orjson.loads(json_data["networkDetail"])