aioamazondevices 3.3.2__tar.gz → 3.5.0__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.3.2
3
+ Version: 3.5.0
4
4
  Summary: Python library to control Amazon devices
5
5
  License: Apache-2.0
6
6
  Author: Simone Chemelli
@@ -85,30 +85,17 @@ The script accept command line arguments or a library_test.json config file:
85
85
  }
86
86
  ```
87
87
 
88
- ## Unknown device type
89
-
90
- Library logs a warning if an unknown device type is linked to your Amazon account.
88
+ ## Known Issues & Limitations
91
89
 
92
- Please open an issue [here](https://github.com/chemelli74/aioamazondevices/issues) and provide the following information:
90
+ See [wiki](https://github.com/chemelli74/aioamazondevices/wiki/Known-Issues-and-Limitations)
93
91
 
94
- - device type
95
- - brand
96
- - model
97
- - generation
98
- - entities are available in Home Assistant
99
- - entities work in Home Assistant
92
+ ## Unknown device type
100
93
 
101
- Current device list: `DEVICE_TYPE_TO_MODEL` from [const.py](https://github.com/chemelli74/aioamazondevices/blob/main/src/aioamazondevices/const.py)
94
+ See [wiki](https://github.com/chemelli74/aioamazondevices/wiki/Unknown-Device-Types)
102
95
 
103
96
  ## Roadmap
104
97
 
105
- The development roadmap includes the following items (in order of priority):
106
-
107
- - Stabilizing library for all countries
108
- - Re-introduce sensors via graphQL
109
- - Introduce timers/schedules/alarms
110
- - Introduce real time websocket updates (media player control)
111
- - Introduce control for Bluetooth connected devices
98
+ See [wiki](https://github.com/chemelli74/aioamazondevices/wiki/Roadmap)
112
99
 
113
100
  ## Contributors ✨
114
101
 
@@ -140,6 +127,13 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
140
127
  <sub><b>jameson_uk</b></sub>
141
128
  </a>
142
129
  </td>
130
+ <td align="center">
131
+ <a href="https://github.com/ivanfmartinez">
132
+ <img src="https://avatars.githubusercontent.com/u/677001?v=4" width="100;" alt="ivanfmartinez"/>
133
+ <br />
134
+ <sub><b>Ivan F. Martinez</b></sub>
135
+ </a>
136
+ </td>
143
137
  <td align="center">
144
138
  <a href="https://github.com/lchavezcuu">
145
139
  <img src="https://avatars.githubusercontent.com/u/22165856?v=4" width="100;" alt="lchavezcuu"/>
@@ -62,30 +62,17 @@ The script accept command line arguments or a library_test.json config file:
62
62
  }
63
63
  ```
64
64
 
65
- ## Unknown device type
66
-
67
- Library logs a warning if an unknown device type is linked to your Amazon account.
65
+ ## Known Issues & Limitations
68
66
 
69
- Please open an issue [here](https://github.com/chemelli74/aioamazondevices/issues) and provide the following information:
67
+ See [wiki](https://github.com/chemelli74/aioamazondevices/wiki/Known-Issues-and-Limitations)
70
68
 
71
- - device type
72
- - brand
73
- - model
74
- - generation
75
- - entities are available in Home Assistant
76
- - entities work in Home Assistant
69
+ ## Unknown device type
77
70
 
78
- Current device list: `DEVICE_TYPE_TO_MODEL` from [const.py](https://github.com/chemelli74/aioamazondevices/blob/main/src/aioamazondevices/const.py)
71
+ See [wiki](https://github.com/chemelli74/aioamazondevices/wiki/Unknown-Device-Types)
79
72
 
80
73
  ## Roadmap
81
74
 
82
- The development roadmap includes the following items (in order of priority):
83
-
84
- - Stabilizing library for all countries
85
- - Re-introduce sensors via graphQL
86
- - Introduce timers/schedules/alarms
87
- - Introduce real time websocket updates (media player control)
88
- - Introduce control for Bluetooth connected devices
75
+ See [wiki](https://github.com/chemelli74/aioamazondevices/wiki/Roadmap)
89
76
 
90
77
  ## Contributors ✨
91
78
 
@@ -117,6 +104,13 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
117
104
  <sub><b>jameson_uk</b></sub>
118
105
  </a>
119
106
  </td>
107
+ <td align="center">
108
+ <a href="https://github.com/ivanfmartinez">
109
+ <img src="https://avatars.githubusercontent.com/u/677001?v=4" width="100;" alt="ivanfmartinez"/>
110
+ <br />
111
+ <sub><b>Ivan F. Martinez</b></sub>
112
+ </a>
113
+ </td>
120
114
  <td align="center">
121
115
  <a href="https://github.com/lchavezcuu">
122
116
  <img src="https://avatars.githubusercontent.com/u/22165856?v=4" width="100;" alt="lchavezcuu"/>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aioamazondevices"
3
- version = "3.3.2"
3
+ version = "3.5.0"
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.3.2"
3
+ __version__ = "3.5.0"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
@@ -1,5 +1,6 @@
1
1
  """Support for Amazon devices."""
2
2
 
3
+ import asyncio
3
4
  import base64
4
5
  import hashlib
5
6
  import mimetypes
@@ -369,15 +370,39 @@ class AmazonEchoApi:
369
370
  self._load_website_cookies() if self._login_stored_data else self._cookies
370
371
  )
371
372
  self.session.cookie_jar.update_cookies(_cookies)
372
- try:
373
- resp = await self.session.request(
374
- method,
375
- URL(url, encoded=True),
376
- data=input_data if not json_data else orjson.dumps(input_data),
377
- headers=headers,
378
- )
379
- except (TimeoutError, ClientConnectorError) as exc:
380
- raise CannotConnect(f"Connection error during {method}") from exc
373
+
374
+ resp: ClientResponse | None = None
375
+ for delay in [0, 1, 2, 5, 8, 12, 21]:
376
+ if delay:
377
+ _LOGGER.info(
378
+ "Sleeping for %s seconds before retrying API call to %s", delay, url
379
+ )
380
+ await asyncio.sleep(delay)
381
+
382
+ try:
383
+ resp = await self.session.request(
384
+ method,
385
+ URL(url, encoded=True),
386
+ data=input_data if not json_data else orjson.dumps(input_data),
387
+ headers=headers,
388
+ )
389
+
390
+ except (TimeoutError, ClientConnectorError) as exc:
391
+ _LOGGER.warning("Connection error to %s: %s", url, repr(exc))
392
+ raise CannotConnect(f"Connection error during {method}") from exc
393
+
394
+ # Retry with a delay only for specific HTTP status
395
+ # that can benefits of a back-off
396
+ if resp.status not in [
397
+ HTTPStatus.INTERNAL_SERVER_ERROR,
398
+ HTTPStatus.SERVICE_UNAVAILABLE,
399
+ HTTPStatus.TOO_MANY_REQUESTS,
400
+ ]:
401
+ break
402
+
403
+ if resp is None:
404
+ _LOGGER.error("No response received from %s", url)
405
+ raise CannotConnect(f"No response received from {url}")
381
406
 
382
407
  if not self._csrf_cookie:
383
408
  self._csrf_cookie = resp.cookies.get(CSRF_COOKIE, Morsel()).value
@@ -902,7 +927,7 @@ class AmazonEchoApi:
902
927
  )
903
928
  if not model_details:
904
929
  _LOGGER.warning(
905
- "Unknown device type '%s' for %s: please read https://github.com/chemelli74/aioamazondevices?tab=readme-ov-file#unknown-device-type",
930
+ "Unknown device type '%s' for %s: please read https://github.com/chemelli74/aioamazondevices/wiki/Unknown-Device-Types",
906
931
  device.device_type,
907
932
  device.account_name,
908
933
  )