Replace auto-start with startup automation, add card colors to dashboard
- Add `startup` automation condition type that activates on server boot, replacing the per-target `auto_start` flag - Remove `auto_start` field from targets, scene snapshots, and all API layers - Remove auto-start UI section and star buttons from dashboard and target cards - Remove `color` field from scene presets (backend, API, modal, frontend) - Add card color support to scene preset cards (color picker + border style) - Show localStorage-backed card colors on all dashboard cards (targets, automations, sync clocks, scene presets) - Fix card color picker updating wrong card when duplicate data attributes exist by using closest() from picker wrapper instead of global querySelector - Add sync clocks step to Sources tab tutorial - Bump SW cache v9 → v10 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,8 @@ class Condition:
|
||||
return MQTTCondition.from_dict(data)
|
||||
if ct == "webhook":
|
||||
return WebhookCondition.from_dict(data)
|
||||
if ct == "startup":
|
||||
return StartupCondition.from_dict(data)
|
||||
raise ValueError(f"Unknown condition type: {ct}")
|
||||
|
||||
|
||||
@@ -177,6 +179,17 @@ class WebhookCondition(Condition):
|
||||
return cls(token=data.get("token", ""))
|
||||
|
||||
|
||||
@dataclass
|
||||
class StartupCondition(Condition):
|
||||
"""Activate when the server starts — stays active while enabled."""
|
||||
|
||||
condition_type: str = "startup"
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict) -> "StartupCondition":
|
||||
return cls()
|
||||
|
||||
|
||||
@dataclass
|
||||
class Automation:
|
||||
"""Automation that activates a scene preset based on conditions."""
|
||||
|
||||
@@ -100,9 +100,9 @@ class KeyColorsPictureTarget(PictureTarget):
|
||||
|
||||
def update_fields(self, *, name=None, device_id=None, picture_source_id=None,
|
||||
settings=None, key_colors_settings=None, description=None,
|
||||
auto_start=None, **_kwargs) -> None:
|
||||
**_kwargs) -> None:
|
||||
"""Apply mutable field updates for KC targets."""
|
||||
super().update_fields(name=name, description=description, auto_start=auto_start)
|
||||
super().update_fields(name=name, description=description)
|
||||
if picture_source_id is not None:
|
||||
self.picture_source_id = picture_source_id
|
||||
if key_colors_settings is not None:
|
||||
@@ -130,7 +130,6 @@ class KeyColorsPictureTarget(PictureTarget):
|
||||
picture_source_id=data.get("picture_source_id", ""),
|
||||
settings=settings,
|
||||
description=data.get("description"),
|
||||
auto_start=data.get("auto_start", False),
|
||||
created_at=datetime.fromisoformat(data.get("created_at", datetime.utcnow().isoformat())),
|
||||
updated_at=datetime.fromisoformat(data.get("updated_at", datetime.utcnow().isoformat())),
|
||||
)
|
||||
|
||||
@@ -15,7 +15,6 @@ class PictureTarget:
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
description: Optional[str] = None
|
||||
auto_start: bool = False
|
||||
|
||||
def register_with_manager(self, manager) -> None:
|
||||
"""Register this target with the processor manager. Subclasses override."""
|
||||
@@ -27,14 +26,12 @@ class PictureTarget:
|
||||
|
||||
def update_fields(self, *, name=None, device_id=None, picture_source_id=None,
|
||||
settings=None, key_colors_settings=None, description=None,
|
||||
auto_start=None) -> None:
|
||||
**_kwargs) -> None:
|
||||
"""Apply mutable field updates. Base handles common fields; subclasses handle type-specific ones."""
|
||||
if name is not None:
|
||||
self.name = name
|
||||
if description is not None:
|
||||
self.description = description
|
||||
if auto_start is not None:
|
||||
self.auto_start = auto_start
|
||||
|
||||
@property
|
||||
def has_picture_source(self) -> bool:
|
||||
@@ -48,7 +45,6 @@ class PictureTarget:
|
||||
"name": self.name,
|
||||
"target_type": self.target_type,
|
||||
"description": self.description,
|
||||
"auto_start": self.auto_start,
|
||||
"created_at": self.created_at.isoformat(),
|
||||
"updated_at": self.updated_at.isoformat(),
|
||||
}
|
||||
|
||||
@@ -105,7 +105,6 @@ class PictureTargetStore:
|
||||
key_colors_settings: Optional[KeyColorsSettings] = None,
|
||||
description: Optional[str] = None,
|
||||
picture_source_id: str = "",
|
||||
auto_start: bool = False,
|
||||
) -> PictureTarget:
|
||||
"""Create a new picture target.
|
||||
|
||||
@@ -138,7 +137,6 @@ class PictureTargetStore:
|
||||
adaptive_fps=adaptive_fps,
|
||||
protocol=protocol,
|
||||
description=description,
|
||||
auto_start=auto_start,
|
||||
created_at=now,
|
||||
updated_at=now,
|
||||
)
|
||||
@@ -150,7 +148,6 @@ class PictureTargetStore:
|
||||
picture_source_id=picture_source_id,
|
||||
settings=key_colors_settings or KeyColorsSettings(),
|
||||
description=description,
|
||||
auto_start=auto_start,
|
||||
created_at=now,
|
||||
updated_at=now,
|
||||
)
|
||||
@@ -178,7 +175,6 @@ class PictureTargetStore:
|
||||
protocol: Optional[str] = None,
|
||||
key_colors_settings: Optional[KeyColorsSettings] = None,
|
||||
description: Optional[str] = None,
|
||||
auto_start: Optional[bool] = None,
|
||||
) -> PictureTarget:
|
||||
"""Update a picture target.
|
||||
|
||||
@@ -209,7 +205,6 @@ class PictureTargetStore:
|
||||
protocol=protocol,
|
||||
key_colors_settings=key_colors_settings,
|
||||
description=description,
|
||||
auto_start=auto_start,
|
||||
)
|
||||
|
||||
target.updated_at = datetime.utcnow()
|
||||
|
||||
@@ -14,7 +14,6 @@ class TargetSnapshot:
|
||||
color_strip_source_id: str = ""
|
||||
brightness_value_source_id: str = ""
|
||||
fps: int = 30
|
||||
auto_start: bool = False
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
return {
|
||||
@@ -23,7 +22,6 @@ class TargetSnapshot:
|
||||
"color_strip_source_id": self.color_strip_source_id,
|
||||
"brightness_value_source_id": self.brightness_value_source_id,
|
||||
"fps": self.fps,
|
||||
"auto_start": self.auto_start,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
@@ -34,7 +32,6 @@ class TargetSnapshot:
|
||||
color_strip_source_id=data.get("color_strip_source_id", ""),
|
||||
brightness_value_source_id=data.get("brightness_value_source_id", ""),
|
||||
fps=data.get("fps", 30),
|
||||
auto_start=data.get("auto_start", False),
|
||||
)
|
||||
|
||||
|
||||
@@ -45,7 +42,6 @@ class ScenePreset:
|
||||
id: str
|
||||
name: str
|
||||
description: str = ""
|
||||
color: str = "#4fc3f7" # accent color for the card
|
||||
targets: List[TargetSnapshot] = field(default_factory=list)
|
||||
order: int = 0
|
||||
created_at: datetime = field(default_factory=datetime.utcnow)
|
||||
@@ -56,7 +52,6 @@ class ScenePreset:
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"description": self.description,
|
||||
"color": self.color,
|
||||
"targets": [t.to_dict() for t in self.targets],
|
||||
"order": self.order,
|
||||
"created_at": self.created_at.isoformat(),
|
||||
@@ -69,7 +64,6 @@ class ScenePreset:
|
||||
id=data["id"],
|
||||
name=data["name"],
|
||||
description=data.get("description", ""),
|
||||
color=data.get("color", "#4fc3f7"),
|
||||
targets=[TargetSnapshot.from_dict(t) for t in data.get("targets", [])],
|
||||
order=data.get("order", 0),
|
||||
created_at=datetime.fromisoformat(data.get("created_at", datetime.utcnow().isoformat())),
|
||||
|
||||
@@ -83,7 +83,6 @@ class ScenePresetStore:
|
||||
preset_id: str,
|
||||
name: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
color: Optional[str] = None,
|
||||
order: Optional[int] = None,
|
||||
) -> ScenePreset:
|
||||
if preset_id not in self._presets:
|
||||
@@ -98,8 +97,6 @@ class ScenePresetStore:
|
||||
preset.name = name
|
||||
if description is not None:
|
||||
preset.description = description
|
||||
if color is not None:
|
||||
preset.color = color
|
||||
if order is not None:
|
||||
preset.order = order
|
||||
|
||||
|
||||
@@ -63,9 +63,9 @@ class WledPictureTarget(PictureTarget):
|
||||
brightness_value_source_id=None,
|
||||
fps=None, keepalive_interval=None, state_check_interval=None,
|
||||
min_brightness_threshold=None, adaptive_fps=None, protocol=None,
|
||||
description=None, auto_start=None, **_kwargs) -> None:
|
||||
description=None, **_kwargs) -> None:
|
||||
"""Apply mutable field updates for WLED targets."""
|
||||
super().update_fields(name=name, description=description, auto_start=auto_start)
|
||||
super().update_fields(name=name, description=description)
|
||||
if device_id is not None:
|
||||
self.device_id = device_id
|
||||
if color_strip_source_id is not None:
|
||||
@@ -120,7 +120,6 @@ class WledPictureTarget(PictureTarget):
|
||||
adaptive_fps=data.get("adaptive_fps", False),
|
||||
protocol=data.get("protocol", "ddp"),
|
||||
description=data.get("description"),
|
||||
auto_start=data.get("auto_start", False),
|
||||
created_at=datetime.fromisoformat(data.get("created_at", datetime.utcnow().isoformat())),
|
||||
updated_at=datetime.fromisoformat(data.get("updated_at", datetime.utcnow().isoformat())),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user