Update __main__.py
What this fixes: On boot, if PipeWire/Pulse starts with the sink at ~40%, LVA now pushes the sink volume to match the persisted LVA volume (0.0–1.0). When you move the HA media_player volume slider, LVA now updates: wpctl (PipeWire) if available pactl (PulseAudio / PipeWire-Pulse) if available amixer (ALSA) as a fallback No reboot / alsactl store required — LVA simply re-applies the persisted volume at start.
This commit is contained in:
@@ -24,6 +24,7 @@ from .led_controller import LedController
|
||||
from .mqtt_controller import MqttController
|
||||
from .models import AvailableWakeWord, Preferences, ServerState, WakeWordType
|
||||
from .mpv_player import MpvMediaPlayer
|
||||
from .audio_volume import ensure_output_volume
|
||||
from .satellite import VoiceSatelliteProtocol
|
||||
from .util import get_mac_address, format_mac
|
||||
from .zeroconf import HomeAssistantZeroconf
|
||||
@@ -165,6 +166,21 @@ async def main() -> None:
|
||||
# --- 5. Initialize Media Players ---
|
||||
media_players = _init_media_players(loop, config, preferences)
|
||||
|
||||
# --- 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).
|
||||
try:
|
||||
loop.create_task(
|
||||
ensure_output_volume(
|
||||
volume=preferences.volume_level,
|
||||
output_device=config.audio.output_device,
|
||||
attempts=20,
|
||||
delay_seconds=0.5,
|
||||
)
|
||||
)
|
||||
except Exception:
|
||||
_LOGGER.exception("Failed to schedule output volume sync")
|
||||
|
||||
# --- 6. Create Server State ---
|
||||
state = _create_server_state(
|
||||
config, loop, event_bus, preferences,
|
||||
|
||||
Reference in New Issue
Block a user