Add entity CRUD events over WebSocket with auto-refresh
Broadcast entity_changed and device_health_changed events via the event bus so the frontend can auto-refresh cards without polling. Adds exponential backoff on WS reconnect. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ from starlette.websockets import WebSocket, WebSocketDisconnect
|
||||
|
||||
from wled_controller.api.auth import AuthRequired
|
||||
from wled_controller.api.dependencies import (
|
||||
fire_entity_event,
|
||||
get_audio_source_store,
|
||||
get_audio_template_store,
|
||||
get_color_strip_store,
|
||||
@@ -84,6 +85,7 @@ async def create_audio_source(
|
||||
audio_template_id=data.audio_template_id,
|
||||
tags=data.tags,
|
||||
)
|
||||
fire_entity_event("audio_source", "created", source.id)
|
||||
return _to_response(source)
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
@@ -123,6 +125,7 @@ async def update_audio_source(
|
||||
audio_template_id=data.audio_template_id,
|
||||
tags=data.tags,
|
||||
)
|
||||
fire_entity_event("audio_source", "updated", source_id)
|
||||
return _to_response(source)
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
@@ -146,6 +149,7 @@ async def delete_audio_source(
|
||||
)
|
||||
|
||||
store.delete_source(source_id)
|
||||
fire_entity_event("audio_source", "deleted", source_id)
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user