Skip to content

Add JSON API documentation for palettes#317

Open
mik-laj wants to merge 2 commits intowled:mainfrom
mik-laj:patch-3
Open

Add JSON API documentation for palettes#317
mik-laj wants to merge 2 commits intowled:mainfrom
mik-laj:patch-3

Conversation

@mik-laj
Copy link
Copy Markdown
Contributor

@mik-laj mik-laj commented May 9, 2026

Adds detailed documentation about WLED palette ID schemes to address the breaking changes introduced in WLED 16.0.0 (issue #2056).

Changes:

  • New "Palettes" section explaining three palette types: built-in, custom, and usermod
  • Documents legacy (< 16.0.0) vs. modern (16.0.0+) palette ID allocation schemes
  • Explains how palette names are obtained from different sources
  • Adds cpalcount, umpalcount, and umpalnames to Info object table
  • Clarifies pal parameter to reference the new Palettes section
  • Includes practical examples for setting palettes via API

Related issue: wled/WLED#5542

Summary by CodeRabbit

Documentation

  • Enhanced JSON API documentation with improved palette guidance
  • Clarified palette ID ranges, firmware variations, and palette types
  • Added schema fields for tracking custom and usermod palette counts
  • Expanded examples for palette selection and customization

Updated JSON API documentation for palettes and custom options.
Copilot AI review requested due to automatic review settings May 9, 2026 00:07
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Review Change Stack

Walkthrough

Documentation for the JSON API expanded to cover palette behavior comprehensively. The segment object and info response schemas were clarified with firmware-dependent palette IDs and new palette-count fields. A dedicated Palettes section explains three palette types and ID scheme changes across WLED versions, with practical examples added for setting palettes on segments.

Changes

Palette API Documentation

Layer / File(s) Summary
API Schema Changes
docs/interfaces/json-api.md
seg.pal field documentation clarified for firmware-dependent palette IDs and supported relative/random operators; /json/info response extended with cpalcount, umpalcount, and umpalnames fields.
Palette Concepts & Scheme
docs/interfaces/json-api.md
New "Palettes" section added documenting built-in, custom, and usermod palette types; explains palette ID scheme differences pre- and post-WLED 16.0.0; details how palette names are derived for each type.
Practical API Examples
docs/interfaces/json-api.md
Sample JSON API requests added showing how to set built-in and custom palettes on specific segments.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • netmindz

Poem

🎨 A palette guide, so bright and clear,
With schemas polished, firmware-aware,
Custom, built-in, usermod delight,
Examples hop through code so light,
Documentation blooms—hop hop hooray! 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add JSON API documentation for palettes' directly aligns with the primary change: comprehensive documentation additions for WLED palette ID schemes and types.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/interfaces/json-api.md`:
- Around line 250-252: The three newly added table rows for cpalcount,
umpalcount, and umpalnames are missing the leading pipe character which breaks
GFM pipe-table formatting and triggers MD055; update the rows referenced by the
symbols cpalcount, umpalcount, and umpalnames to start with a leading '|' and
match the surrounding pipe-table format (also apply the same fix to the
analogous rows at the other occurrence mentioned around umpalcount/umpalnames at
the later section).
- Line 354: Change the subsection heading "Palette naming" to title case
("Palette Naming") in the docs/interfaces/json-api.md content so it matches the
project's documentation heading rules; locate the heading text "Palette naming"
and update its casing only (no other content changes).
- Line 199: The table row for the "pal" field is missing the leading pipe, which
breaks GFM pipe table style and triggers MD055; update the table row for the pal
entry (the line containing "pal | byte | ID of an available palette...") to
include the leading "|" at the start of the line so it conforms to standard
Markdown pipe-table syntax and passes linting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d0c3f320-7d9a-4263-8ade-9f4b64a1d157

📥 Commits

Reviewing files that changed from the base of the PR and between 96b4c4a and 858e704.

📒 Files selected for processing (1)
  • docs/interfaces/json-api.md

Comment thread docs/interfaces/json-api.md Outdated
o2 | bool | Effect option 2.
o3 | bool | Effect option 3.
pal | 0 to info.palcount -1 | ID of the color palette or ~ to increment, ~- to decrement, or r for random.
pal | byte | ID of an available palette (see [Palettes](#palettes) section for available ID ranges depending on firmware version) or ~ to increment, ~- to decrement, or r for random.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix table row pipe style for the pal field entry.

This changed row is missing the leading |, which triggers MD055 and can fail docs linting.

Suggested fix
-pal | byte | ID of an available palette (see [Palettes](`#palettes`) section for available ID ranges depending on firmware version) or ~ to increment, ~- to decrement, or r for random.
+| pal | byte | ID of an available palette (see [Palettes](`#palettes`) section for available ID ranges depending on firmware version) or ~ to increment, ~- to decrement, or r for random.

As per coding guidelines, use standard GFM pipe tables for Markdown documentation.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pal | byte | ID of an available palette (see [Palettes](#palettes) section for available ID ranges depending on firmware version) or ~ to increment, ~- to decrement, or r for random.
| pal | byte | ID of an available palette (see [Palettes](`#palettes`) section for available ID ranges depending on firmware version) or ~ to increment, ~- to decrement, or r for random.
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 199-199: Table pipe style
Expected: leading_only; Actual: no_leading_or_trailing; Missing leading pipe

(MD055, table-pipe-style)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/interfaces/json-api.md` at line 199, The table row for the "pal" field
is missing the leading pipe, which breaks GFM pipe table style and triggers
MD055; update the table row for the pal entry (the line containing "pal | byte |
ID of an available palette...") to include the leading "|" at the start of the
line so it conforms to standard Markdown pipe-table syntax and passes linting.

Comment thread docs/interfaces/json-api.md Outdated
Comment on lines +250 to +252
cpalcount | byte | Number of custom user-created palettes. _(available since 0.11.0)_
umpalcount | byte | Number of usermod-registered palettes. _(available since 16.0.0)_
umpalnames | array of strings | Names of usermod-registered palettes. _(available since 16.0.0)_
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Normalize pipe-table formatting for the newly added rows.

The newly added table rows here also miss the leading |, causing the same MD055 warnings.

Suggested fix
-cpalcount | byte | Number of custom user-created palettes. _(available since 0.11.0)_
-umpalcount | byte | Number of usermod-registered palettes. _(available since 16.0.0)_
-umpalnames | array of strings | Names of usermod-registered palettes. _(available since 16.0.0)_
+| cpalcount | byte | Number of custom user-created palettes. _(available since 0.11.0)_
+| umpalcount | byte | Number of usermod-registered palettes. _(available since 16.0.0)_
+| umpalnames | array of strings | Names of usermod-registered palettes. _(available since 16.0.0)_

-Set palette 0 on segment 0 | `{"seg":[{"id":0,"pal":0}]}`
-Set a custom palette (ID 200) on segment 1 | `{"seg":[{"id":1,"pal":200}]}`
+| Set palette 0 on segment 0 | `{"seg":[{"id":0,"pal":0}]}`
+| Set a custom palette (ID 200) on segment 1 | `{"seg":[{"id":1,"pal":200}]}`

As per coding guidelines, use standard GFM pipe tables for Markdown documentation.

Also applies to: 281-282

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 250-250: Table pipe style
Expected: leading_only; Actual: no_leading_or_trailing; Missing leading pipe

(MD055, table-pipe-style)


[warning] 251-251: Table pipe style
Expected: leading_only; Actual: no_leading_or_trailing; Missing leading pipe

(MD055, table-pipe-style)


[warning] 252-252: Table pipe style
Expected: leading_only; Actual: no_leading_or_trailing; Missing leading pipe

(MD055, table-pipe-style)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/interfaces/json-api.md` around lines 250 - 252, The three newly added
table rows for cpalcount, umpalcount, and umpalnames are missing the leading
pipe character which breaks GFM pipe-table formatting and triggers MD055; update
the rows referenced by the symbols cpalcount, umpalcount, and umpalnames to
start with a leading '|' and match the surrounding pipe-table format (also apply
the same fix to the analogous rows at the other occurrence mentioned around
umpalcount/umpalnames at the later section).

Comment thread docs/interfaces/json-api.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new “Palettes” documentation section to the JSON API docs to explain palette types and the palette ID scheme differences across WLED versions, motivated by the palette ID breaking changes introduced in WLED 16.0.0.

Changes:

  • Updates the segment pal parameter documentation to point readers to a new Palettes section.
  • Extends the Info object table with cpalcount, umpalcount, and umpalnames.
  • Adds examples and a new “Palettes” section describing legacy vs. 16.0.0+ ID allocation and naming sources.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/interfaces/json-api.md Outdated
o2 | bool | Effect option 2.
o3 | bool | Effect option 3.
pal | 0 to info.palcount -1 | ID of the color palette or ~ to increment, ~- to decrement, or r for random.
pal | byte | ID of an available palette (see [Palettes](#palettes) section for available ID ranges depending on firmware version) or ~ to increment, ~- to decrement, or r for random.
Comment thread docs/interfaces/json-api.md Outdated
Select random effect on _all selected_ segments | `{"seg":{"fx":"r"}}`
Select random palette between 5 and 10 on segment 2 | `{"seg":[{"id":2,"pal":"5~10r"}]}`
Set palette 0 on segment 0 | `{"seg":[{"id":0,"pal":0}]}`
Set a custom palette (ID 200) on segment 1 | `{"seg":[{"id":1,"pal":200}]}`
Comment thread docs/interfaces/json-api.md Outdated
Comment on lines +249 to +251
palcount | uint16 | Number of palettes configured.
cpalcount | byte | Number of custom user-created palettes. _(available since 0.11.0)_
umpalcount | byte | Number of usermod-registered palettes. _(available since 16.0.0)_
Updated palette ID range and clarified custom palette usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants