python-amazon-echo 0.2.0__py3-none-any.whl → 0.3.0__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 CHANGED
@@ -30,7 +30,7 @@ from .models import (
30
30
  )
31
31
  from .push import PushClient, PushEvent
32
32
 
33
- __version__ = "0.2.0"
33
+ __version__ = "0.3.0"
34
34
 
35
35
  __all__ = [
36
36
  "Account",
amazon_echo/client.py CHANGED
@@ -1425,16 +1425,32 @@ class AmazonEchoClient:
1425
1425
  )
1426
1426
  )
1427
1427
 
1428
- async def play_music(self, device: Device, provider_id: str, phrase: str) -> None:
1429
- """Play ``phrase`` from a music provider (see :meth:`get_music_providers`)."""
1428
+ async def play_music(
1429
+ self,
1430
+ device: Device,
1431
+ provider_id: str,
1432
+ phrase: str,
1433
+ *,
1434
+ timer: int | None = None,
1435
+ ) -> None:
1436
+ """Play ``phrase`` from a music provider (see :meth:`get_music_providers`).
1437
+
1438
+ Args:
1439
+ device: The device that plays.
1440
+ provider_id: A key of :meth:`get_music_providers`.
1441
+ phrase: What to search for.
1442
+ timer: Stop after this many seconds (a sleep timer).
1443
+
1444
+ """
1445
+ payload: dict[str, Any] = {
1446
+ "searchPhrase": phrase,
1447
+ "sanitizedSearchPhrase": phrase,
1448
+ "musicProviderId": provider_id,
1449
+ }
1450
+ if timer:
1451
+ payload["waitTimeInSeconds"] = timer
1430
1452
  await self._run(
1431
- await self._node(
1432
- device,
1433
- "Alexa.Music.PlaySearchPhrase",
1434
- searchPhrase=phrase,
1435
- sanitizedSearchPhrase=phrase,
1436
- musicProviderId=provider_id,
1437
- )
1453
+ await self._node(device, "Alexa.Music.PlaySearchPhrase", **payload)
1438
1454
  )
1439
1455
 
1440
1456
  async def launch_skill(self, device: Device, skill_id: str) -> None:
@@ -1582,6 +1598,7 @@ class AmazonEchoClient:
1582
1598
  *,
1583
1599
  label: str | None = None,
1584
1600
  recurrence: str | None = None,
1601
+ music: Notification | None = None,
1585
1602
  ) -> Notification:
1586
1603
  """Create an alarm.
1587
1604
 
@@ -1592,6 +1609,14 @@ class AmazonEchoClient:
1592
1609
  label: Not supported by Amazon for alarms; accepted and ignored.
1593
1610
  recurrence: ``DAILY``, ``WEEKDAYS``, ``WEEKENDS``, ``WEEKLY`` or a
1594
1611
  day list such as ``MO,WE,FR``.
1612
+ music: An existing music alarm of the account; the new alarm
1613
+ wakes with the same station. Amazon has no public way to
1614
+ search for a station, so one that was picked in the Alexa app
1615
+ is reused (the ``MUSIC-<id>`` tone :meth:`enable_alarm` sends;
1616
+ this request has not been replayed against Amazon).
1617
+
1618
+ Raises:
1619
+ AmazonEchoNotSupportedError: ``music`` is not a music alarm.
1595
1620
 
1596
1621
  """
1597
1622
  del label
@@ -1599,17 +1624,20 @@ class AmazonEchoClient:
1599
1624
  trigger: dict[str, Any] = {"scheduledTime": local.isoformat(timespec="seconds")}
1600
1625
  if recurrence:
1601
1626
  trigger["recurrence"] = _recurrence_rule(recurrence, local)
1627
+ body: dict[str, Any] = {
1628
+ "trigger": trigger,
1629
+ "extensions": [],
1630
+ "endpointId": f"{device.serial}@{device.device_type}",
1631
+ }
1632
+ if music is not None:
1633
+ if not (music_id := music.raw.get("musicAlarmId")):
1634
+ raise AmazonEchoNotSupportedError("Not a music alarm")
1635
+ body["assets"] = [{"type": "TONE", "assetId": f"MUSIC-{music_id}"}]
1602
1636
  known = {item.id for item in await self.get_notifications()}
1603
- await self._alerts(
1604
- "POST",
1605
- "alarms",
1606
- {
1607
- "trigger": trigger,
1608
- "extensions": [],
1609
- "endpointId": f"{device.serial}@{device.device_type}",
1610
- },
1637
+ await self._alerts("POST", "alarms", body)
1638
+ return await self._find_new(
1639
+ device, "alarm" if music is None else "music_alarm", known
1611
1640
  )
1612
- return await self._find_new(device, "alarm", known)
1613
1641
 
1614
1642
  async def create_reminder(
1615
1643
  self, device: Device, when: datetime, label: str
amazon_echo/const.py CHANGED
@@ -4,7 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  from typing import Any, Final
6
6
 
7
- VERSION: Final = "0.2.0"
7
+ VERSION: Final = "0.3.0"
8
8
 
9
9
  # Identity of the Alexa iOS app, which is what a registration impersonates.
10
10
  APP_NAME: Final = "Amazon Echo for Home Assistant"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-amazon-echo
3
- Version: 0.2.0
3
+ Version: 0.3.0
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
@@ -244,6 +244,8 @@ with mocked HTTP.
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
246
  | `create_alarm` | ported |
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) | ported from Alexa Media Player's payload, never sent |
247
249
  | `create_timer` | ported — body inferred from field names in the app, never sent |
248
250
  | `set_wake_word` | ported |
249
251
  | `speak`, `announce`, `text_command`, `play_sound`, `play_music`, `launch_skill`, `run_routine`, `stop` | ported |
@@ -256,8 +258,8 @@ with mocked HTTP.
256
258
  | `get_smart_home_endpoints` | live read; power, brightness, colour, colour temperature, temperature, battery, contact, motion and lock states and the operation names all parsed |
257
259
  | `parse_endpoint_update` (smart-home push) | ported, not replayed live — no push stream on the test session |
258
260
  | Smart-home operations through `call_feature` (`turnOn`, `turnOff`, `setBrightness`, `setColor`, `setColorTemperature`, `setMode`, `lock`, `unlock`) | ported, not replayed live — they change a device's visible state. The request shapes of `power`, `brightness`, `lock` and `toggle` are the ones in the Alexa app; the payload of `setColorTemperature` is inferred |
259
- | `get_communication_preferences` | ported. Called live on five devices: the service answers HTTP 503 for this account whatever the device, while `/accounts` on the same host answers 200 with the same cookies |
260
- | `set_communications`, `set_announcements`, `set_drop_in` | ported, not replayed live — there was no value to write back (see the line above) |
261
+ | `get_communication_preferences` | verified live once (an Echo Plus answered `announcements: true, communications: true, drop_in: all`); otherwise the service answered HTTP 503 on about 95 % of 60+ spaced requests on 2026-11-16, on both the `.com` and the marketplace host, with cookies or a bearer token |
262
+ | `set_communications`, `set_announcements`, `set_drop_in` | ported, not replayed live — the no-op write was attempted three times each and the service answered 503 every time |
261
263
  | `get_device_preferences`, `get_kids_mode`, `get_children`, `get_kids_profile` | live read |
262
264
  | `set_kids_mode` | ported, not replayed live — it changes how a device behaves |
263
265
  | `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 |
@@ -289,6 +291,9 @@ with mocked HTTP.
289
291
  pass a naive datetime in the Echo's local time if the host lives elsewhere.
290
292
  - **Alarms have no label** in Amazon's API; `create_alarm(label=…)` is accepted
291
293
  and ignored.
294
+ - **Music alarms** can only reuse a station: `create_alarm(music=…)` takes a
295
+ music alarm that already exists on the account (create one in the Alexa app
296
+ first) and wakes with the same station. Amazon has no public search for one.
292
297
  - **`create_timer` is unverified** (see the table). Use
293
298
  `text_command(device, "set a timer for 5 minutes")` if it is rejected.
294
299
  - **Voice history** comes 10 records per call; at most 50 are fetched.
@@ -1,16 +1,16 @@
1
- amazon_echo/__init__.py,sha256=0oC9ErIQXFVmdUTl7RYXw1hvl6-gTp3yN2s0qY-8NqM,1437
1
+ amazon_echo/__init__.py,sha256=qY8C7gE4GVFBxuYAtrbgmhhoWxM8EAFej8HRcc2LuNo,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=k8xzNc6WDSadtZ444HgdCFK71CACFZOYLLN8ODgWvLk,79419
5
- amazon_echo/const.py,sha256=o8qqiY7JCD1BDELpIn-L17FT2THn_ni_5YejGtWZVM4,11880
4
+ amazon_echo/client.py,sha256=7AP2eBJ6_E_y029m8LwSEcz9d0WT0MR5Gu-YSrpuLdA,80593
5
+ amazon_echo/const.py,sha256=vOG2d3FC5ewenGSNrFwXi7-X0Vp4GrPejcVjp2YQWrg,11880
6
6
  amazon_echo/endpoints.py,sha256=_6vXYWtwGIR_2IjVFJAXWP1vR6jwzIpZ4upkRctwBp8,7925
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/push.py,sha256=KMcHeDLgRxEjCQpTybiJUAUNTFTxlDMpTVPDv0ZYAzE,11206
11
11
  amazon_echo/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- python_amazon_echo-0.2.0.dist-info/METADATA,sha256=Jn6gvMcgmFIkkgObcl4-09A9n07PU0NTChVHwJ7_nGY,16967
13
- python_amazon_echo-0.2.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
14
- python_amazon_echo-0.2.0.dist-info/entry_points.txt,sha256=rbZJ8BI8kkiDTV9cKk6acbHuyAm2xNYfpDBXQNw8Yb8,58
15
- python_amazon_echo-0.2.0.dist-info/licenses/LICENSE,sha256=4Zgd3fbLJqWSkwKA-hh1rNN6DC9tNQ3rWLX93fingOw,1071
16
- python_amazon_echo-0.2.0.dist-info/RECORD,,
12
+ python_amazon_echo-0.3.0.dist-info/METADATA,sha256=TFFdzx2CS4r1ZfO3jl7f-LFyeSZ4dxZarv0LibnZbls,17589
13
+ python_amazon_echo-0.3.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
14
+ python_amazon_echo-0.3.0.dist-info/entry_points.txt,sha256=rbZJ8BI8kkiDTV9cKk6acbHuyAm2xNYfpDBXQNw8Yb8,58
15
+ python_amazon_echo-0.3.0.dist-info/licenses/LICENSE,sha256=4Zgd3fbLJqWSkwKA-hh1rNN6DC9tNQ3rWLX93fingOw,1071
16
+ python_amazon_echo-0.3.0.dist-info/RECORD,,