[PR #787] [MERGED] [Feature] Spoolbuddy Fixes and Improvements #1114

Closed
opened 2026-05-06 12:35:07 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/maziggy/bambuddy/pull/787
Author: @Keybored02
Created: 3/22/2026
Status: Merged
Merged: 3/24/2026
Merged by: @maziggy

Base: devHead: feature/spoolbuddy_fixes


📝 Commits (10+)

📊 Changes

27 files changed (+2274 additions, -324 deletions)

View changed files

📝 backend/app/api/routes/inventory.py (+31 -8)
📝 backend/app/api/routes/spoolbuddy.py (+221 -4)
📝 backend/app/core/database.py (+10 -0)
📝 backend/app/models/spoolbuddy_device.py (+2 -0)
📝 backend/app/schemas/spoolbuddy.py (+25 -4)
📝 backend/app/services/spool_tag_matcher.py (+80 -10)
backend/app/utils/tag_normalization.py (+24 -0)
📝 backend/tests/integration/test_spoolbuddy.py (+56 -0)
📝 backend/tests/unit/services/test_spool_tag_matcher.py (+61 -0)
📝 frontend/src/api/client.ts (+19 -0)
📝 frontend/src/components/SpoolFormModal.tsx (+11 -1)
frontend/src/components/spoolbuddy/DiagnosticModal.tsx (+172 -0)
📝 frontend/src/components/spoolbuddy/SpoolBuddyLayout.tsx (+10 -5)
📝 frontend/src/i18n/locales/en.ts (+13 -0)
📝 frontend/src/pages/SettingsPage.tsx (+0 -2)
📝 frontend/src/pages/spoolbuddy/SpoolBuddyDashboard.tsx (+31 -13)
📝 frontend/src/pages/spoolbuddy/SpoolBuddySettingsPage.tsx (+147 -0)
📝 frontend/src/pages/spoolbuddy/SpoolBuddyWriteTagPage.tsx (+633 -151)
📝 spoolbuddy/README.md (+10 -29)
📝 spoolbuddy/daemon/api_client.py (+38 -0)

...and 7 more files

📄 Description

Description

This feature branch encompasses major enhancements to the SpoolBuddy hardware. The work spans backend hardware communication, frontend spool creation workflows, and error handling.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test addition or update

Changes Made

1. SpoolBuddy Kiosk UI/UX Improvements (Frontend)

Replace modal-based spool creation with inline form optimized for kiosk touch interface

  • Replaced SpoolFormModal with NewSpoolTouchForm component directly on the page
  • Implemented dual-view toggle (Simple mode for quick entry, Full mode for advanced options)
  • Integrated all Inventory Add Spool form sections (Filament, Color, Additional, PA Profiles)
  • Added K-profile selection and bulk creation support
  • Matched Simple view layout to historical proven UI implementation

2. Hardware Diagnostics & Error Handling (Backend/Scripts)

Provide user-friendly diagnostic feedback when hardware is in use or unavailable

  • Enhanced scale_diag.py with intelligent error detection:
    • Errno 16 (Device busy) → Clear message about daemon lock + restart instructions
    • Errno 121 (I2C NACK) → Hardware troubleshooting checklist
    • Suppresses noisy tracebacks for known errors
  • Enhanced read_tag.py with resource conflict detection:
    • Detects GPIO/SPI resource busy conditions
    • Provides actionable daemon stop/restart guidance
    • Catches OSError, RuntimeError, PermissionError
  • Both diagnostics now only show full traceback for unexpected errors
  • Added DiagnosticModal component for running NFC/scale diagnostics from the kiosk.
  • Integrated diagnostic buttons in the SpoolBuddyWriteTagPage and settings page.
  • Displays real-time output/results from backend diagnostics endpoints.
  • New/updated API endpoints to queue and fetch diagnostic results for devices.
  • Diagnostic result schema and response handling improvements.

3. Hardware Integration & Configuration (Backend/Installer)

Simplify hardware configuration and improve installer robustness

  • Standardized environment variable naming for kiosk parameters
  • Fixed I2C bus initialization in installer scripts
  • Made GPIO/SPI pin assignments configurable via environment variables
  • Updated installer to support branch selection (main/dev)
  • Added kiosk user permissions for environment file access
  • Improved environment variable parsing and validation
  • Extended device model and API to support updating the device’s IP address and API token.
  • Added/updated endpoints for device configuration (IP, token).
  • Improved validation and error handling for config changes.
  • Ensured secure update of API token with proper authentication/authorization checks.
  • Updated device registration and heartbeat logic to handle IP/token changes.

4. NFC Tag Reading & Spool Matching (Backend)

Fix critical issues with NFC tag detection and spool identification

  • Fixed UUID mismatch bugs that caused previously-tagged spools to appear as new
  • Added backward compatibility for shorter UID formats
  • Improved spool retrieval and tag matching logic
  • Enhanced tag input validation
  • Improved diagnostic output for troubleshooting NFC issues

5. Untagging & Tag Management (Frontend)

Allow users to remove spool tags and improve write safety

  • Added untagging capability for selected spools in kiosk interface
  • Enhanced NFC write logic to prevent incompatible tag type operations
  • Improved user feedback for tag write operations
  • Files: frontend/src/pages/spoolbuddy/SpoolBuddyWriteTagPage.tsx

6. Device Online Status & Heartbeat (Backend)

Implement proper online/offline status tracking for SpoolBuddy kiosk devices

  • Added online presence broadcasting during heartbeat events
  • Fixed device online state detection logic
  • Ensures accurate device availability reporting in multihost environments
  • Files: spoolbuddy/daemon/*.py, backend/app/api/routes/spoolbuddy.py

Screenshots

image

Testing

  • I have tested this on my local machine
  • I have tested with my printer model: H2C

Checklist

  • My code follows the project's coding style
  • I have commented my code where necessary
  • [] I have updated the documentation (if needed)
  • My changes generate no new warnings
  • I have tested my changes thoroughly

Additional Notes

Installation script needs testing on different systems.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/maziggy/bambuddy/pull/787 **Author:** [@Keybored02](https://github.com/Keybored02) **Created:** 3/22/2026 **Status:** ✅ Merged **Merged:** 3/24/2026 **Merged by:** [@maziggy](https://github.com/maziggy) **Base:** `dev` ← **Head:** `feature/spoolbuddy_fixes` --- ### 📝 Commits (10+) - [`aadf9f3`](https://github.com/maziggy/bambuddy/commit/aadf9f365fdca6bce6489ee892114fd4611096b1) Revert "Set version" - [`20ee781`](https://github.com/maziggy/bambuddy/commit/20ee781a15a64c81ff42171a17bae8d10fc602b8) Updated README - [`d4e38b5`](https://github.com/maziggy/bambuddy/commit/d4e38b5105ddb0f0203d4ab675868997f30a89d2) Merge branch 'dev' of https://github.com/Keybored02/bambuddy into dev - [`66e335e`](https://github.com/maziggy/bambuddy/commit/66e335eede691f01060e60c6ddacabe4d6462148) Swiutch to internal LDO and 3.0V reference - [`69ceeac`](https://github.com/maziggy/bambuddy/commit/69ceeac5606b5e8eb9faf44e798c13d8465f92aa) Update scale diagnostic - [`f607d40`](https://github.com/maziggy/bambuddy/commit/f607d40cc71ee4d301e0d6b354275ddafa18129b) Improve readers - [`57fcb7f`](https://github.com/maziggy/bambuddy/commit/57fcb7fbf34fb7129e8ec7716818eb4651d3d21b) Update readme to change scale pins and I2C pins - [`820dce8`](https://github.com/maziggy/bambuddy/commit/820dce84e6694496584d8d4546878c398b54497b) Improve NFC diagnostics - [`3c53854`](https://github.com/maziggy/bambuddy/commit/3c53854cbc4bb65250963410548ad35ac6b4d272) Make kiosk params follow .env keys, fix installer inits for i2C bus - [`37165ab`](https://github.com/maziggy/bambuddy/commit/37165abebbbf5af918b3049b7354ea80acb3b839) Make SPI pins more aeasily assignable ### 📊 Changes **27 files changed** (+2274 additions, -324 deletions) <details> <summary>View changed files</summary> 📝 `backend/app/api/routes/inventory.py` (+31 -8) 📝 `backend/app/api/routes/spoolbuddy.py` (+221 -4) 📝 `backend/app/core/database.py` (+10 -0) 📝 `backend/app/models/spoolbuddy_device.py` (+2 -0) 📝 `backend/app/schemas/spoolbuddy.py` (+25 -4) 📝 `backend/app/services/spool_tag_matcher.py` (+80 -10) ➕ `backend/app/utils/tag_normalization.py` (+24 -0) 📝 `backend/tests/integration/test_spoolbuddy.py` (+56 -0) 📝 `backend/tests/unit/services/test_spool_tag_matcher.py` (+61 -0) 📝 `frontend/src/api/client.ts` (+19 -0) 📝 `frontend/src/components/SpoolFormModal.tsx` (+11 -1) ➕ `frontend/src/components/spoolbuddy/DiagnosticModal.tsx` (+172 -0) 📝 `frontend/src/components/spoolbuddy/SpoolBuddyLayout.tsx` (+10 -5) 📝 `frontend/src/i18n/locales/en.ts` (+13 -0) 📝 `frontend/src/pages/SettingsPage.tsx` (+0 -2) 📝 `frontend/src/pages/spoolbuddy/SpoolBuddyDashboard.tsx` (+31 -13) 📝 `frontend/src/pages/spoolbuddy/SpoolBuddySettingsPage.tsx` (+147 -0) 📝 `frontend/src/pages/spoolbuddy/SpoolBuddyWriteTagPage.tsx` (+633 -151) 📝 `spoolbuddy/README.md` (+10 -29) 📝 `spoolbuddy/daemon/api_client.py` (+38 -0) _...and 7 more files_ </details> ### 📄 Description ## Description This feature branch encompasses major enhancements to the SpoolBuddy hardware. The work spans backend hardware communication, frontend spool creation workflows, and error handling. ## Type of Change <!-- Mark the relevant option with an "x" --> - [x] Bug fix (non-breaking change that fixes an issue) - [x] New feature (non-breaking change that adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [x] Code refactoring - [ ] Performance improvement - [ ] Test addition or update ## Changes Made ### 1. **SpoolBuddy Kiosk UI/UX Improvements** (Frontend) Replace modal-based spool creation with inline form optimized for kiosk touch interface - Replaced `SpoolFormModal` with `NewSpoolTouchForm` component directly on the page - Implemented dual-view toggle (Simple mode for quick entry, Full mode for advanced options) - Integrated all Inventory Add Spool form sections (Filament, Color, Additional, PA Profiles) - Added K-profile selection and bulk creation support - Matched Simple view layout to historical proven UI implementation --- ### 2. **Hardware Diagnostics & Error Handling** (Backend/Scripts) Provide user-friendly diagnostic feedback when hardware is in use or unavailable - Enhanced `scale_diag.py` with intelligent error detection: - Errno 16 (Device busy) → Clear message about daemon lock + restart instructions - Errno 121 (I2C NACK) → Hardware troubleshooting checklist - Suppresses noisy tracebacks for known errors - Enhanced `read_tag.py` with resource conflict detection: - Detects GPIO/SPI resource busy conditions - Provides actionable daemon stop/restart guidance - Catches OSError, RuntimeError, PermissionError - Both diagnostics now only show full traceback for unexpected errors - Added DiagnosticModal component for running NFC/scale diagnostics from the kiosk. - Integrated diagnostic buttons in the SpoolBuddyWriteTagPage and settings page. - Displays real-time output/results from backend diagnostics endpoints. - New/updated API endpoints to queue and fetch diagnostic results for devices. - Diagnostic result schema and response handling improvements. --- ### 3. **Hardware Integration & Configuration** (Backend/Installer) Simplify hardware configuration and improve installer robustness - Standardized environment variable naming for kiosk parameters - Fixed I2C bus initialization in installer scripts - Made GPIO/SPI pin assignments configurable via environment variables - Updated installer to support branch selection (main/dev) - Added kiosk user permissions for environment file access - Improved environment variable parsing and validation - Extended device model and API to support updating the device’s IP address and API token. - Added/updated endpoints for device configuration (IP, token). - Improved validation and error handling for config changes. - Ensured secure update of API token with proper authentication/authorization checks. - Updated device registration and heartbeat logic to handle IP/token changes. --- ### 4. **NFC Tag Reading & Spool Matching** (Backend) Fix critical issues with NFC tag detection and spool identification - Fixed UUID mismatch bugs that caused previously-tagged spools to appear as new - Added backward compatibility for shorter UID formats - Improved spool retrieval and tag matching logic - Enhanced tag input validation - Improved diagnostic output for troubleshooting NFC issues --- ### 5. **Untagging & Tag Management** (Frontend) Allow users to remove spool tags and improve write safety - Added untagging capability for selected spools in kiosk interface - Enhanced NFC write logic to prevent incompatible tag type operations - Improved user feedback for tag write operations - Files: `frontend/src/pages/spoolbuddy/SpoolBuddyWriteTagPage.tsx` --- ### 6. **Device Online Status & Heartbeat** (Backend) Implement proper online/offline status tracking for SpoolBuddy kiosk devices - Added online presence broadcasting during heartbeat events - Fixed device online state detection logic - Ensures accurate device availability reporting in multihost environments - Files: `spoolbuddy/daemon/*.py`, `backend/app/api/routes/spoolbuddy.py` --- ## Screenshots <img width="1916" height="988" alt="image" src="https://github.com/user-attachments/assets/62384a92-bb69-41c2-b6e4-86fbe0936f1b" /> ## Testing <!-- Describe how you tested your changes --> - [x] I have tested this on my local machine - [x] I have tested with my printer model: H2C ## Checklist - [x] My code follows the project's coding style - [x] I have commented my code where necessary - [] I have updated the documentation (if needed) - [x] My changes generate no new warnings - [x] I have tested my changes thoroughly ## Additional Notes Installation script needs testing on different systems. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:35:07 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/bambuddy#1114
No description provided.