Add LED skip start/end, rename standby_interval to keepalive_interval, remove migrations
LED skip: set first N and last M LEDs to black on a target. Color sources (static, gradient, effect, color cycle) render across only the active (non-skipped) LEDs. Processor pads with blacks before sending to device. Rename standby_interval → keepalive_interval across all Python, API schemas, and JS. from_dict falls back to old key for existing configs. Remove legacy migration functions (_migrate_devices_to_targets, _migrate_targets_to_color_strips) and legacy fields from target model. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -91,9 +91,7 @@ class KeyColorsPictureTarget(PictureTarget):
|
||||
|
||||
def update_fields(self, *, name=None, device_id=None, picture_source_id=None,
|
||||
settings=None, key_colors_settings=None, description=None,
|
||||
# WledPictureTarget-specific params — accepted but ignored:
|
||||
color_strip_source_id=None, standby_interval=None,
|
||||
state_check_interval=None) -> None:
|
||||
**_kwargs) -> None:
|
||||
"""Apply mutable field updates for KC targets."""
|
||||
super().update_fields(name=name, description=description)
|
||||
if picture_source_id is not None:
|
||||
|
||||
@@ -103,8 +103,10 @@ class PictureTargetStore:
|
||||
device_id: str = "",
|
||||
color_strip_source_id: str = "",
|
||||
fps: int = 30,
|
||||
standby_interval: float = 1.0,
|
||||
keepalive_interval: float = 1.0,
|
||||
state_check_interval: int = DEFAULT_STATE_CHECK_INTERVAL,
|
||||
led_skip_start: int = 0,
|
||||
led_skip_end: int = 0,
|
||||
key_colors_settings: Optional[KeyColorsSettings] = None,
|
||||
description: Optional[str] = None,
|
||||
# Legacy params — accepted but ignored for backward compat
|
||||
@@ -118,7 +120,7 @@ class PictureTargetStore:
|
||||
target_type: Target type ("led", "wled", "key_colors")
|
||||
device_id: WLED device ID (for led targets)
|
||||
color_strip_source_id: Color strip source ID (for led targets)
|
||||
standby_interval: Keepalive interval in seconds (for led targets)
|
||||
keepalive_interval: Keepalive interval in seconds (for led targets)
|
||||
state_check_interval: State check interval in seconds (for led targets)
|
||||
key_colors_settings: Key colors settings (for key_colors targets)
|
||||
description: Optional description
|
||||
@@ -148,8 +150,10 @@ class PictureTargetStore:
|
||||
device_id=device_id,
|
||||
color_strip_source_id=color_strip_source_id,
|
||||
fps=fps,
|
||||
standby_interval=standby_interval,
|
||||
keepalive_interval=keepalive_interval,
|
||||
state_check_interval=state_check_interval,
|
||||
led_skip_start=led_skip_start,
|
||||
led_skip_end=led_skip_end,
|
||||
description=description,
|
||||
created_at=now,
|
||||
updated_at=now,
|
||||
@@ -181,8 +185,10 @@ class PictureTargetStore:
|
||||
device_id: Optional[str] = None,
|
||||
color_strip_source_id: Optional[str] = None,
|
||||
fps: Optional[int] = None,
|
||||
standby_interval: Optional[float] = None,
|
||||
keepalive_interval: Optional[float] = None,
|
||||
state_check_interval: Optional[int] = None,
|
||||
led_skip_start: Optional[int] = None,
|
||||
led_skip_end: Optional[int] = None,
|
||||
key_colors_settings: Optional[KeyColorsSettings] = None,
|
||||
description: Optional[str] = None,
|
||||
# Legacy params — accepted but ignored
|
||||
@@ -210,8 +216,10 @@ class PictureTargetStore:
|
||||
device_id=device_id,
|
||||
color_strip_source_id=color_strip_source_id,
|
||||
fps=fps,
|
||||
standby_interval=standby_interval,
|
||||
keepalive_interval=keepalive_interval,
|
||||
state_check_interval=state_check_interval,
|
||||
led_skip_start=led_skip_start,
|
||||
led_skip_end=led_skip_end,
|
||||
key_colors_settings=key_colors_settings,
|
||||
description=description,
|
||||
)
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
"""LED picture target — sends a color strip source to an LED device."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from wled_controller.storage.picture_target import PictureTarget
|
||||
|
||||
@@ -20,12 +19,10 @@ class WledPictureTarget(PictureTarget):
|
||||
device_id: str = ""
|
||||
color_strip_source_id: str = ""
|
||||
fps: int = 30 # target send FPS (1-90)
|
||||
standby_interval: float = 1.0 # seconds between keepalive sends when screen is static
|
||||
keepalive_interval: float = 1.0 # seconds between keepalive sends when screen is static
|
||||
state_check_interval: int = DEFAULT_STATE_CHECK_INTERVAL
|
||||
|
||||
# Legacy fields — populated from old JSON data during migration; not written back
|
||||
_legacy_picture_source_id: str = field(default="", repr=False, compare=False)
|
||||
_legacy_settings: Optional[dict] = field(default=None, repr=False, compare=False)
|
||||
led_skip_start: int = 0 # first N LEDs forced to black
|
||||
led_skip_end: int = 0 # last M LEDs forced to black
|
||||
|
||||
def register_with_manager(self, manager) -> None:
|
||||
"""Register this WLED target with the processor manager."""
|
||||
@@ -35,8 +32,10 @@ class WledPictureTarget(PictureTarget):
|
||||
device_id=self.device_id,
|
||||
color_strip_source_id=self.color_strip_source_id,
|
||||
fps=self.fps,
|
||||
standby_interval=self.standby_interval,
|
||||
keepalive_interval=self.keepalive_interval,
|
||||
state_check_interval=self.state_check_interval,
|
||||
led_skip_start=self.led_skip_start,
|
||||
led_skip_end=self.led_skip_end,
|
||||
)
|
||||
|
||||
def sync_with_manager(self, manager, *, settings_changed: bool, source_changed: bool, device_changed: bool) -> None:
|
||||
@@ -44,8 +43,10 @@ class WledPictureTarget(PictureTarget):
|
||||
if settings_changed:
|
||||
manager.update_target_settings(self.id, {
|
||||
"fps": self.fps,
|
||||
"standby_interval": self.standby_interval,
|
||||
"keepalive_interval": self.keepalive_interval,
|
||||
"state_check_interval": self.state_check_interval,
|
||||
"led_skip_start": self.led_skip_start,
|
||||
"led_skip_end": self.led_skip_end,
|
||||
})
|
||||
if source_changed:
|
||||
manager.update_target_color_strip_source(self.id, self.color_strip_source_id)
|
||||
@@ -53,10 +54,9 @@ class WledPictureTarget(PictureTarget):
|
||||
manager.update_target_device(self.id, self.device_id)
|
||||
|
||||
def update_fields(self, *, name=None, device_id=None, color_strip_source_id=None,
|
||||
fps=None, standby_interval=None, state_check_interval=None,
|
||||
# Legacy params accepted but ignored to keep base class compat:
|
||||
picture_source_id=None, settings=None,
|
||||
key_colors_settings=None, description=None) -> None:
|
||||
fps=None, keepalive_interval=None, state_check_interval=None,
|
||||
led_skip_start=None, led_skip_end=None,
|
||||
description=None, **_kwargs) -> None:
|
||||
"""Apply mutable field updates for WLED targets."""
|
||||
super().update_fields(name=name, description=description)
|
||||
if device_id is not None:
|
||||
@@ -65,10 +65,14 @@ class WledPictureTarget(PictureTarget):
|
||||
self.color_strip_source_id = color_strip_source_id
|
||||
if fps is not None:
|
||||
self.fps = fps
|
||||
if standby_interval is not None:
|
||||
self.standby_interval = standby_interval
|
||||
if keepalive_interval is not None:
|
||||
self.keepalive_interval = keepalive_interval
|
||||
if state_check_interval is not None:
|
||||
self.state_check_interval = state_check_interval
|
||||
if led_skip_start is not None:
|
||||
self.led_skip_start = led_skip_start
|
||||
if led_skip_end is not None:
|
||||
self.led_skip_end = led_skip_end
|
||||
|
||||
@property
|
||||
def has_picture_source(self) -> bool:
|
||||
@@ -80,31 +84,27 @@ class WledPictureTarget(PictureTarget):
|
||||
d["device_id"] = self.device_id
|
||||
d["color_strip_source_id"] = self.color_strip_source_id
|
||||
d["fps"] = self.fps
|
||||
d["standby_interval"] = self.standby_interval
|
||||
d["keepalive_interval"] = self.keepalive_interval
|
||||
d["state_check_interval"] = self.state_check_interval
|
||||
d["led_skip_start"] = self.led_skip_start
|
||||
d["led_skip_end"] = self.led_skip_end
|
||||
return d
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict) -> "WledPictureTarget":
|
||||
"""Create from dictionary. Reads legacy picture_source_id/settings for migration."""
|
||||
obj = cls(
|
||||
"""Create from dictionary."""
|
||||
return cls(
|
||||
id=data["id"],
|
||||
name=data["name"],
|
||||
target_type="led",
|
||||
device_id=data.get("device_id", ""),
|
||||
color_strip_source_id=data.get("color_strip_source_id", ""),
|
||||
fps=data.get("fps", 30),
|
||||
standby_interval=data.get("standby_interval", 1.0),
|
||||
keepalive_interval=data.get("keepalive_interval", data.get("standby_interval", 1.0)),
|
||||
state_check_interval=data.get("state_check_interval", DEFAULT_STATE_CHECK_INTERVAL),
|
||||
led_skip_start=data.get("led_skip_start", 0),
|
||||
led_skip_end=data.get("led_skip_end", 0),
|
||||
description=data.get("description"),
|
||||
created_at=datetime.fromisoformat(data.get("created_at", datetime.utcnow().isoformat())),
|
||||
updated_at=datetime.fromisoformat(data.get("updated_at", datetime.utcnow().isoformat())),
|
||||
)
|
||||
|
||||
# Preserve legacy fields for migration — never written back by to_dict()
|
||||
obj._legacy_picture_source_id = data.get("picture_source_id", "")
|
||||
settings_data = data.get("settings", {})
|
||||
if settings_data:
|
||||
obj._legacy_settings = settings_data
|
||||
|
||||
return obj
|
||||
|
||||
Reference in New Issue
Block a user