Add support for usermod palettes#2058
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR extends the WLED Python library to support usermod palettes, a firmware feature available in version 16.0.0 and later. The changes reorganize the palette ID space, extend the Info model to deserialize usermod metadata (count and optional names), implement a synthesis helper, integrate it into Device deserialization and updates, and add comprehensive test coverage for different firmware versions and edge cases. ChangesUsermod Palette Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
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. Comment |
There was a problem hiding this comment.
Pull request overview
This PR adds support for synthesizing “usermod palettes” (and updated custom-palette ID behavior) into the Device.palettes mapping based on firmware-reported counts/names, and updates tests/snapshots accordingly.
Changes:
- Add
Info.usermod_palette_count/Info.usermod_palette_namesand synthesize usermod palettes intoDevice.palettes. - Make custom palette IDs depend on a firmware version threshold (legacy 255-descending vs new 200-descending layout).
- Expand unit tests and update snapshots to cover version-dependent palette IDs and usermod palettes.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
src/wled/const.py |
Introduces the firmware version threshold constant for the custom-palette ID layout change. |
src/wled/models.py |
Adds usermod palette fields on Info and synthesizes usermod/custom palette entries during deserialization and updates. |
tests/test_models.py |
Adds/updates tests for version-dependent custom palette IDs and usermod palette synthesis/update behavior. |
tests/__snapshots__/test_models.ambr |
Updates snapshots to include new Info fields (usermod_palette_count, usermod_palette_names). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9eccbd6 to
58a0ad0
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2058 +/- ##
===========================================
+ Coverage 58.61% 97.34% +38.73%
===========================================
Files 6 8 +2
Lines 662 1131 +469
Branches 143 114 -29
===========================================
+ Hits 388 1101 +713
+ Misses 270 20 -250
- Partials 4 10 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fixes three issues identified in code review: 1. Bound umpalcount to 55 slots (reserved ID space 255-201) to prevent collision with custom palette IDs. Previously umpalcount > 55 would generate IDs <= 200 and silently overwrite custom palette entries. 2. Handle null umpalnames from JSON by normalizing to empty list before use, preventing TypeError on null input. 3. Gate usermod palette synthesis on firmware >= 16.0.0, matching the version when the usermod feature was introduced. Pre-16.0.0 firmware may have custom palettes in the same ID space (255 down), so unexpected usermod fields would corrupt that data. Implementation mirrors _build_custom_palettes pattern: version check inside the function for clarity and consistency. Added three regression tests covering edge cases: - Excess count bounded to 55 max - null names list handled gracefully - Pre-16.0.0 firmware skips usermod synthesis Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
86f5645 to
cd217c6
Compare
Proposed Changes
This PR adds support for synthesizing “usermod palettes” into the Device.palettes mapping based on firmware-reported counts/names. It follows custom palettes flow.
Related Issues
Summary by CodeRabbit
New Features
Tests