Skip to content

Add set_color MQTT command handler for LED#37

Merged
sjordan0228 merged 1 commit into
devfrom
fix/uid-led-color
Mar 26, 2026
Merged

Add set_color MQTT command handler for LED#37
sjordan0228 merged 1 commit into
devfrom
fix/uid-led-color

Conversation

@sjordan0228
Copy link
Copy Markdown
Contributor

@sjordan0228 sjordan0228 commented Mar 26, 2026

Summary

New set_color MQTT command handler in HomeAssistantManager. Receives a 6-character hex color string via spoolsense/<device_id>/cmd/set_color and sets the LED to that color.

Used by the middleware for UID-only tags where the filament color comes from Spoolman, not from the tag itself. No tag needs to be present — the command is processed before the tag-present check.

Test plan

  • Scan UID-only tag → middleware sends set_color → LED turns yellow (F5EC00)
  • Smart tags still work (LED set from tag data directly)
  • Compiles clean on ESP32-WROOM

Paired with spoolsense_middleware PR #29

Summary by CodeRabbit

  • New Features
    • Added support for controlling LED colors through Home Assistant, enabling dynamic RGB color adjustments for compatible devices.

Receives color hex from middleware via spoolsense/<id>/cmd/set_color
and sets the LED to that color. Used for UID-only tags where the color
comes from Spoolman, not the tag itself.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 26, 2026

Caution

Review failed

Pull request was closed or merged during review

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'instructions'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

A modification to src/HomeAssistantManager.cpp adds LED color control handling. The handleCommand method now intercepts set_color commands with 6-character hex RGB payloads, parses them, invokes the LED display function, and returns early to prevent normal command flow processing.

Changes

Cohort / File(s) Summary
LED Color Control Integration
src/HomeAssistantManager.cpp
Added LEDManager.h include and implemented command interception for set_color command. Parses 6-character hex RGB payload using %2hhx%2hhx%2hhx format and calls LEDManager::showFilamentColor(r, g, b) with early return to bypass standard JSON parsing and command dispatch flow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description covers the summary and test plan, but is missing the required Changes section listing specific modifications and does not fully address the Checklist requirements. Add a Changes section detailing the specific modifications (e.g., modified HomeAssistantManager.cpp, added LEDManager.h include), and complete the Checklist section with hardware testing and compilation confirmations for both targets.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a set_color MQTT command handler for LED control.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/uid-led-color

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.

@sjordan0228 sjordan0228 merged commit 7e4761b into dev Mar 26, 2026
1 check was pending
@sjordan0228 sjordan0228 deleted the fix/uid-led-color branch March 27, 2026 18:34
@coderabbitai coderabbitai Bot mentioned this pull request Apr 10, 2026
4 tasks
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.

1 participant