Skip to content

feat: cmd/low_spool MQTT handler#147

Merged
sjordan0228 merged 1 commit into
devfrom
feature/cmd-low-spool
Apr 10, 2026
Merged

feat: cmd/low_spool MQTT handler#147
sjordan0228 merged 1 commit into
devfrom
feature/cmd-low-spool

Conversation

@sjordan0228
Copy link
Copy Markdown
Contributor

@sjordan0228 sjordan0228 commented Apr 10, 2026

Summary

  • New cmd/low_spool MQTT command — middleware/HA sends true/false to start/stop LED breathing mid-print
  • Uses LED's current target color (persists after tag removal) so breathing matches the last scanned spool
  • LEDManager::getTargetColor() getter for reading current LED target RGB
  • Fix misleading log: "Spool X synced" instead of "Spool X, 0.0g remaining" when weight not sent

Test plan

  • Build succeeds
  • Scan red tag, remove, send cmd/low_spool true → breathes red
  • Send cmd/low_spool false → solid red
  • Web log shows "Low spool: breathing enabled/disabled"

Completes #137 (gap #3 — cmd/low_spool handler)

Summary by CodeRabbit

  • New Features

    • Added new MQTT command support for controlling LED indicator behavior based on spool status, enabling LED breathing effects or static display modes
  • Improvements

    • Enhanced logging messages for spool weight synchronization to provide clearer feedback during updates

Middleware or HA sends cmd/low_spool with "true"/"false" to start/stop
LED breathing. Uses current LED target color (persists after tag
removal) so breathing matches the last scanned spool.

Also fixes misleading log message — shows "Spool X synced" instead
of "Spool X, 0.0g remaining" when weight field is skipped.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 10, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR adds MQTT command handling for low_spool in HomeAssistantManager that controls LED behavior by fetching the current target color and toggling between LED breathing and static display, complemented by a new LEDManager accessor method and improved weight logging in SpoolmanManager.

Changes

Cohort / File(s) Summary
LEDManager Accessor
src/LEDManager.h, src/LEDManager.cpp
Added public const method getTargetColor() to expose the internal _target RGB color components via output references.
MQTT Command Handler
src/HomeAssistantManager.cpp
Implemented low_spool command that fetches target LED color, applies dim-white fallback for zero RGB values, and conditionally starts LED breathing or sets static color based on payload boolean interpretation.
Weight Logging
src/SpoolmanManager.cpp
Modified updateSpool() to conditionally log remaining weight only when greater than zero; logs sync completion without numeric value otherwise.

Sequence Diagram

sequenceDiagram
    participant MQTT as MQTT Broker
    participant HAM as HomeAssistantManager
    participant LED as LEDManager
    participant Log as Logger

    MQTT->>HAM: low_spool command<br/>(payload: "true"/"false")
    HAM->>LED: getTargetColor(r, g, b)
    LED-->>HAM: return RGB values
    alt RGB all zero
        HAM->>HAM: apply dim-white fallback<br/>(r=200, g=200, b=200)
    end
    alt payload == "true"
        HAM->>LED: breatheFilamentColor()
        HAM->>Log: log "Low spool enabled"
    else payload != "true"
        HAM->>LED: showFilamentColor(r, g, b)
        HAM->>Log: log "Low spool disabled"
    end
    HAM->>MQTT: publish command response<br/>(success)
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly Related Issues

Possibly Related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title 'feat: cmd/low_spool MQTT handler' accurately and concisely describes the main change — adding a new MQTT command handler for low spool detection.
Description check ✅ Passed The description includes Summary and Test plan sections matching template requirements, with specific test cases and build verification. However, it lacks the 'Changes' and 'How to Test' structural sections and missing explicit checklist items.

✏️ 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 feature/cmd-low-spool

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.

@github-actions github-actions Bot added the size/S Small change (10-50 lines) label Apr 10, 2026
@sjordan0228 sjordan0228 merged commit c24488d into dev Apr 10, 2026
2 of 3 checks passed
@sjordan0228 sjordan0228 deleted the feature/cmd-low-spool branch April 10, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small change (10-50 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant