From 0f1ceefc5ca678b73b08daf8202c64edec29df51 Mon Sep 17 00:00:00 2001 From: imonlinux <39863321+imonlinux@users.noreply.github.com> Date: Mon, 17 Nov 2025 15:05:35 -0800 Subject: [PATCH] Update models.py Goal: satellite.py currently uses a set of boolean flags (_is_streaming_audio, _tts_played, _run_finished, _is_speaking) to figure out what it's doing. This is hard to read and easy to break. Replaced this with a clean, formal state machine (using an Enum). This makes the logic explicit and much easier to manage. added the SatelliteState Enum at the top and removed the media_player_entity from ServerState as it's better managed by the satellite itself --- linux_voice_assistant/models.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/linux_voice_assistant/models.py b/linux_voice_assistant/models.py index 7e832ef..c8e7608 100644 --- a/linux_voice_assistant/models.py +++ b/linux_voice_assistant/models.py @@ -21,6 +21,15 @@ if TYPE_CHECKING: _LOGGER = logging.getLogger(__name__) +class SatelliteState(str, Enum): + """Voice satellite state.""" + IDLE = "idle" + LISTENING = "listening" # Wake word detected + THINKING = "thinking" # VAD, waiting for STT/intent + RESPONDING = "responding" # Playing TTS + ERROR = "error" + + class WakeWordType(str, Enum): MICRO_WAKE_WORD = "micro" OPEN_WAKE_WORD = "openWakeWord" @@ -60,7 +69,7 @@ class AvailableWakeWord: class Preferences: active_wake_words: List[str] = field(default_factory=list) volume_level: float = 1.0 - num_leds: int = 3 # THIS LINE WAS MISSING + num_leds: int = 3 @dataclass @@ -86,7 +95,6 @@ class ServerState: oww_embedding_path: Path # --- Fields WITH default values --- - media_player_entity: "Optional[MediaPlayerEntity]" = None satellite: "Optional[VoiceSatelliteProtocol]" = None wake_words_changed: bool = False refractory_seconds: float = 2.0