Update models.py

Updated Preferences dataclass with a new field:

alarm_duration_seconds: int = 0

Kept ServerState.save_preferences() unchanged so alarm_duration_seconds is automatically serialized into preferences.json.
This commit is contained in:
imonlinux
2025-11-29 14:38:13 -08:00
committed by GitHub
parent b43b036198
commit 5da1dd4bc4
+8 -1
View File
@@ -64,6 +64,10 @@ class Preferences:
active_wake_words: List[str] = field(default_factory=list)
volume_level: float = 1.0
num_leds: int = 3
# New: configurable alarm duration in seconds.
# 0 = infinite alarm (only Stop/wake word stops it)
# >0 = auto-stop alarm after this many seconds
alarm_duration_seconds: int = 0
@dataclass
@@ -112,5 +116,8 @@ class ServerState:
self.preferences_path.parent.mkdir(parents=True, exist_ok=True)
with open(self.preferences_path, "w", encoding="utf-8") as preferences_file:
json.dump(
asdict(self.preferences), preferences_file, ensure_ascii=False, indent=4
asdict(self.preferences),
preferences_file,
ensure_ascii=False,
indent=4,
)