Extract SerialDeviceProvider base class and power off serial devices on shutdown

Create SerialDeviceProvider as the common base for Adalight and AmbiLED
providers, replacing the misleading Adalight→AmbiLED inheritance chain.
Subclasses now only override device_type and create_client(). Also send
explicit black frames to all serial LED devices during server shutdown.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-19 03:04:27 +03:00
parent 45634836b6
commit f83cd81937
5 changed files with 153 additions and 224 deletions

View File

@@ -658,6 +658,14 @@ class ProcessorManager:
for device_id in self._devices:
await self._restore_device_idle_state(device_id)
# Power off serial LED devices before closing connections
for device_id, ds in self._devices.items():
if ds.device_type != "wled":
try:
await self._send_clear_pixels(device_id)
except Exception as e:
logger.error(f"Failed to power off {device_id} on shutdown: {e}")
# Close any cached idle LED clients
for did in list(self._idle_clients):
await self._close_idle_client(did)