python-amazon-echo 0.3.2__py3-none-any.whl → 0.3.4__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.
- amazon_echo/__init__.py +1 -1
- amazon_echo/client.py +30 -1
- amazon_echo/const.py +1 -1
- amazon_echo/endpoints.py +5 -1
- {python_amazon_echo-0.3.2.dist-info → python_amazon_echo-0.3.4.dist-info}/METADATA +14 -11
- {python_amazon_echo-0.3.2.dist-info → python_amazon_echo-0.3.4.dist-info}/RECORD +9 -9
- {python_amazon_echo-0.3.2.dist-info → python_amazon_echo-0.3.4.dist-info}/WHEEL +0 -0
- {python_amazon_echo-0.3.2.dist-info → python_amazon_echo-0.3.4.dist-info}/entry_points.txt +0 -0
- {python_amazon_echo-0.3.2.dist-info → python_amazon_echo-0.3.4.dist-info}/licenses/LICENSE +0 -0
amazon_echo/__init__.py
CHANGED
amazon_echo/client.py
CHANGED
|
@@ -178,6 +178,20 @@ def parse_notification(item: dict[str, Any]) -> Notification:
|
|
|
178
178
|
)
|
|
179
179
|
|
|
180
180
|
|
|
181
|
+
def _session_as_player(now: dict[str, Any]) -> dict[str, Any]:
|
|
182
|
+
"""Shape a media session's ``nowPlayingData`` like ``playerInfo``.
|
|
183
|
+
|
|
184
|
+
The session names the state ``playerState`` and counts in milliseconds.
|
|
185
|
+
"""
|
|
186
|
+
progress = dict(now.get("progress") or {})
|
|
187
|
+
for key in ("mediaLength", "mediaProgress"):
|
|
188
|
+
try:
|
|
189
|
+
progress[key] = float(progress[key]) / 1000
|
|
190
|
+
except KeyError, TypeError, ValueError:
|
|
191
|
+
progress.pop(key, None)
|
|
192
|
+
return {**now, "state": now.get("playerState"), "progress": progress}
|
|
193
|
+
|
|
194
|
+
|
|
181
195
|
def _parse_media(info: dict[str, Any]) -> MediaState:
|
|
182
196
|
"""Build a :class:`MediaState` from the ``playerInfo`` of ``/api/np/player``."""
|
|
183
197
|
transport = info.get("transport") or {}
|
|
@@ -792,7 +806,22 @@ class AmazonEchoClient:
|
|
|
792
806
|
"/api/np/player",
|
|
793
807
|
params={**self._query(device), "screenWidth": "2560"},
|
|
794
808
|
)
|
|
795
|
-
|
|
809
|
+
info = (data or {}).get("playerInfo") or {}
|
|
810
|
+
if info.get("state"):
|
|
811
|
+
return _parse_media(info)
|
|
812
|
+
# Spotify and other external players leave /api/np/player empty and
|
|
813
|
+
# only show up as a media session (observed live).
|
|
814
|
+
try:
|
|
815
|
+
sessions = await self._request(
|
|
816
|
+
"GET", "/api/np/list-media-sessions", params=self._query(device)
|
|
817
|
+
)
|
|
818
|
+
except AmazonEchoResponseError:
|
|
819
|
+
return _parse_media(info)
|
|
820
|
+
for session in (sessions or {}).get("mediaSessionList") or []:
|
|
821
|
+
now = session.get("nowPlayingData") or {}
|
|
822
|
+
if now.get("playerState"):
|
|
823
|
+
return _parse_media(_session_as_player(now))
|
|
824
|
+
return _parse_media(info)
|
|
796
825
|
|
|
797
826
|
async def get_endpoint_states(self) -> dict[str, dict[str, Any]]:
|
|
798
827
|
"""Return the GraphQL state of every Alexa endpoint by device serial.
|
amazon_echo/const.py
CHANGED
amazon_echo/endpoints.py
CHANGED
|
@@ -118,7 +118,8 @@ def parse_features(
|
|
|
118
118
|
|
|
119
119
|
Keys: ``reachable``, ``temperature`` (°C), ``humidity`` (%),
|
|
120
120
|
``illuminance`` (lx), ``motion``, ``contact`` (True = open), ``battery``
|
|
121
|
-
(%), ``remote_battery`` (%), ``volume``, ``ambient_mode
|
|
121
|
+
(%), ``remote_battery`` (%), ``volume``, ``ambient_mode`` (with
|
|
122
|
+
``ambient_mode_supported``, set even when Amazon gives no state), ``power``,
|
|
122
123
|
``brightness`` (0-100), ``color`` (``hue`` 0-360, ``saturation`` and
|
|
123
124
|
``brightness`` 0-1), ``color_temperature`` (K), ``lock`` (``LOCKED`` /
|
|
124
125
|
``UNLOCKED`` / ``JAMMED``), ``mode`` with ``mode_instance`` and
|
|
@@ -134,6 +135,9 @@ def parse_features(
|
|
|
134
135
|
# two features can carry a battery: keep the one that reads
|
|
135
136
|
if value is not None or state.get(key) is None:
|
|
136
137
|
state[key] = value
|
|
138
|
+
if name == "toggle" and instance == AMBIENT_MODE_INSTANCE:
|
|
139
|
+
# Fire TV lists the feature but never reports its state (observed)
|
|
140
|
+
state["ambient_mode_supported"] = True
|
|
137
141
|
options = dig(feature, "configuration", "modeOptions")
|
|
138
142
|
if name == "mode" and options:
|
|
139
143
|
state["mode_instance"] = instance
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: python-amazon-echo
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: Async Python client for Amazon Echo / Alexa devices: state, settings, media, notifications, lists, HTTP/2 push and LAN discovery
|
|
5
5
|
Project-URL: Homepage, https://github.com/hudsonbrendon/python-amazon-echo
|
|
6
6
|
Project-URL: Repository, https://github.com/hudsonbrendon/python-amazon-echo
|
|
@@ -235,7 +235,7 @@ with mocked HTTP.
|
|
|
235
235
|
| `build_authorize_url`, `register_device` | ported (the authorize URL answers 302 as expected; no registration was made) |
|
|
236
236
|
| `get_account`, `get_devices`, `get_routines`, `get_music_providers`, `get_service_urls` | live read |
|
|
237
237
|
| `get_dnd`, `get_volumes`, `get_bluetooth`, `get_notifications`, `get_alarm_volumes`, `get_wake_words`, `get_ascending_alarms`, `get_endpoint_states` | live read |
|
|
238
|
-
| `get_media` | live
|
|
238
|
+
| `get_media` | verified live on 2026-11-16 with Spotify: playing, title, provider and position, then paused when the sleep timer ran out |
|
|
239
239
|
| `get_wifi`, `get_equalizer`, `get_earcons`, `get_aux`, `get_setting`, `get_available_wake_words`, `get_alarm_sounds`, `get_default_alarm_sound` | live read |
|
|
240
240
|
| `get_whisper_mode`, `get_adaptive_volume` | live read |
|
|
241
241
|
| `set_whisper_mode`, `set_adaptive_volume` | no-op write during the reverse engineering (same request), not replayed by the library |
|
|
@@ -243,30 +243,33 @@ with mocked HTTP.
|
|
|
243
243
|
| `set_aux_direction` | no-op write accepted; the body field name is unconfirmed |
|
|
244
244
|
| `set_volume` (sequence pipeline) | no-op write |
|
|
245
245
|
| `create_reminder`, `delete_notification` | live (a reminder 320 days ahead was created and deleted) |
|
|
246
|
-
| `create_alarm` |
|
|
246
|
+
| `create_alarm` | music alarm verified live on 2026-11-16 (`music=`, reusing a Spotify music alarm made by voice): created on an Echo Plus with the requested date and time, then deleted. A plain alarm is ported, not replayed live |
|
|
247
247
|
| `create_alarm(music=…)` (music alarm that reuses the station of an existing one) | ported from Alexa Media Player's request, never sent |
|
|
248
|
-
| `play_music(timer=…)` (stop after that many seconds) |
|
|
248
|
+
| `play_music(timer=…)` (stop after that many seconds) | verified live on 2026-11-16 (Spotify): the music stopped by itself, though not at the exact second (25 s asked → stopped at 26 s; 20 s asked → about 38 s) |
|
|
249
249
|
| `create_timer` | verified live on an Echo Plus (pt-BR): a 12-minute timer, with and without a name, created and deleted. It is a typed request with the duration in words; English phrases are unit-tested only |
|
|
250
250
|
| `set_wake_word` | ported |
|
|
251
|
-
| `speak`, `announce`, `text_command`, `play_sound`, `play_music`, `
|
|
251
|
+
| `speak`, `announce`, `text_command`, `play_sound`, `play_music`, `info_skill`, `set_volume` | verified live on 2026-11-16 on an Echo Plus, through Home Assistant; the voice history shows each request and Alexa's answer |
|
|
252
|
+
| `launch_skill`, `run_routine`, `stop`, `send_drop_in_notification` | ported, not replayed live |
|
|
253
|
+
| `send_mobile_push` | sent live three times on 2026-11-16 (with and without the device fields, the second identical to Alexa Media Player's request); Amazon accepted all three but none reached the owner's phone. The phone's Alexa app registration lists no enabled notification types, so the cause is most likely on the phone; not proven |
|
|
252
254
|
| `media_command`, `bluetooth_connect`, `bluetooth_disconnect`, `reboot` | ported |
|
|
253
255
|
| `get_lists`, `get_list_items` | live read |
|
|
254
256
|
| `add_list_item`, `update_list_item`, `delete_list_item` | ported |
|
|
255
257
|
| `get_voice_history` | live read |
|
|
256
|
-
| `call_feature` |
|
|
258
|
+
| `call_feature` | verified live on 2026-11-16 (see the two rows below) |
|
|
257
259
|
| `get_endpoint_states` with the 0.2.0 query (illuminance, motion, humidity, air quality) | live read: a few hundred endpoints, no GraphQL error. Four devices advertise a light sensor and report no value; no device of the account reports motion, humidity or air quality, so those are unit tested only |
|
|
258
260
|
| `get_smart_home_endpoints` | live read; power, brightness, colour, colour temperature, temperature, battery, contact, motion and lock states and the operation names all parsed |
|
|
259
261
|
| `parse_endpoint_update` (smart-home push) | ported, not replayed live — no push stream on the test session |
|
|
260
|
-
| Smart-home operations through `call_feature`
|
|
261
|
-
| `
|
|
262
|
-
| `
|
|
262
|
+
| Smart-home operations through `call_feature` | `turnOn`, `turnOff` and `setBrightness` verified live on 2026-11-16 on a Tuya lamp linked to Alexa (Amazon reported each new state; the lamp was put back as it was). `setColor`, `setColorTemperature`, `setMode`, `lock`, `unlock` are ported, not replayed live; the payload of `setColorTemperature` is inferred |
|
|
263
|
+
| Fire TV ambient mode (`call_feature(…, "toggle", "turnOn"/"turnOff", instance="FTV.AmbientMode")`) | verified live on 2026-11-16 on a Fire TV Stick 4K Max: ADB showed the ambient app in front after `turnOn` and the previous app back after `turnOff`. Amazon lists the feature but never reports its state, so `get_endpoint_states` gives `ambient_mode_supported` with `ambient_mode` None |
|
|
264
|
+
| `get_communication_preferences` | verified live on an Echo Plus. The service is flaky for this account: on 2026-11-16 it answered HTTP 503 to roughly nine requests out of ten, on both the `.com` and the marketplace host |
|
|
265
|
+
| `set_communications`, `set_announcements`, `set_drop_in` | verified live on 2026-11-16 with no-op writes (the value just read) on an Echo Plus, read back unchanged; each took up to six attempts because of the 503s above |
|
|
263
266
|
| `get_device_preferences`, `get_kids_mode`, `get_children`, `get_kids_profile` | live read |
|
|
264
267
|
| `set_kids_mode` | ported, not replayed live — it changes how a device behaves |
|
|
265
268
|
| `get_guard` | live for an account without Guard (the appliance list is read, no panel is found, None); the state read is ported — the test account has no Guard |
|
|
266
269
|
| `set_guard` | ported, not replayed live — Guard was not touched |
|
|
267
|
-
| `
|
|
270
|
+
| `send_sequence`, `announce(method=…)` | ported, not replayed live |
|
|
268
271
|
| `enable_alarm`, `disable_alarm`, `skip_next_alarm` | ported, not replayed live |
|
|
269
|
-
| `set_background_image` |
|
|
272
|
+
| `set_background_image` | **does not work any more**: tried live on 2026-11-16 on an Echo Show 5, Amazon answers 200 but the background stays Amazon's (`/api/background-image` still reads `CURATIONS_SEASONAL`); a PUT answers 404. The current Alexa app uploads the picture through a native module instead. Kept for accounts where it still works |
|
|
270
273
|
| `PushClient` | handshake live (HTTP/2, 200, multipart boundary). the stream is then closed within ~1 s because the test session shares its registration with a running `alexa_media` (one stream per registration, see *Known limitations*); event parsing is unit tested only |
|
|
271
274
|
| `probe_local`, `is_reachable` | live (two Echo models answer, a smart TV of another brand returns None) |
|
|
272
275
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
amazon_echo/__init__.py,sha256=
|
|
1
|
+
amazon_echo/__init__.py,sha256=3BjisfLRJ2uU7LRcPwJw_XAf7G31aYJKjC9mdr_X0ss,1437
|
|
2
2
|
amazon_echo/__main__.py,sha256=1Hhd7w2cW5Z9jmwO1OThhcj6gbTLVqAQu5fAMqijJ_0,4325
|
|
3
3
|
amazon_echo/auth.py,sha256=O5SAtY5Wf76-LtFOkHJvrzlNoZdprgJsx5-3crEPUGQ,14417
|
|
4
|
-
amazon_echo/client.py,sha256=
|
|
5
|
-
amazon_echo/const.py,sha256
|
|
6
|
-
amazon_echo/endpoints.py,sha256=
|
|
4
|
+
amazon_echo/client.py,sha256=_IHh8dAEm75c7S6zMPzJDjglCuLsEkIl3KRiFdwZ_QM,83398
|
|
5
|
+
amazon_echo/const.py,sha256=-njl2W-dNUjufanhCYWyr1JgIdJVayQgkqLE9dGc_Cs,11880
|
|
6
|
+
amazon_echo/endpoints.py,sha256=K_7_s4znM2XkLukP6aP3Rop6qLJwV7P1SIBApd1Y1Ng,8197
|
|
7
7
|
amazon_echo/exceptions.py,sha256=7ETH4C2sKbKEJWnJ30ygAO0a_GiD5PWmDHJCSVTedAU,1120
|
|
8
8
|
amazon_echo/local.py,sha256=KHwwgC2-MzFZ0wBaxXRuotyr7-zrrenzfM0P3BEMRvE,3080
|
|
9
9
|
amazon_echo/models.py,sha256=ZKEHuiyG7hqRt5M8nufyf1nyaRZ2-l1WXlOCzG4UH7A,5258
|
|
10
10
|
amazon_echo/phrases.py,sha256=iqhqIK07XRTWmAwJ5jhzGPtqatvUz4nywCvJvCgwTK0,3579
|
|
11
11
|
amazon_echo/push.py,sha256=KMcHeDLgRxEjCQpTybiJUAUNTFTxlDMpTVPDv0ZYAzE,11206
|
|
12
12
|
amazon_echo/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
python_amazon_echo-0.3.
|
|
14
|
-
python_amazon_echo-0.3.
|
|
15
|
-
python_amazon_echo-0.3.
|
|
16
|
-
python_amazon_echo-0.3.
|
|
17
|
-
python_amazon_echo-0.3.
|
|
13
|
+
python_amazon_echo-0.3.4.dist-info/METADATA,sha256=yRnXpDZtUU6ItD__95a7nx5HMm9YKIz8EiA-A9t6KoM,19414
|
|
14
|
+
python_amazon_echo-0.3.4.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
15
|
+
python_amazon_echo-0.3.4.dist-info/entry_points.txt,sha256=rbZJ8BI8kkiDTV9cKk6acbHuyAm2xNYfpDBXQNw8Yb8,58
|
|
16
|
+
python_amazon_echo-0.3.4.dist-info/licenses/LICENSE,sha256=4Zgd3fbLJqWSkwKA-hh1rNN6DC9tNQ3rWLX93fingOw,1071
|
|
17
|
+
python_amazon_echo-0.3.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|