pywiim 3.0.0__tar.gz → 3.0.2__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.
Files changed (86) hide show
  1. {pywiim-3.0.0/pywiim.egg-info → pywiim-3.0.2}/PKG-INFO +1 -1
  2. {pywiim-3.0.0 → pywiim-3.0.2}/pyproject.toml +3 -1
  3. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/__init__.py +1 -1
  4. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/__init__.py +13 -3
  5. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/base.py +1 -0
  6. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/debounce.py +6 -1
  7. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/statemgr.py +24 -18
  8. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/polling.py +1 -1
  9. {pywiim-3.0.0 → pywiim-3.0.2/pywiim.egg-info}/PKG-INFO +1 -1
  10. {pywiim-3.0.0 → pywiim-3.0.2}/LICENSE +0 -0
  11. {pywiim-3.0.0 → pywiim-3.0.2}/README.md +0 -0
  12. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/__init__.py +0 -0
  13. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/audio_pro.py +0 -0
  14. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/audio_settings.py +0 -0
  15. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/base.py +0 -0
  16. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/bluetooth.py +0 -0
  17. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/constants.py +0 -0
  18. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/device.py +0 -0
  19. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/diagnostics.py +0 -0
  20. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/endpoints.py +0 -0
  21. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/eq.py +0 -0
  22. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/firmware.py +0 -0
  23. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/group.py +0 -0
  24. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/lms.py +0 -0
  25. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/loop_mode.py +0 -0
  26. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/misc.py +0 -0
  27. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/parser.py +0 -0
  28. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/peq.py +0 -0
  29. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/playback.py +0 -0
  30. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/preset.py +0 -0
  31. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/ssl.py +0 -0
  32. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/subwoofer.py +0 -0
  33. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/api/timer.py +0 -0
  34. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/backoff.py +0 -0
  35. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/capabilities.py +0 -0
  36. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/cli/__init__.py +0 -0
  37. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/cli/diagnostics.py +0 -0
  38. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/cli/discovery_cli.py +0 -0
  39. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/cli/group_test_cli.py +0 -0
  40. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/cli/join_test_cli.py +0 -0
  41. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/cli/monitor_cli.py +0 -0
  42. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/cli/verify_cli.py +0 -0
  43. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/client.py +0 -0
  44. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/device_capabilities.py +0 -0
  45. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/discovery.py +0 -0
  46. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/exceptions.py +0 -0
  47. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/group.py +0 -0
  48. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/group_helpers.py +0 -0
  49. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/mcp/__init__.py +0 -0
  50. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/mcp/__main__.py +0 -0
  51. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/mcp/config.example.json +0 -0
  52. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/mcp/config.py +0 -0
  53. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/mcp/context.py +0 -0
  54. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/mcp/server.py +0 -0
  55. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/metadata.py +0 -0
  56. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/model_names.py +0 -0
  57. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/models.py +0 -0
  58. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/normalize.py +0 -0
  59. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/audio.py +0 -0
  60. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/bluetooth.py +0 -0
  61. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/coverart.py +0 -0
  62. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/diagnostics.py +0 -0
  63. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/groupops.py +0 -0
  64. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/media.py +0 -0
  65. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/playback.py +0 -0
  66. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/properties.py +0 -0
  67. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/source_capabilities.py +0 -0
  68. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/stream.py +0 -0
  69. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/stream_enricher.py +0 -0
  70. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/player/volume.py +0 -0
  71. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/profiles.py +0 -0
  72. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/py.typed +0 -0
  73. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/role.py +0 -0
  74. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/state.py +0 -0
  75. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/upnp/__init__.py +0 -0
  76. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/upnp/client.py +0 -0
  77. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/upnp/eventer.py +0 -0
  78. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/upnp/health.py +0 -0
  79. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/upnp/metadata.py +0 -0
  80. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim/upnp/playqueue.py +0 -0
  81. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim.egg-info/SOURCES.txt +0 -0
  82. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim.egg-info/dependency_links.txt +0 -0
  83. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim.egg-info/entry_points.txt +0 -0
  84. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim.egg-info/requires.txt +0 -0
  85. {pywiim-3.0.0 → pywiim-3.0.2}/pywiim.egg-info/top_level.txt +0 -0
  86. {pywiim-3.0.0 → pywiim-3.0.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pywiim
3
- Version: 3.0.0
3
+ Version: 3.0.2
4
4
  Summary: Python library for WiiM/LinkPlay device communication
5
5
  Author-email: Michael Cumming <mjcumming@gmail.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pywiim"
7
- version = "3.0.0"
7
+ version = "3.0.2"
8
8
  description = "Python library for WiiM/LinkPlay device communication"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -113,4 +113,6 @@ addopts = "-m 'not integration'"
113
113
  filterwarnings = [
114
114
  "ignore:Unclosed client session:ResourceWarning",
115
115
  "ignore:Unclosed connector:ResourceWarning",
116
+ "error:coroutine .* was never awaited:RuntimeWarning",
117
+ "error::pytest.PytestUnraisableExceptionWarning",
116
118
  ]
@@ -105,7 +105,7 @@ from .profiles import (
105
105
  from .role import RoleDetectionResult, detect_role
106
106
  from .state import GroupStateSynchronizer, StateSynchronizer
107
107
 
108
- __version__ = "3.0.0"
108
+ __version__ = "3.0.2"
109
109
  __all__ = [
110
110
  # Main client
111
111
  "WiiMClient",
@@ -7,6 +7,7 @@ that adds group awareness, role management, and cached state with getter methods
7
7
  from __future__ import annotations
8
8
 
9
9
  import logging
10
+ import time
10
11
  from collections.abc import Callable, Sequence
11
12
  from typing import TYPE_CHECKING, Any, Literal
12
13
 
@@ -410,16 +411,25 @@ class Player(PlayerBase):
410
411
  self._on_state_changed()
411
412
 
412
413
  async def initialize_peq_presets(self) -> None:
413
- """Read saved PEQ preset names once per player session."""
414
+ """Read saved PEQ names if the player's cache is not initialized."""
414
415
  if self._peq_presets is not None:
415
416
  return
416
- presets = await self.client.get_peq_preset_list()
417
- self._peq_presets = list(dict.fromkeys(name for key in ("custom", "preset") for name in presets[key] if name))
417
+ await self._refresh_peq_presets()
418
418
  try:
419
419
  await self.refresh_peq_preset()
420
420
  except WiiMError as err:
421
421
  _LOGGER.debug("Could not read initial PEQ state for %s: %s", self.host, err)
422
422
 
423
+ async def _refresh_peq_presets(self) -> None:
424
+ """Refresh saved names without changing the active PEQ state."""
425
+ try:
426
+ presets = await self.client.get_peq_preset_list()
427
+ self._peq_presets = list(
428
+ dict.fromkeys(name for key in ("custom", "preset") for name in presets[key] if name)
429
+ )
430
+ finally:
431
+ self._last_peq_presets_check = time.time()
432
+
423
433
  async def refresh_peq_preset(self) -> None:
424
434
  """Refresh the current input's active PEQ preset."""
425
435
  async with self._peq_lock:
@@ -158,6 +158,7 @@ class PlayerBase:
158
158
  self._room_correction_name: str = ""
159
159
  self._last_room_correction_check: float = 0
160
160
  self._peq_presets: list[str] | None = None
161
+ self._last_peq_presets_check: float = 0
161
162
  self._peq_preset: str | None = None
162
163
  self._peq_enabled: bool | None = None
163
164
  self._last_peq_state_check: float = 0
@@ -46,7 +46,12 @@ class PlayStateDebouncer:
46
46
 
47
47
  try:
48
48
  loop = asyncio.get_event_loop()
49
- self._pending_task = loop.create_task(self._apply_delayed_state(new_state))
49
+ pending = self._apply_delayed_state(new_state)
50
+ try:
51
+ self._pending_task = loop.create_task(pending)
52
+ except RuntimeError:
53
+ pending.close()
54
+ raise
50
55
  except RuntimeError:
51
56
  # No event loop (sync context) - apply immediately
52
57
  _LOGGER.debug("No event loop available, applying state immediately: %s", new_state)
@@ -58,6 +58,10 @@ def _coerce_player_play_state(value: str | None) -> _PlayerPlayState | None:
58
58
  # UPnP retry cooldown - wait this many seconds between failed creation attempts
59
59
  UPNP_RETRY_COOLDOWN = 60.0
60
60
 
61
+ # Saved EQ names change infrequently; retry an empty initial cache sooner.
62
+ EQ_PRESET_LIST_INTERVAL = 15 * 60.0
63
+ EQ_PRESET_INITIAL_RETRY_INTERVAL = 60.0
64
+
61
65
  # Sources where play_url() filename fallback is the intended title.
62
66
  # WiiM reports URL playback as custompushurl (display name "URL Stream").
63
67
  _URL_PLAYBACK_SOURCES = frozenset({"wifi", "network", "ethernet", "usb", "udisk", "http", "custompushurl"})
@@ -1079,21 +1083,14 @@ class StateManager:
1079
1083
  # Clear cached state on exception to avoid showing stale information
1080
1084
  self.player._audio_output_status = None
1081
1085
 
1082
- # EQ Preset List - Fetch on full refresh, track change, or periodically (every 60s)
1083
- # Track changes may indicate preset changes (user switched to different preset/station)
1084
- # Periodic fetch ensures list stays current even without activity
1086
+ # Saved lists change infrequently and are independent of track changes.
1087
+ # A new input invalidates the graphic list and needs an immediate read.
1085
1088
  eq_supported = self.player.client.capabilities.get("supports_eq", False)
1086
- should_fetch_eq_presets = (
1087
- full
1088
- or track_changed
1089
- or (self.player._eq_presets is None and now - (self.player._last_eq_presets_check or 0) >= 60)
1090
- or (
1091
- self._polling_strategy
1092
- and self._polling_strategy.should_fetch_eq_info(
1093
- self.player._last_eq_presets_check, eq_supported, now=now
1094
- )
1095
- )
1089
+ last_eq_list_check = self.player._last_eq_presets_check or 0
1090
+ eq_list_interval = (
1091
+ EQ_PRESET_INITIAL_RETRY_INTERVAL if self.player._eq_presets is None else EQ_PRESET_LIST_INTERVAL
1096
1092
  )
1093
+ should_fetch_eq_presets = full or not last_eq_list_check or now - last_eq_list_check >= eq_list_interval
1097
1094
  if should_fetch_eq_presets and eq_supported:
1098
1095
  source = self.player._eq_state_source
1099
1096
  revision = self.player._eq_state_revision
@@ -1107,9 +1104,8 @@ class StateManager:
1107
1104
  if source == self.player._eq_state_source and revision == self.player._eq_state_revision:
1108
1105
  self.player._last_eq_presets_check = now
1109
1106
 
1110
- # EQGetBand - enabled flag and preset name. Same cadence as the preset list,
1111
- # plus once when getPlayerStatus eq changes, so a real app change is confirmed
1112
- # without trusting the stale status field.
1107
+ # EQGetBand - enabled flag and preset name. Active state retains its own
1108
+ # shorter cadence and can change without the saved preset list changing.
1113
1109
  should_fetch_eq_status = (
1114
1110
  full
1115
1111
  or track_changed
@@ -1289,9 +1285,18 @@ class StateManager:
1289
1285
  except Exception as err:
1290
1286
  _LOGGER.debug("Failed to fetch DAC digital filter for %s: %s", self.player.host, err)
1291
1287
 
1292
- # RoomFit. The profile list changes in the app, so refresh names and the
1293
- # switch together on the same 60s tier. supports_peq is the gate.
1288
+ # PEQ names are cached independently of the current input's active state.
1294
1289
  peq_supported = bool(self.player.client.capabilities.get("supports_peq", False))
1290
+ last_peq_list_check = self.player._last_peq_presets_check or 0
1291
+ peq_list_interval = (
1292
+ EQ_PRESET_INITIAL_RETRY_INTERVAL if self.player._peq_presets is None else EQ_PRESET_LIST_INTERVAL
1293
+ )
1294
+ if peq_supported and (full or not last_peq_list_check or now - last_peq_list_check >= peq_list_interval):
1295
+ try:
1296
+ await self.player._refresh_peq_presets()
1297
+ except Exception as err:
1298
+ _LOGGER.debug("Failed to fetch PEQ presets for %s: %s", self.player.host, err)
1299
+
1295
1300
  should_fetch_peq = (
1296
1301
  full
1297
1302
  or eq_source_changed
@@ -1309,6 +1314,7 @@ class StateManager:
1309
1314
  self.player._last_peq_state_check = now
1310
1315
  except Exception as err:
1311
1316
  _LOGGER.debug("Failed to fetch PEQ state for %s: %s", self.player.host, err)
1317
+ # RoomFit profiles and state remain on their existing configuration tier.
1312
1318
  should_fetch_room = full or (
1313
1319
  self._polling_strategy
1314
1320
  and self._polling_strategy.should_fetch_led_indicator(
@@ -63,7 +63,7 @@ class PollingStrategy:
63
63
  # Polling interval constants (in seconds)
64
64
  FAST_POLL_INTERVAL = 1.0 # Active Playback / UI Responsiveness
65
65
  NORMAL_POLL_INTERVAL = 5.0 # Idle / Background
66
- CONFIGURATION_INTERVAL = 60.0 # Bluetooth, EQ presets, device info
66
+ CONFIGURATION_INTERVAL = 60.0 # Bluetooth, active EQ state, device info
67
67
  # Faster tier for user-toggled hardware (12V trigger, subwoofer) — light GETs, visible in HA/monitor
68
68
  HARDWARE_STATUS_INTERVAL = 15.0
69
69
  METADATA_CHECK_INTERVAL = 1.0 # Check for track changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pywiim
3
- Version: 3.0.0
3
+ Version: 3.0.2
4
4
  Summary: Python library for WiiM/LinkPlay device communication
5
5
  Author-email: Michael Cumming <mjcumming@gmail.com>
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes