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:
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user