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:
@@ -12,6 +12,7 @@ from wled_controller.core.devices.led_client import (
|
||||
get_provider,
|
||||
)
|
||||
from wled_controller.api.dependencies import (
|
||||
fire_entity_event,
|
||||
get_device_store,
|
||||
get_output_target_store,
|
||||
get_processor_manager,
|
||||
@@ -146,6 +147,7 @@ async def create_device(
|
||||
zone_mode=device.zone_mode,
|
||||
)
|
||||
|
||||
fire_entity_event("device", "created", device.id)
|
||||
return _device_to_response(device)
|
||||
|
||||
except HTTPException:
|
||||
@@ -332,6 +334,7 @@ async def update_device(
|
||||
if update_data.zone_mode is not None:
|
||||
ds.zone_mode = update_data.zone_mode
|
||||
|
||||
fire_entity_event("device", "updated", device_id)
|
||||
return _device_to_response(device)
|
||||
|
||||
except ValueError as e:
|
||||
@@ -369,6 +372,7 @@ async def delete_device(
|
||||
# Delete from storage
|
||||
store.delete_device(device_id)
|
||||
|
||||
fire_entity_event("device", "deleted", device_id)
|
||||
logger.info(f"Deleted device {device_id}")
|
||||
|
||||
except HTTPException:
|
||||
|
||||
Reference in New Issue
Block a user