Fix peripheral volume_muted state (#403)

Enable updating the `volume_muted` status when muting/unmuting the media player volume, and improve its tracking.
This commit is contained in:
Omar Amin authored and GitHub committed 2026-08-17 20:23:16 +03:00
1 parent e334aa3fb1
commit 8303a96279
12 files changed
+177 -18

No files matched your search

+5
View File
@@ -217,6 +217,7 @@ class ServerState:
_LOGGER.debug("Skipping save - volume unchanged")
return
previous_muted = self.volume == 0.0
self.volume = clamped_volume
self.preferences.volume = clamped_volume
_LOGGER.info("Saving volume %s to %s", clamped_volume, self.preferences_path)
@@ -230,6 +231,10 @@ class ServerState:
api.emit_event_sync(LVAEvent.VOLUME_CHANGED, {"volume": round(clamped_volume, 3)})
new_muted = clamped_volume == 0.0
if previous_muted != new_muted:
api.emit_event_sync(LVAEvent.VOLUME_MUTED, {"muted": new_muted})
def persist_mic_gain(self, gain: float) -> None:
"""Persist the microphone auto gain value."""
gain_int = int(gain)
+2
View File
@@ -278,6 +278,7 @@ class PeripheralAPIServer:
"data": {
"muted": state.muted,
"volume": round(state.volume, 3),
"volume_muted": state.volume == 0.0,
"ha_connected": state.connected,
"last_stt_text": self._last_stt_text,
"last_tts_text": self._last_tts_text,
@@ -659,6 +660,7 @@ class PeripheralAPIServer:
LVAEvent.MEDIA_PLAYER_PLAYING,
LVAEvent.DISCONNECTED,
LVAEvent.PIPELINE_ERROR,
LVAEvent.VOLUME_MUTED,
}
if event in _STATE_EVENTS:
self._current_state = event