Updated Celebrations and Silent Dying on Critical/Warning
This commit is contained in:
@@ -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,6 +171,7 @@ def write_status():
|
||||
def cleanup_expired_events():
|
||||
"""Background thread to remove expired TTL events."""
|
||||
while True:
|
||||
try:
|
||||
time.sleep(1)
|
||||
now = time.time()
|
||||
expired = []
|
||||
@@ -185,6 +186,8 @@ def cleanup_expired_events():
|
||||
|
||||
if expired:
|
||||
write_status()
|
||||
except Exception as e:
|
||||
print(f"[cleanup] Error: {e}")
|
||||
|
||||
|
||||
@app.route("/event", methods=["POST"])
|
||||
|
||||
60
openapi.yaml
60
openapi.yaml
@@ -19,7 +19,7 @@ info:
|
||||
name: MIT
|
||||
|
||||
servers:
|
||||
- url: http://localhost:5100
|
||||
- url: http://192.168.2.114:5100
|
||||
description: Local development server
|
||||
|
||||
paths:
|
||||
@@ -36,7 +36,7 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/EventRequest'
|
||||
$ref: "#/components/schemas/EventRequest"
|
||||
examples:
|
||||
critical:
|
||||
summary: Critical event
|
||||
@@ -52,18 +52,18 @@ paths:
|
||||
message: "CPU nominal"
|
||||
ttl: 60
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: Event registered successfully
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/EventResponse'
|
||||
'400':
|
||||
$ref: "#/components/schemas/EventResponse"
|
||||
"400":
|
||||
description: Invalid request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
$ref: "#/components/schemas/Error"
|
||||
|
||||
/clear:
|
||||
post:
|
||||
@@ -84,24 +84,24 @@ paths:
|
||||
description: Event identifier to clear
|
||||
example: "disk_root"
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: Event cleared successfully
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ClearResponse'
|
||||
'400':
|
||||
$ref: "#/components/schemas/ClearResponse"
|
||||
"400":
|
||||
description: Missing required field
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'404':
|
||||
$ref: "#/components/schemas/Error"
|
||||
"404":
|
||||
description: Event not found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
$ref: "#/components/schemas/Error"
|
||||
|
||||
/notify:
|
||||
post:
|
||||
@@ -116,7 +116,7 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/NotifyRequest'
|
||||
$ref: "#/components/schemas/NotifyRequest"
|
||||
examples:
|
||||
simple:
|
||||
summary: Simple notification
|
||||
@@ -133,12 +133,12 @@ paths:
|
||||
animation: "celebrating"
|
||||
sound: "chime"
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: Notification sent
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/NotifyResponse'
|
||||
$ref: "#/components/schemas/NotifyResponse"
|
||||
|
||||
/sleep:
|
||||
post:
|
||||
@@ -148,12 +148,12 @@ paths:
|
||||
dimmed colors. All events are preserved but not displayed until wake.
|
||||
operationId: sleep
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: Entered sleep mode
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/SleepResponse'
|
||||
$ref: "#/components/schemas/SleepResponse"
|
||||
|
||||
/wake:
|
||||
post:
|
||||
@@ -161,12 +161,12 @@ paths:
|
||||
description: Wake Kao from sleep mode and resume normal status display.
|
||||
operationId: wake
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: Exited sleep mode
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/WakeResponse'
|
||||
$ref: "#/components/schemas/WakeResponse"
|
||||
|
||||
/status:
|
||||
get:
|
||||
@@ -176,12 +176,12 @@ paths:
|
||||
animation, and list of active events. The frontend polls this endpoint.
|
||||
operationId: getStatus
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: Current status
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Status'
|
||||
$ref: "#/components/schemas/Status"
|
||||
|
||||
/events:
|
||||
get:
|
||||
@@ -189,12 +189,12 @@ paths:
|
||||
description: Returns all currently active events with their full details.
|
||||
operationId: listEvents
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: List of active events
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/EventList'
|
||||
$ref: "#/components/schemas/EventList"
|
||||
|
||||
components:
|
||||
schemas:
|
||||
@@ -231,7 +231,7 @@ components:
|
||||
type: string
|
||||
example: "ok"
|
||||
current_state:
|
||||
$ref: '#/components/schemas/Status'
|
||||
$ref: "#/components/schemas/Status"
|
||||
|
||||
ClearResponse:
|
||||
type: object
|
||||
@@ -240,7 +240,7 @@ components:
|
||||
type: string
|
||||
example: "cleared"
|
||||
current_state:
|
||||
$ref: '#/components/schemas/Status'
|
||||
$ref: "#/components/schemas/Status"
|
||||
|
||||
NotifyRequest:
|
||||
type: object
|
||||
@@ -261,7 +261,7 @@ components:
|
||||
color:
|
||||
type: string
|
||||
description: Custom color in hex format
|
||||
pattern: '^#[0-9A-Fa-f]{6}$'
|
||||
pattern: "^#[0-9A-Fa-f]{6}$"
|
||||
example: "#FF9900"
|
||||
animation:
|
||||
type: string
|
||||
@@ -299,7 +299,7 @@ components:
|
||||
description: Generated event ID
|
||||
example: "ha_notify_1704067200000"
|
||||
current_state:
|
||||
$ref: '#/components/schemas/Status'
|
||||
$ref: "#/components/schemas/Status"
|
||||
|
||||
SleepResponse:
|
||||
type: object
|
||||
@@ -308,7 +308,7 @@ components:
|
||||
type: string
|
||||
example: "sleeping"
|
||||
current_state:
|
||||
$ref: '#/components/schemas/Status'
|
||||
$ref: "#/components/schemas/Status"
|
||||
|
||||
WakeResponse:
|
||||
type: object
|
||||
@@ -317,7 +317,7 @@ components:
|
||||
type: string
|
||||
example: "awake"
|
||||
current_state:
|
||||
$ref: '#/components/schemas/Status'
|
||||
$ref: "#/components/schemas/Status"
|
||||
|
||||
Status:
|
||||
type: object
|
||||
@@ -355,7 +355,7 @@ components:
|
||||
active_events:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/ActiveEvent'
|
||||
$ref: "#/components/schemas/ActiveEvent"
|
||||
last_updated:
|
||||
type: string
|
||||
format: date-time
|
||||
|
||||
Reference in New Issue
Block a user