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:
2026-03-10 11:09:09 +03:00
parent 1ce25caa35
commit 73562cd525
18 changed files with 169 additions and 10 deletions

View File

@@ -4,6 +4,7 @@ from fastapi import APIRouter, HTTPException, Depends
from wled_controller.api.auth import AuthRequired
from wled_controller.api.dependencies import (
fire_entity_event,
get_pattern_template_store,
get_output_target_store,
)
@@ -73,6 +74,7 @@ async def create_pattern_template(
description=data.description,
tags=data.tags,
)
fire_entity_event("pattern_template", "created", template.id)
return _pat_template_to_response(template)
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
@@ -117,6 +119,7 @@ async def update_pattern_template(
description=data.description,
tags=data.tags,
)
fire_entity_event("pattern_template", "updated", template_id)
return _pat_template_to_response(template)
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
@@ -143,6 +146,7 @@ async def delete_pattern_template(
"Please reassign those targets before deleting.",
)
store.delete_template(template_id)
fire_entity_event("pattern_template", "deleted", template_id)
except HTTPException:
raise
except ValueError as e: