Update models.py
ServerState is now a pure data container, no longer holding controller instances. The satellite reference was re-added, as it's required by the audio thread to call satellite.wakeup(). Fixed a TypeError by re-ordering non-default fields.
This commit is contained in:
@@ -67,24 +67,25 @@ class Preferences:
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ServerState:
|
class ServerState:
|
||||||
|
"""A simple dataclass to hold core application state."""
|
||||||
# --- Fields WITHOUT default values ---
|
# --- Fields WITHOUT default values ---
|
||||||
name: str
|
name: str
|
||||||
mac_address: str
|
mac_address: str
|
||||||
|
event_bus: EventBus
|
||||||
|
loop: asyncio.AbstractEventLoop
|
||||||
entities: "List[ESPHomeEntity]"
|
entities: "List[ESPHomeEntity]"
|
||||||
|
music_player: "MpvMediaPlayer"
|
||||||
|
tts_player: "MpvMediaPlayer"
|
||||||
available_wake_words: "Dict[str, AvailableWakeWord]"
|
available_wake_words: "Dict[str, AvailableWakeWord]"
|
||||||
wake_words: "Dict[str, Union[MicroWakeWord, OpenWakeWord]]"
|
wake_words: "Dict[str, Union[MicroWakeWord, OpenWakeWord]]"
|
||||||
active_wake_words: Set[str]
|
active_wake_words: Set[str]
|
||||||
stop_word: "MicroWakeWord"
|
stop_word: "MicroWakeWord"
|
||||||
music_player: "MpvMediaPlayer"
|
|
||||||
tts_player: "MpvMediaPlayer"
|
|
||||||
wakeup_sound: str
|
wakeup_sound: str
|
||||||
timer_finished_sound: str
|
timer_finished_sound: str
|
||||||
preferences: Preferences
|
|
||||||
preferences_path: Path
|
preferences_path: Path
|
||||||
event_bus: EventBus
|
download_dir: Path
|
||||||
loop: asyncio.AbstractEventLoop
|
preferences: Preferences # <-- MOVED UP
|
||||||
download_dir: Path # <-- ADDED
|
|
||||||
|
|
||||||
# --- Fields WITH default values ---
|
# --- Fields WITH default values ---
|
||||||
satellite: "Optional[VoiceSatelliteProtocol]" = None
|
satellite: "Optional[VoiceSatelliteProtocol]" = None
|
||||||
wake_words_changed: bool = False
|
wake_words_changed: bool = False
|
||||||
|
|||||||
Reference in New Issue
Block a user