finall - lightB is Bresponse ver

This commit is contained in:
2026-11-24 11:45:01 -05:00
parent d7e9409156
commit d828c27c42
3 changed files with 1005 additions and 0 deletions

0
sources/FinalPrompt.md Normal file
View File

View File

@@ -11,12 +11,20 @@ Create a `ColorModeHandler` dataclass/protocol that encapsulates per-mode config
## Suggested 5-Turn Plan
### Turn 1: Define ColorModeHandler and Refactor __init__
Original instructions
- Create `ColorModeHandler` dataclass with fields: `color_mode`, `script_attr`, `template_attr`, `state_attr`, `property_name`, `update_callback`, `validation_fn`, `turn_on_priority`, `script_param_builder`
- In `__init__`, build a list `self._color_mode_handlers` by checking which scripts/templates are configured
- Replace individual `_rgb_script`, `_hs_script`, etc. with handler-based lookup
- Compute `supported_color_modes` from handlers dynamically
Actual instructions
We're refactoring the component light.py working to reduce the duplication. Create `ColorModeHandler` data class (a DTO) with fields like: color_mode, script_attr, state_attr, property_name and others you deem needed.
In `__init__` create a list of color_mode handlers by checking which scripts or template are configured.
Replace `_rgb_script`, `hs_script`, etc. with handler-based lookups.
Finally, compute `supported_color_modes` from the handlers dynamically.
### Turn 2: Refactor _async_setup_templates
This is effectively complete - do not implement
- Replace 8 separate `if self._xxx_template:` blocks with a loop over `self._color_mode_handlers`
- Each handler registers its template with `add_template_attribute` using its update callback
- Handle special cases (min/max mireds, transition, effect_list) separately or as additional handlers