Updated Celebrations and Silent Dying on Critical/Warning

This commit is contained in:
2026-02-06 11:09:58 -06:00
parent 94f29bf4f4
commit 2c918565de
2 changed files with 45 additions and 42 deletions

View File

@@ -118,7 +118,7 @@ def get_current_state():
sound = top_event["sound"]
# Check for recovery (was bad, now optimal)
if priority == 4 and previous_priority < 4:
if priority == 4 and previous_priority < 3:
celebrating_until = now + CELEBRATION_DURATION
previous_priority = priority
@@ -171,20 +171,23 @@ def write_status():
def cleanup_expired_events():
"""Background thread to remove expired TTL events."""
while True:
time.sleep(1)
now = time.time()
expired = []
try:
time.sleep(1)
now = time.time()
expired = []
with events_lock:
for eid, event in active_events.items():
if event.get("ttl") and now > event["ttl"]:
expired.append(eid)
with events_lock:
for eid, event in active_events.items():
if event.get("ttl") and now > event["ttl"]:
expired.append(eid)
for eid in expired:
del active_events[eid]
for eid in expired:
del active_events[eid]
if expired:
write_status()
if expired:
write_status()
except Exception as e:
print(f"[cleanup] Error: {e}")
@app.route("/event", methods=["POST"])