Add segment name support to the segment() method#2051
Add segment name support to the segment() method#2051mik-laj wants to merge 5 commits intofrenck:mainfrom
Conversation
Adds a `name` parameter to `wled.segment()` allowing callers to set or clear a segment name. Passing `None` (the default) leaves the name unchanged; passing an empty string clears it on the device. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR adds an optional Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2051 +/- ##
===========================================
+ Coverage 58.61% 97.02% +38.41%
===========================================
Files 6 8 +2
Lines 662 1075 +413
Branches 143 112 -31
===========================================
+ Hits 388 1043 +655
+ Misses 270 21 -249
- Partials 4 11 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR extends the WLED client’s segment() API to support setting/clearing a segment name, and strengthens the test suite by refactoring fixtures and asserting the exact outgoing request payloads sent to the WLED API.
Changes:
- Add a
name: str | Noneparameter toWLED.segment()and map it to the WLED JSON field"n"(with""clearing the name andNoneomitting the field). - Refactor tests to use shared
responses,session, andwledfixtures, reducing boilerplate setup. - Add/expand request contract assertions by validating the exact POST payloads (including the auto-added
"v": Trueflag).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/wled/wled.py |
Adds segment(..., name=...) support and includes "n" in the segment payload when provided. |
tests/conftest.py |
Enhances mock_json_and_presets to accept custom fixture data and introduces async session/wled fixtures. |
tests/test_wled.py |
Refactors tests to fixtures and adds a helper to assert POST payloads, including new parametrized coverage for segment naming. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
nameparameter towled.segment()to set or clear the name of a WLED segmentname=None(default) leaves the name unchanged — consistent with all other parameters in this methodname=""(empty string) clears the name on the device — the only way the WLED API supports clearing itNone, and default (omitted)Depends on
Depends on #2050
Test plan
test_segment_name[set]—name="Curtain"sends{"n": "Curtain"}in payloadtest_segment_name[clear_empty_string]—name=""sends{"n": ""}in payloadtest_segment_name[none_explicit]—name=Noneomitsnfrom payloadtest_segment_name[default_omitted]— nonameargument omitsnfrom payloadWLED API behavior (verified on device)
nabsent"n": null"n": """n": "Curtain"🤖 Generated with Claude Code
Summary by CodeRabbit
segment()method now supports an optionalnameparameter for setting segment names. Use an empty string to clear a name, or leave it unspecified to preserve the existing name.