Add support for cold white in color mode#50
Conversation
📝 WalkthroughWalkthroughAdds a fifth color channel Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@ttls/cli.py`:
- Line 126: Update the ValueError raised in ttls/cli.py’s colour validation (the
raise ValueError(...) line) to include the newly supported "r,g,b,w,w" format in
the message; change the text so it lists all accepted formats (e.g., "r,g,b",
"r,g,b,w", and "r,g,b,w,w") to make the error clear when colour parsing fails.
aa155a6 to
2772d3f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@ttls/cli.py`:
- Line 126: The ValueError message in ttls/cli.py currently contains a
duplicated word ("format format"); update the raise ValueError call that
produces "Colour argument is not in r,g,b, r,g,b,w or r,g,b,w,cw format format"
to remove the duplicate so it reads "...cw format" (i.e., a single "format") in
the same raise statement.
2772d3f to
3721d74
Compare
jschlyter
left a comment
There was a problem hiding this comment.
No major issues, but please fix some minor nits.
Sure, here you go! |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
ttls/colours.py (1)
10-33:⚠️ Potential issue | 🟠 MajorEnforce
cold_whiterequireswhiteto be set.Right now
cold_whitecan be provided withoutwhite, which makesas_twinkly_tuple/as_tupledrop the channel whileas_dictemits onlycold_white. That violates the PR requirement to specify all channels and can leave warm white stale. Add a validation guard (preferably in__post_init__) to fail fast whencold_whiteis set butwhiteisn’t.💡 Suggested validation guard
`@dataclass`(frozen=True) class TwinklyColour: red: int green: int blue: int white: int | None = None cold_white: int | None = None + def __post_init__(self): + if self.cold_white is not None and self.white is None: + raise ValueError("cold_white requires white to be set")
🧹 Nitpick comments (1)
ttls/colours.py (1)
17-27: Clarify 5‑tuple ordering in docstrings (CW vs W).“(W,W,…)” is ambiguous. Explicitly label cold vs warm ordering to prevent misuse.
✍️ Docstring clarification
- """Convert TwinklyColour to a tuple as used by Twinkly: (R,G,B), (W,R,G,B) or (W,W,R,G,B)""" + """Convert TwinklyColour to a tuple as used by Twinkly: (R,G,B), (W,R,G,B) or (CW,W,R,G,B)""" - """Convert TwinklyColour to a tuple: (R,G,B), (R,G,B,W) or (R,G,B,W,W)""" + """Convert TwinklyColour to a tuple: (R,G,B), (R,G,B,W) or (R,G,B,W,CW)"""
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@ttls/colours.py`:
- Around line 21-25: The docstring and implementation in the TwinklyColour
to-tuple logic incorrectly claim a 5-channel "(CW,W,R,G,B)" format is "as used
by Twinkly"; remove or isolate that branch so only Twinkly-supported tuples are
returned (RGB as (R,G,B) or RGBW as (W,R,G,B)). Specifically, update the method
that checks self.cold_white and self.white (the branch returning
(self.cold_white, self.white, self.red, self.green, self.blue)) to either be
removed or moved into a new non-Twinkly-specific method (e.g.,
to_custom_5_channel) and adjust the docstring to state Twinkly uses only RGB and
RGBW and that any 5-channel output is a custom extension if retained.
The Permanent Lights have a cold white led, this PR adds the support to control that in color mode.
A few notes to consider:
Summary by CodeRabbit
New Features
Tests