finall - lightB is Bresponse ver
This commit is contained in:
0
sources/FinalPrompt.md
Normal file
0
sources/FinalPrompt.md
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user