Cache idle LED clients to avoid repeated Arduino resets
Adalight devices trigger a ~3s bootloader reset on every serial connection open. Add a persistent idle client cache in ProcessorManager so calibration test toggles, static color changes, and auto-restore reuse an existing connection instead of creating a new one each time. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -291,7 +291,7 @@ async def delete_device(
|
||||
|
||||
# Remove from manager
|
||||
try:
|
||||
manager.remove_device(device_id)
|
||||
await manager.remove_device(device_id)
|
||||
except (ValueError, RuntimeError):
|
||||
pass
|
||||
|
||||
@@ -497,11 +497,7 @@ async def set_device_color(
|
||||
# If device is idle, apply the color immediately
|
||||
if color is not None and not manager.is_device_processing(device_id):
|
||||
try:
|
||||
provider = get_provider(device.device_type)
|
||||
await provider.set_color(
|
||||
device.url, color,
|
||||
led_count=device.led_count, baud_rate=device.baud_rate,
|
||||
)
|
||||
await manager.send_static_color(device_id, color)
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to apply static color immediately: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user