Add dynamic brightness value source support for KC targets, fix subtab selector collision

Extend value source brightness modulation to Key Colors targets (matching LED target support).
Also fix stream subtab CSS selector collision that broke target subtab selection, and use 🔢 emoji
for value source UI elements.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-24 12:42:00 +03:00
parent ef474fe275
commit 8f79b77fe4
10 changed files with 131 additions and 13 deletions

View File

@@ -71,6 +71,7 @@ def _kc_settings_to_schema(settings: KeyColorsSettings) -> KeyColorsSettingsSche
smoothing=settings.smoothing,
pattern_template_id=settings.pattern_template_id,
brightness=settings.brightness,
brightness_value_source_id=settings.brightness_value_source_id,
)
@@ -82,6 +83,7 @@ def _kc_schema_to_settings(schema: KeyColorsSettingsSchema) -> KeyColorsSettings
smoothing=schema.smoothing,
pattern_template_id=schema.pattern_template_id,
brightness=schema.brightness,
brightness_value_source_id=schema.brightness_value_source_id,
)
@@ -254,6 +256,7 @@ async def update_target(
smoothing=incoming.get("smoothing", ex.smoothing),
pattern_template_id=incoming.get("pattern_template_id", ex.pattern_template_id),
brightness=incoming.get("brightness", ex.brightness),
brightness_value_source_id=incoming.get("brightness_value_source_id", ex.brightness_value_source_id),
)
kc_settings = _kc_schema_to_settings(merged)
else:
@@ -273,6 +276,13 @@ async def update_target(
description=data.description,
)
# Detect KC brightness VS change (inside key_colors_settings)
kc_brightness_vs_changed = False
if data.key_colors_settings is not None:
kc_incoming = data.key_colors_settings.model_dump(exclude_unset=True)
if "brightness_value_source_id" in kc_incoming:
kc_brightness_vs_changed = True
# Sync processor manager
try:
target.sync_with_manager(
@@ -283,7 +293,7 @@ async def update_target(
data.key_colors_settings is not None),
css_changed=data.color_strip_source_id is not None,
device_changed=data.device_id is not None,
brightness_vs_changed=data.brightness_value_source_id is not None,
brightness_vs_changed=(data.brightness_value_source_id is not None or kc_brightness_vs_changed),
)
except ValueError:
pass