Update __main__.py

Add volume max percentage and config for volume sync.
This commit is contained in:
imonlinux
2026-01-06 13:37:00 -08:00
committed by GitHub
parent 6866358dfe
commit 010e5447df
+4
View File
@@ -169,17 +169,21 @@ async def main() -> None:
# --- 5b. Sync OS sink volume to persisted volume ---
# mpv's per-player volume is kept at 100% and ducking is handled within mpv.
# The user-visible "volume" in HA maps to the OS output volume (PipeWire/Pulse/ALSA).
if getattr(config.audio, "volume_sync", False):
try:
loop.create_task(
ensure_output_volume(
volume=preferences.volume_level,
output_device=config.audio.output_device,
max_volume_percent=getattr(config.audio, "max_volume_percent", 100),
attempts=20,
delay_seconds=0.5,
)
)
except Exception:
_LOGGER.exception("Failed to schedule output volume sync")
else:
_LOGGER.debug("Output volume sync disabled (audio.volume_sync=false)")
# --- 6. Create Server State ---
state = _create_server_state(