pywiim 2.3.20__tar.gz → 2.3.22__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.
- {pywiim-2.3.20/pywiim.egg-info → pywiim-2.3.22}/PKG-INFO +1 -1
- {pywiim-2.3.20 → pywiim-2.3.22}/pyproject.toml +1 -1
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/__init__.py +1 -1
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/peq.py +25 -4
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/__init__.py +42 -1
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/audio.py +13 -5
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/base.py +10 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/properties.py +4 -1
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/statemgr.py +94 -41
- {pywiim-2.3.20 → pywiim-2.3.22/pywiim.egg-info}/PKG-INFO +1 -1
- {pywiim-2.3.20 → pywiim-2.3.22}/LICENSE +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/README.md +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/__init__.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/audio_pro.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/audio_settings.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/base.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/bluetooth.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/constants.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/device.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/diagnostics.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/endpoints.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/eq.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/firmware.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/group.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/lms.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/loop_mode.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/misc.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/parser.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/playback.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/preset.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/ssl.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/subwoofer.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/api/timer.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/backoff.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/capabilities.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/cli/__init__.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/cli/diagnostics.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/cli/discovery_cli.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/cli/group_test_cli.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/cli/join_test_cli.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/cli/monitor_cli.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/cli/verify_cli.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/client.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/device_capabilities.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/discovery.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/exceptions.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/group.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/group_helpers.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/mcp/__init__.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/mcp/__main__.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/mcp/config.example.json +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/mcp/config.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/mcp/context.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/mcp/server.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/metadata.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/model_names.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/models.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/normalize.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/bluetooth.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/coverart.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/debounce.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/diagnostics.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/groupops.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/media.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/playback.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/source_capabilities.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/stream.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/stream_enricher.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/player/volume.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/polling.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/profiles.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/py.typed +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/role.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/state.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/upnp/__init__.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/upnp/client.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/upnp/eventer.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/upnp/health.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/upnp/metadata.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim/upnp/playqueue.py +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim.egg-info/SOURCES.txt +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim.egg-info/dependency_links.txt +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim.egg-info/entry_points.txt +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim.egg-info/requires.txt +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/pywiim.egg-info/top_level.txt +0 -0
- {pywiim-2.3.20 → pywiim-2.3.22}/setup.cfg +0 -0
|
@@ -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__ = "2.3.
|
|
108
|
+
__version__ = "2.3.22"
|
|
109
109
|
__all__ = [
|
|
110
110
|
# Main client
|
|
111
111
|
"WiiMClient",
|
|
@@ -40,7 +40,7 @@ from dataclasses import dataclass, field
|
|
|
40
40
|
from typing import Any
|
|
41
41
|
from urllib.parse import quote
|
|
42
42
|
|
|
43
|
-
from ..exceptions import WiiMError
|
|
43
|
+
from ..exceptions import WiiMError, WiiMResponseError
|
|
44
44
|
from .constants import (
|
|
45
45
|
API_ENDPOINT_EQ_OFF,
|
|
46
46
|
API_ENDPOINT_PEQ_CHANGE_FX,
|
|
@@ -423,7 +423,13 @@ class PEQAPI:
|
|
|
423
423
|
endpoint = API_ENDPOINT_PEQ_GET_BAND + quote(PEQ_PLUGIN_URI, safe="")
|
|
424
424
|
|
|
425
425
|
raw = await self._request(endpoint) # type: ignore[attr-defined]
|
|
426
|
-
|
|
426
|
+
if (
|
|
427
|
+
not isinstance(raw.parsed, dict)
|
|
428
|
+
or str(raw.parsed.get("status", "ok")).lower() != "ok"
|
|
429
|
+
or str(raw.parsed.get("EQStat", "")).lower() not in ("on", "off")
|
|
430
|
+
):
|
|
431
|
+
raise WiiMResponseError("Invalid PEQ state response", endpoint=endpoint)
|
|
432
|
+
return _parse_peq_settings(raw.parsed)
|
|
427
433
|
|
|
428
434
|
async def get_graphic_eq_bands(self, source_name: str | None = None) -> GraphicEQSettings:
|
|
429
435
|
"""Get WiiM LV2 graphic 10-band EQ settings.
|
|
@@ -725,7 +731,15 @@ class PEQAPI:
|
|
|
725
731
|
self._require_peq()
|
|
726
732
|
endpoint = API_ENDPOINT_PEQ_GET_LIST + quote(PEQ_PLUGIN_URI, safe="")
|
|
727
733
|
raw = await self._request(endpoint) # type: ignore[attr-defined]
|
|
728
|
-
data = raw.parsed
|
|
734
|
+
data = raw.parsed
|
|
735
|
+
if (
|
|
736
|
+
not isinstance(data, dict)
|
|
737
|
+
or str(data.get("status", "ok")).lower() != "ok"
|
|
738
|
+
or not all(isinstance(data.get(k), list) for k in ("custom", "preset"))
|
|
739
|
+
):
|
|
740
|
+
raise WiiMResponseError("Invalid PEQ preset list response", endpoint=endpoint)
|
|
741
|
+
if not all(isinstance(name, str) for key in ("custom", "preset") for name in data[key]):
|
|
742
|
+
raise WiiMResponseError("Invalid PEQ preset name", endpoint=endpoint)
|
|
729
743
|
return {
|
|
730
744
|
"custom": list(data.get("custom", [])),
|
|
731
745
|
"preset": list(data.get("preset", [])),
|
|
@@ -826,7 +840,14 @@ class PEQAPI:
|
|
|
826
840
|
payload = {"pluginURI": PEQ_PLUGIN_URI, "Name": name}
|
|
827
841
|
endpoint = API_ENDPOINT_PEQ_LOAD + _encode_json_param(payload)
|
|
828
842
|
raw = await self._request(endpoint) # type: ignore[attr-defined]
|
|
829
|
-
|
|
843
|
+
if (
|
|
844
|
+
not isinstance(raw.parsed, dict)
|
|
845
|
+
or str(raw.parsed.get("status", "")).lower() != "ok"
|
|
846
|
+
or str(raw.parsed.get("EQStat", "")).lower() != "on"
|
|
847
|
+
or raw.parsed.get("Name") != name
|
|
848
|
+
):
|
|
849
|
+
raise WiiMResponseError(f"Failed to load PEQ preset {name!r}", endpoint=endpoint)
|
|
850
|
+
return _parse_peq_settings(raw.parsed)
|
|
830
851
|
|
|
831
852
|
async def delete_peq(self, name: str) -> None:
|
|
832
853
|
"""Delete a custom PEQ preset by name.
|
|
@@ -406,6 +406,37 @@ class Player(PlayerBase):
|
|
|
406
406
|
if self._on_state_changed:
|
|
407
407
|
self._on_state_changed()
|
|
408
408
|
|
|
409
|
+
async def initialize_peq_presets(self) -> None:
|
|
410
|
+
"""Read saved PEQ preset names once per player session."""
|
|
411
|
+
if self._peq_presets is not None:
|
|
412
|
+
return
|
|
413
|
+
presets = await self.client.get_peq_preset_list()
|
|
414
|
+
self._peq_presets = list(dict.fromkeys(name for key in ("custom", "preset") for name in presets[key] if name))
|
|
415
|
+
if self._peq_presets:
|
|
416
|
+
await self.refresh_peq_preset()
|
|
417
|
+
|
|
418
|
+
async def refresh_peq_preset(self) -> None:
|
|
419
|
+
"""Refresh the current input's active PEQ preset."""
|
|
420
|
+
async with self._peq_lock:
|
|
421
|
+
try:
|
|
422
|
+
settings = await self.client.get_peq_bands()
|
|
423
|
+
except WiiMError:
|
|
424
|
+
self._peq_preset = None
|
|
425
|
+
raise
|
|
426
|
+
self._peq_preset = (
|
|
427
|
+
settings.name if settings.enabled and settings.name in (self._peq_presets or []) else None
|
|
428
|
+
)
|
|
429
|
+
|
|
430
|
+
async def set_peq_preset(self, name: str) -> None:
|
|
431
|
+
"""Load a saved PEQ preset for this player's active input."""
|
|
432
|
+
if name not in (self._peq_presets or []):
|
|
433
|
+
raise WiiMError(f"Unknown PEQ preset {name!r}")
|
|
434
|
+
async with self._peq_lock:
|
|
435
|
+
settings = await self.client.load_peq(name)
|
|
436
|
+
self._peq_preset = settings.name if settings.enabled and settings.name == name else None
|
|
437
|
+
if self._on_state_changed:
|
|
438
|
+
self._on_state_changed()
|
|
439
|
+
|
|
409
440
|
async def set_room_correction(self, name: str) -> None:
|
|
410
441
|
"""Load a RoomFit profile, or turn RoomFit off.
|
|
411
442
|
|
|
@@ -1161,7 +1192,7 @@ class Player(PlayerBase):
|
|
|
1161
1192
|
|
|
1162
1193
|
@property
|
|
1163
1194
|
def eq_preset(self) -> str | None:
|
|
1164
|
-
"""Current EQ preset
|
|
1195
|
+
"""Current EQ preset, or Off when EQ is bypassed."""
|
|
1165
1196
|
return self._properties.eq_preset
|
|
1166
1197
|
|
|
1167
1198
|
@property
|
|
@@ -1413,6 +1444,16 @@ class Player(PlayerBase):
|
|
|
1413
1444
|
return item.name
|
|
1414
1445
|
return None
|
|
1415
1446
|
|
|
1447
|
+
@property
|
|
1448
|
+
def peq_presets(self) -> list[str]:
|
|
1449
|
+
"""Saved PEQ preset names cached for this player session."""
|
|
1450
|
+
return list(self._peq_presets or [])
|
|
1451
|
+
|
|
1452
|
+
@property
|
|
1453
|
+
def peq_preset(self) -> str | None:
|
|
1454
|
+
"""Active PEQ preset for the current source, if known."""
|
|
1455
|
+
return self._peq_preset
|
|
1456
|
+
|
|
1416
1457
|
@property
|
|
1417
1458
|
def room_correction_profiles(self) -> list[str]:
|
|
1418
1459
|
"""Cached RoomFit profile names."""
|
|
@@ -475,12 +475,16 @@ class AudioConfiguration:
|
|
|
475
475
|
available_presets=available_presets or None,
|
|
476
476
|
)
|
|
477
477
|
|
|
478
|
-
# Update cached state immediately (optimistic) with normalized preset
|
|
478
|
+
# Update cached state immediately (optimistic) with normalized preset.
|
|
479
|
+
# Remember it as the EQGetBand name so later status polls cannot replace it
|
|
480
|
+
# with a stale flat value once the short preservation window ends.
|
|
479
481
|
if self.player._status_model:
|
|
480
482
|
self.player._status_model.eq_preset = normalized_preset
|
|
483
|
+
self.player._eq_band_preset = normalized_preset
|
|
484
|
+
self.player._eq_band_reconcile = False
|
|
481
485
|
|
|
482
486
|
# Track when EQ was set for preserving optimistic update during refresh
|
|
483
|
-
# Device status endpoint returns stale EQ data
|
|
487
|
+
# Device status endpoint returns stale EQ data and may never catch up
|
|
484
488
|
self.player._last_eq_preset_set_time = time.time()
|
|
485
489
|
|
|
486
490
|
# Verify by querying the authoritative EQ endpoint after a brief delay
|
|
@@ -488,10 +492,14 @@ class AudioConfiguration:
|
|
|
488
492
|
try:
|
|
489
493
|
await asyncio.sleep(0.3) # Brief delay for device to apply
|
|
490
494
|
eq_data = await self.player.client.get_eq()
|
|
491
|
-
verified_preset =
|
|
495
|
+
verified_preset = None
|
|
496
|
+
if isinstance(eq_data, dict):
|
|
497
|
+
verified_preset = eq_data.get("Name") or eq_data.get("name")
|
|
492
498
|
if verified_preset and self.player._status_model:
|
|
493
|
-
|
|
494
|
-
|
|
499
|
+
verified_name = str(verified_preset)
|
|
500
|
+
self.player._status_model.eq_preset = verified_name
|
|
501
|
+
self.player._eq_band_preset = verified_name
|
|
502
|
+
_LOGGER.debug("EQ preset verified: %s", verified_name)
|
|
495
503
|
except Exception as err:
|
|
496
504
|
# If verification fails, keep the optimistic update
|
|
497
505
|
_LOGGER.debug("EQ verification failed, keeping optimistic value: %s", err)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import asyncio
|
|
5
6
|
import logging
|
|
6
7
|
import weakref
|
|
7
8
|
from collections.abc import Callable
|
|
@@ -98,6 +99,11 @@ class PlayerBase:
|
|
|
98
99
|
self._eq_enabled: bool | None = None
|
|
99
100
|
self._last_eq_status_check: float = 0 # Track when EQ status was last fetched
|
|
100
101
|
|
|
102
|
+
# Preset name from EQGetBand. getPlayerStatus eq stays at flat on current
|
|
103
|
+
# firmware after EQLoad, so this name outranks that field (wiim #165).
|
|
104
|
+
self._eq_band_preset: str | None = None
|
|
105
|
+
self._eq_band_reconcile: bool = False
|
|
106
|
+
|
|
101
107
|
# Track when EQ preset was set (for preserving optimistic updates during refresh)
|
|
102
108
|
# Device status endpoint returns stale EQ data; we preserve the optimistic update for a few seconds
|
|
103
109
|
self._last_eq_preset_set_time: float = 0
|
|
@@ -152,6 +158,10 @@ class PlayerBase:
|
|
|
152
158
|
self._room_correction_enabled: bool = False
|
|
153
159
|
self._room_correction_name: str = ""
|
|
154
160
|
self._last_room_correction_check: float = 0
|
|
161
|
+
self._peq_presets: list[str] | None = None
|
|
162
|
+
self._peq_preset: str | None = None
|
|
163
|
+
self._last_peq_state_check: float = 0
|
|
164
|
+
self._peq_lock = asyncio.Lock()
|
|
155
165
|
|
|
156
166
|
# UPnP health tracking (only if UPnP client is provided)
|
|
157
167
|
self._upnp_health_tracker: UpnpHealthTracker | None = None
|
|
@@ -923,7 +923,10 @@ class PlayerProperties:
|
|
|
923
923
|
|
|
924
924
|
@property
|
|
925
925
|
def eq_preset(self) -> str | None:
|
|
926
|
-
"""Current EQ preset
|
|
926
|
+
"""Current EQ preset, or "Off" if EQ is disabled.
|
|
927
|
+
|
|
928
|
+
The name comes from EQGetBand once that read has succeeded. A later
|
|
929
|
+
getPlayerStatus ``eq`` value does not replace it.
|
|
927
930
|
|
|
928
931
|
Returns:
|
|
929
932
|
- "Off" if EQ is disabled (bypassed)
|
|
@@ -34,6 +34,15 @@ if TYPE_CHECKING:
|
|
|
34
34
|
from . import Player
|
|
35
35
|
|
|
36
36
|
_LOGGER = logging.getLogger(__name__)
|
|
37
|
+
_EQ_PRESET_PRESERVATION_SECONDS = 60.0
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _eq_names_match(left: str | None, right: str | None) -> bool:
|
|
41
|
+
"""Return True when two EQ preset names are the same, ignoring case."""
|
|
42
|
+
if left is None or right is None:
|
|
43
|
+
return left is None and right is None
|
|
44
|
+
return left.casefold() == right.casefold()
|
|
45
|
+
|
|
37
46
|
|
|
38
47
|
_PlayerPlayState = Literal["play", "pause", "stop", "idle", "buffering"]
|
|
39
48
|
_PLAYER_PLAY_STATES: frozenset[str] = frozenset({"play", "pause", "stop", "idle", "buffering"})
|
|
@@ -100,6 +109,8 @@ class StateManager:
|
|
|
100
109
|
|
|
101
110
|
# Track last EQ preset to detect changes (trigger full EQ info fetch)
|
|
102
111
|
self._last_eq_preset: str | None = None
|
|
112
|
+
# Last raw getPlayerStatus eq, before a preserved name replaces it.
|
|
113
|
+
self._last_status_eq_preset: str | None = None
|
|
103
114
|
|
|
104
115
|
# Track last source to detect source changes (for audio output fetching)
|
|
105
116
|
self._last_source: str | None = None
|
|
@@ -363,6 +374,50 @@ class StateManager:
|
|
|
363
374
|
except Exception as err:
|
|
364
375
|
self._handle_refresh_error(err)
|
|
365
376
|
|
|
377
|
+
def _eq_preset_to_keep(self, polled: str | None) -> str | None:
|
|
378
|
+
"""Return the preset name that should replace a stale status poll.
|
|
379
|
+
|
|
380
|
+
``EQGetBand`` ``Name`` wins over ``getPlayerStatus`` ``eq``. Until that
|
|
381
|
+
read exists, a preset set in the last minute is kept.
|
|
382
|
+
"""
|
|
383
|
+
band = self.player._eq_band_preset
|
|
384
|
+
if band:
|
|
385
|
+
if not _eq_names_match(polled, band):
|
|
386
|
+
# A new status value gets one EQGetBand check. A value that is
|
|
387
|
+
# already known to be stale does not.
|
|
388
|
+
seen = self._last_status_eq_preset
|
|
389
|
+
if seen is not None and not _eq_names_match(polled, seen):
|
|
390
|
+
self.player._eq_band_reconcile = True
|
|
391
|
+
return band
|
|
392
|
+
return None
|
|
393
|
+
|
|
394
|
+
model = self.player._status_model
|
|
395
|
+
set_at = self.player._last_eq_preset_set_time
|
|
396
|
+
if (
|
|
397
|
+
model is not None
|
|
398
|
+
and model.eq_preset
|
|
399
|
+
and set_at > 0
|
|
400
|
+
and (time.time() - set_at) < _EQ_PRESET_PRESERVATION_SECONDS
|
|
401
|
+
):
|
|
402
|
+
return str(model.eq_preset)
|
|
403
|
+
return None
|
|
404
|
+
|
|
405
|
+
def _remember_eq_band(self, eq_data: dict[str, Any] | None) -> None:
|
|
406
|
+
"""Store EQGetBand enabled state and preset name."""
|
|
407
|
+
if not isinstance(eq_data, dict):
|
|
408
|
+
return
|
|
409
|
+
if "EQStat" in eq_data:
|
|
410
|
+
self.player._eq_enabled = str(eq_data["EQStat"]).lower() == "on"
|
|
411
|
+
name = eq_data.get("Name")
|
|
412
|
+
if name is None:
|
|
413
|
+
name = eq_data.get("name")
|
|
414
|
+
if isinstance(name, str) and name.strip():
|
|
415
|
+
self.player._eq_band_preset = name.strip()
|
|
416
|
+
if self.player._status_model is not None and self.player._eq_enabled is not False:
|
|
417
|
+
self.player._status_model.eq_preset = self.player._eq_band_preset
|
|
418
|
+
self._last_eq_preset = self.player._eq_band_preset
|
|
419
|
+
_LOGGER.debug("EQ preset from EQGetBand: %s", self.player._eq_band_preset)
|
|
420
|
+
|
|
366
421
|
async def _refresh_core_status(self) -> PlayerStatus:
|
|
367
422
|
"""Fetch core player status and update state synchronizer.
|
|
368
423
|
|
|
@@ -597,20 +652,13 @@ class StateManager:
|
|
|
597
652
|
# Recently set source via set_source() - preserve the optimistic value
|
|
598
653
|
status.source = self.player._status_model.source
|
|
599
654
|
|
|
600
|
-
#
|
|
601
|
-
#
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
and self.player._status_model
|
|
608
|
-
and self.player._status_model.eq_preset
|
|
609
|
-
and self.player._last_eq_preset_set_time > 0
|
|
610
|
-
and (time.time() - self.player._last_eq_preset_set_time) < eq_preservation_window
|
|
611
|
-
):
|
|
612
|
-
# Recently set EQ preset via set_eq_preset() - preserve the optimistic value
|
|
613
|
-
status.eq_preset = self.player._status_model.eq_preset
|
|
655
|
+
# getPlayerStatus eq stays at flat after EQLoad on current firmware (wiim #165).
|
|
656
|
+
# Keep an EQGetBand name, and the short optimistic window before that read exists.
|
|
657
|
+
polled_eq_preset = status.eq_preset if status else None
|
|
658
|
+
kept_eq_preset = self._eq_preset_to_keep(polled_eq_preset) if status else None
|
|
659
|
+
if status is not None and kept_eq_preset is not None:
|
|
660
|
+
status.eq_preset = kept_eq_preset
|
|
661
|
+
self._last_status_eq_preset = polled_eq_preset
|
|
614
662
|
|
|
615
663
|
# Preserve optimistic loop_mode (shuffle/repeat) if it was recently set
|
|
616
664
|
# Device status endpoint may return stale loop_mode data after a change.
|
|
@@ -641,15 +689,9 @@ class StateManager:
|
|
|
641
689
|
# Update synchronizer with preserved optimistic source
|
|
642
690
|
optimistic_updates["source"] = self.player._status_model.source
|
|
643
691
|
|
|
644
|
-
if (
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
and self.player._status_model.eq_preset
|
|
648
|
-
and self.player._last_eq_preset_set_time > 0
|
|
649
|
-
and (time.time() - self.player._last_eq_preset_set_time) < eq_preservation_window
|
|
650
|
-
):
|
|
651
|
-
# Update synchronizer with preserved optimistic EQ preset
|
|
652
|
-
optimistic_updates["eq_preset"] = self.player._status_model.eq_preset
|
|
692
|
+
if kept_eq_preset is not None and not _eq_names_match(polled_eq_preset, kept_eq_preset):
|
|
693
|
+
# Update synchronizer with the EQGetBand or optimistic preset
|
|
694
|
+
optimistic_updates["eq_preset"] = kept_eq_preset
|
|
653
695
|
|
|
654
696
|
if optimistic_updates:
|
|
655
697
|
# Update state synchronizer with preserved optimistic values
|
|
@@ -789,12 +831,17 @@ class StateManager:
|
|
|
789
831
|
|
|
790
832
|
# Detect EQ preset change (trigger full EQ info fetch)
|
|
791
833
|
current_eq_preset = status.eq_preset if status else None
|
|
792
|
-
eq_preset_changed = self._last_eq_preset is not None and
|
|
834
|
+
eq_preset_changed = self._last_eq_preset is not None and not _eq_names_match(
|
|
835
|
+
current_eq_preset, self._last_eq_preset
|
|
836
|
+
)
|
|
793
837
|
# Initialize on first run (don't trigger fetch on first detection)
|
|
794
838
|
if self._last_eq_preset is None:
|
|
795
839
|
self._last_eq_preset = current_eq_preset
|
|
796
840
|
elif eq_preset_changed:
|
|
797
841
|
self._last_eq_preset = current_eq_preset
|
|
842
|
+
# Ask the periodic EQGetBand read to confirm this poll. One fetch per cycle.
|
|
843
|
+
if self.player.client.capabilities.get("supports_eq", False):
|
|
844
|
+
self.player._eq_band_reconcile = True
|
|
798
845
|
|
|
799
846
|
# Detect source change (trigger audio output fetch)
|
|
800
847
|
current_source = status.source if status else None
|
|
@@ -883,17 +930,6 @@ class StateManager:
|
|
|
883
930
|
_LOGGER.debug("Failed to fetch metadata for %s: %s", self.player.host, err)
|
|
884
931
|
self.player._metadata = None
|
|
885
932
|
|
|
886
|
-
# EQ Info - Fetch full EQ state when preset changes
|
|
887
|
-
# When EQ preset changes in status, fetch full EQ info (band values, enabled status)
|
|
888
|
-
if eq_preset_changed and self.player.client.capabilities.get("supports_eq", False):
|
|
889
|
-
try:
|
|
890
|
-
_ = (
|
|
891
|
-
await self.player.client.get_eq()
|
|
892
|
-
) # Fetch EQ data (currently not cached, but available for callbacks)
|
|
893
|
-
_LOGGER.debug("EQ preset changed to %s, fetched full EQ info", current_eq_preset)
|
|
894
|
-
except Exception as err:
|
|
895
|
-
_LOGGER.debug("Failed to fetch EQ info after preset change for %s: %s", self.player.host, err)
|
|
896
|
-
|
|
897
933
|
async def _refresh_periodic_data(self, full: bool, status: PlayerStatus, track_changed: bool) -> None:
|
|
898
934
|
"""Refresh periodic data (audio output, EQ presets, presets, BT history).
|
|
899
935
|
|
|
@@ -995,11 +1031,13 @@ class StateManager:
|
|
|
995
1031
|
_LOGGER.debug("Failed to fetch EQ presets for %s: %s", self.player.host, err)
|
|
996
1032
|
self.player._eq_presets = None
|
|
997
1033
|
|
|
998
|
-
#
|
|
999
|
-
#
|
|
1034
|
+
# EQGetBand - enabled flag and preset name. Same cadence as the preset list,
|
|
1035
|
+
# plus once when getPlayerStatus eq changes, so a real app change is confirmed
|
|
1036
|
+
# without trusting the stale status field.
|
|
1000
1037
|
should_fetch_eq_status = (
|
|
1001
1038
|
full
|
|
1002
1039
|
or track_changed
|
|
1040
|
+
or self.player._eq_band_reconcile
|
|
1003
1041
|
or (
|
|
1004
1042
|
self._polling_strategy
|
|
1005
1043
|
and self._polling_strategy.should_fetch_eq_info(
|
|
@@ -1007,14 +1045,17 @@ class StateManager:
|
|
|
1007
1045
|
)
|
|
1008
1046
|
)
|
|
1009
1047
|
)
|
|
1010
|
-
if
|
|
1048
|
+
if not eq_supported:
|
|
1049
|
+
self.player._eq_band_reconcile = False
|
|
1050
|
+
elif should_fetch_eq_status:
|
|
1011
1051
|
try:
|
|
1012
|
-
|
|
1013
|
-
self.player._eq_enabled = eq_enabled
|
|
1052
|
+
self._remember_eq_band(await self.player.client.get_eq())
|
|
1014
1053
|
self.player._last_eq_status_check = now
|
|
1015
1054
|
except Exception as err:
|
|
1016
1055
|
_LOGGER.debug("Failed to fetch EQ status for %s: %s", self.player.host, err)
|
|
1017
|
-
# Don't clear - keep previous
|
|
1056
|
+
# Don't clear enabled/name - keep previous values if fetch fails
|
|
1057
|
+
finally:
|
|
1058
|
+
self.player._eq_band_reconcile = False
|
|
1018
1059
|
|
|
1019
1060
|
# Channel balance (WiiM HTTP getChannelBalance only; no UPnP event path)
|
|
1020
1061
|
cb_supported = self.player.client.capabilities.get("supports_channel_balance", False)
|
|
@@ -1165,6 +1206,18 @@ class StateManager:
|
|
|
1165
1206
|
# RoomFit. The profile list changes in the app, so refresh names and the
|
|
1166
1207
|
# switch together on the same 60s tier. supports_peq is the gate.
|
|
1167
1208
|
peq_supported = bool(self.player.client.capabilities.get("supports_peq", False))
|
|
1209
|
+
should_fetch_peq = full or (
|
|
1210
|
+
self._polling_strategy
|
|
1211
|
+
and self._polling_strategy.should_fetch_led_indicator(
|
|
1212
|
+
self.player._last_peq_state_check, peq_supported, now=now
|
|
1213
|
+
)
|
|
1214
|
+
)
|
|
1215
|
+
if should_fetch_peq and peq_supported and self.player._peq_presets:
|
|
1216
|
+
try:
|
|
1217
|
+
await self.player.refresh_peq_preset()
|
|
1218
|
+
self.player._last_peq_state_check = now
|
|
1219
|
+
except Exception as err:
|
|
1220
|
+
_LOGGER.debug("Failed to fetch PEQ state for %s: %s", self.player.host, err)
|
|
1168
1221
|
should_fetch_room = full or (
|
|
1169
1222
|
self._polling_strategy
|
|
1170
1223
|
and self._polling_strategy.should_fetch_led_indicator(
|
|
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
|
|
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
|