Remove led_count from static, gradient, color_cycle, and effect CSS sources
These types always auto-size from the connected device — the explicit led_count override was unused clutter. Streams now use getattr fallback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -134,7 +134,6 @@ class ColorStripSource:
|
||||
id=sid, name=name, source_type="static",
|
||||
created_at=created_at, updated_at=updated_at, description=description,
|
||||
clock_id=clock_id, color=color,
|
||||
led_count=data.get("led_count") or 0,
|
||||
animation=data.get("animation"),
|
||||
)
|
||||
|
||||
@@ -145,7 +144,6 @@ class ColorStripSource:
|
||||
id=sid, name=name, source_type="gradient",
|
||||
created_at=created_at, updated_at=updated_at, description=description,
|
||||
clock_id=clock_id, stops=stops,
|
||||
led_count=data.get("led_count") or 0,
|
||||
animation=data.get("animation"),
|
||||
)
|
||||
|
||||
@@ -156,7 +154,6 @@ class ColorStripSource:
|
||||
id=sid, name=name, source_type="color_cycle",
|
||||
created_at=created_at, updated_at=updated_at, description=description,
|
||||
clock_id=clock_id, colors=colors,
|
||||
led_count=data.get("led_count") or 0,
|
||||
)
|
||||
|
||||
if source_type == "composite":
|
||||
@@ -204,7 +201,6 @@ class ColorStripSource:
|
||||
id=sid, name=name, source_type="effect",
|
||||
created_at=created_at, updated_at=updated_at, description=description,
|
||||
clock_id=clock_id, effect_type=data.get("effect_type") or "fire",
|
||||
led_count=data.get("led_count") or 0,
|
||||
palette=data.get("palette") or "fire",
|
||||
color=color,
|
||||
intensity=float(data.get("intensity") or 1.0),
|
||||
@@ -313,13 +309,11 @@ class StaticColorStripSource(ColorStripSource):
|
||||
"""
|
||||
|
||||
color: list = field(default_factory=lambda: [255, 255, 255]) # [R, G, B]
|
||||
led_count: int = 0 # 0 = use device LED count
|
||||
animation: Optional[dict] = None # {"enabled": bool, "type": str, "speed": float} or None
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
d = super().to_dict()
|
||||
d["color"] = list(self.color)
|
||||
d["led_count"] = self.led_count
|
||||
d["animation"] = self.animation
|
||||
return d
|
||||
|
||||
@@ -332,7 +326,7 @@ class GradientColorStripSource(ColorStripSource):
|
||||
Each stop has a primary color; optionally a second "right" color to create
|
||||
a hard discontinuity (bidirectional stop) at that position.
|
||||
|
||||
LED count auto-sizes from the connected device when led_count == 0.
|
||||
LED count auto-sizes from the connected device.
|
||||
"""
|
||||
|
||||
# Each stop: {"position": float, "color": [R,G,B], "color_right": [R,G,B] | null}
|
||||
@@ -340,13 +334,11 @@ class GradientColorStripSource(ColorStripSource):
|
||||
{"position": 0.0, "color": [255, 0, 0]},
|
||||
{"position": 1.0, "color": [0, 0, 255]},
|
||||
])
|
||||
led_count: int = 0 # 0 = use device LED count
|
||||
animation: Optional[dict] = None # {"enabled": bool, "type": str, "speed": float} or None
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
d = super().to_dict()
|
||||
d["stops"] = [dict(s) for s in self.stops]
|
||||
d["led_count"] = self.led_count
|
||||
d["animation"] = self.animation
|
||||
return d
|
||||
|
||||
@@ -357,19 +349,17 @@ class ColorCycleColorStripSource(ColorStripSource):
|
||||
|
||||
All LEDs receive the same solid color at any point in time, smoothly
|
||||
interpolating between the configured color stops in a continuous loop.
|
||||
LED count auto-sizes from the connected device when led_count == 0.
|
||||
LED count auto-sizes from the connected device.
|
||||
"""
|
||||
|
||||
colors: list = field(default_factory=lambda: [
|
||||
[255, 0, 0], [255, 255, 0], [0, 255, 0],
|
||||
[0, 255, 255], [0, 0, 255], [255, 0, 255],
|
||||
])
|
||||
led_count: int = 0 # 0 = use device LED count
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
d = super().to_dict()
|
||||
d["colors"] = [list(c) for c in self.colors]
|
||||
d["led_count"] = self.led_count
|
||||
return d
|
||||
|
||||
|
||||
@@ -379,11 +369,10 @@ class EffectColorStripSource(ColorStripSource):
|
||||
|
||||
The effect_type field selects which algorithm to use:
|
||||
fire, meteor, plasma, noise, aurora.
|
||||
LED count auto-sizes from the connected device when led_count == 0.
|
||||
LED count auto-sizes from the connected device.
|
||||
"""
|
||||
|
||||
effect_type: str = "fire" # fire | meteor | plasma | noise | aurora
|
||||
led_count: int = 0 # 0 = use device LED count
|
||||
palette: str = "fire" # named color palette
|
||||
color: list = field(default_factory=lambda: [255, 80, 0]) # [R,G,B] for meteor head
|
||||
intensity: float = 1.0 # effect-specific intensity (0.1–2.0)
|
||||
@@ -393,7 +382,6 @@ class EffectColorStripSource(ColorStripSource):
|
||||
def to_dict(self) -> dict:
|
||||
d = super().to_dict()
|
||||
d["effect_type"] = self.effect_type
|
||||
d["led_count"] = self.led_count
|
||||
d["palette"] = self.palette
|
||||
d["color"] = list(self.color)
|
||||
d["intensity"] = self.intensity
|
||||
|
||||
@@ -155,7 +155,6 @@ class ColorStripStore:
|
||||
description=description,
|
||||
clock_id=clock_id,
|
||||
color=rgb,
|
||||
led_count=led_count,
|
||||
animation=animation,
|
||||
)
|
||||
elif source_type == "gradient":
|
||||
@@ -171,7 +170,6 @@ class ColorStripStore:
|
||||
{"position": 0.0, "color": [255, 0, 0]},
|
||||
{"position": 1.0, "color": [0, 0, 255]},
|
||||
],
|
||||
led_count=led_count,
|
||||
animation=animation,
|
||||
)
|
||||
elif source_type == "color_cycle":
|
||||
@@ -188,7 +186,6 @@ class ColorStripStore:
|
||||
description=description,
|
||||
clock_id=clock_id,
|
||||
colors=colors if isinstance(colors, list) and len(colors) >= 2 else default_colors,
|
||||
led_count=led_count,
|
||||
)
|
||||
elif source_type == "effect":
|
||||
rgb = color if isinstance(color, list) and len(color) == 3 else [255, 80, 0]
|
||||
@@ -201,7 +198,6 @@ class ColorStripStore:
|
||||
description=description,
|
||||
clock_id=clock_id,
|
||||
effect_type=effect_type or "fire",
|
||||
led_count=led_count,
|
||||
palette=palette or "fire",
|
||||
color=rgb,
|
||||
intensity=float(intensity) if intensity else 1.0,
|
||||
@@ -402,27 +398,19 @@ class ColorStripStore:
|
||||
if color is not None:
|
||||
if isinstance(color, list) and len(color) == 3:
|
||||
source.color = color
|
||||
if led_count is not None:
|
||||
source.led_count = led_count
|
||||
if animation is not None:
|
||||
source.animation = animation
|
||||
elif isinstance(source, GradientColorStripSource):
|
||||
if stops is not None and isinstance(stops, list):
|
||||
source.stops = stops
|
||||
if led_count is not None:
|
||||
source.led_count = led_count
|
||||
if animation is not None:
|
||||
source.animation = animation
|
||||
elif isinstance(source, ColorCycleColorStripSource):
|
||||
if colors is not None and isinstance(colors, list) and len(colors) >= 2:
|
||||
source.colors = colors
|
||||
if led_count is not None:
|
||||
source.led_count = led_count
|
||||
elif isinstance(source, EffectColorStripSource):
|
||||
if effect_type is not None:
|
||||
source.effect_type = effect_type
|
||||
if led_count is not None:
|
||||
source.led_count = led_count
|
||||
if palette is not None:
|
||||
source.palette = palette
|
||||
if color is not None and isinstance(color, list) and len(color) == 3:
|
||||
|
||||
Reference in New Issue
Block a user