[PR #533] [CLOSED] Feature AMS maintenance #1062

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

📋 Pull Request Information

Original PR: https://github.com/maziggy/bambuddy/pull/533
Author: @cadtoolbox
Created: 2/26/2026
Status: Closed

Base: 0.2.2b1Head: feature_ams_maintenance


📝 Commits (10+)

  • 31b67f1 Bumped version
  • c4fe017 Add SpoolBuddy AMS slot config, external slots, and dashboard redesign
  • 6aa6a96 Increase scale moving average window to reduce weight bouncing
  • 4cdf52f Remove stability flipping as scale report trigger
  • 96a27d6 Minor Spoolbuddy frontend improvements
  • 3669219 Updated CI
  • bcde036 Updated CI
  • 7bf960a Updated CI
  • bf2e1d0 Updated .github/ISSUE_TEMPLATE/bug_report.yml
  • 9e654a6 Updated .github/ISSUE_TEMPLATE/bug_report.yml

📊 Changes

42 files changed (+1842 additions, -52 deletions)

View changed files

📝 .github/workflows/security.yml (+2 -2)
📝 CHANGELOG.md (+7 -6)
📝 backend/app/api/routes/printers.py (+71 -0)
📝 backend/app/api/routes/settings.py (+6 -3)
📝 backend/app/core/database.py (+1 -0)
📝 backend/app/models/__init__.py (+4 -0)
backend/app/models/ams_label.py (+32 -0)
📝 backend/app/schemas/printer.py (+2 -0)
📝 backend/app/services/bambu_mqtt.py (+109 -0)
📝 backend/app/services/printer_manager.py (+4 -0)
debug_logs/a1 mini/CubeTest.3mf (+0 -0)
debug_logs/a1 mini/CubeTest.gcode.3mf (+0 -0)
debug_logs/a1 mini/bambuddy-support-20260218-193933.zip (+0 -0)
debug_logs/h2c/Cube + Cube + Cube.gcode.3mf (+0 -0)
debug_logs/h2c/bambuddy-support-20260218-110542.zip (+0 -0)
debug_logs/h2c/support-info.json (+143 -0)
debug_logs/h2d_pro/H2D Pro 5 Color AMS Test.gcode.3mf (+0 -0)
debug_logs/h2d_pro/H2D Pro mgtt request from Bambustudio.json (+56 -0)
debug_logs/h2d_pro/bambuddy-support-20260218-092343.zip (+0 -0)
debug_logs/h2d_pro/support_data/support-info.json (+204 -0)

...and 22 more files

📄 Description

Description

Adds two UX improvements to the AMS display on the Printers page: a hover popup on each AMS label exposing hardware details and a user-editable friendly name, and 1-based slot numbers centered inside each filament color circle with auto-inverted contrast.

AMS name hover popup
Hovering the AMS label (e.g. AMS-A) opens a popover showing:

  • Serial number – sourced from the MQTT sn field on the AMS unit object
  • Firmware version – parsed from info.module[name="ams/"].sw_ver in the get_version MQTT response
  • Friendly name – editable text field, stored in a new ams_labels DB table; gated by printers:update permission

Fixes #464

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

Backend

  • New AmsLabel model (printer_id, ams_id, label); table auto-created via create_all.
  • AMSUnit schema gains serial_number and sw_ver fields; both populated in the status route from raw MQTT data.
    _handle_version_info in bambu_mqtt.py extended to parse ams/ modules and write sw_ver/sn back onto the stored AMS unit dict.
  • Three new REST endpoints: GET /printers/{id}/ams-labels, PUT /printers/{id}/ams-labels/{ams_id}, DELETE /printers/{id}/ams-labels/{ams_id}.

Frontend

  • New AmsNameHoverCard component in PrintersPage.tsx using the same hover-card pattern as NozzleSlotHoverCard.
  • AMSUnit interface extended with serial_number and sw_ver; three new API client functions added.
  • Slot numbers in color circles
  • Each filament circle now renders its 1-based slot number centered inside it. Font color is computed via the existing isLightFilamentColor helper—black text on light filament, white on dark. Applied consistently to regular 4-tray AMS, HT AMS, and external spool slots.

Bug Fixes

  • backend/app/api/routes/settings.py: After copying the backup database file, call reinitialize_database() to point the engine at the restored file, then init_db() to create missing tables (CREATE TABLE IF NOT EXISTS) and apply column migrations — eliminating the need for a manual restart to recover a usable schema.
# After shutil.copy2(backup_db, db_path)
await reinitialize_database()
await init_db()
  • backend/tests/integration/test_settings_api.py: Added test_restore_reinitializes_database_schema asserting that close_all_connections, reinitialize_database, and init_db are all invoked on a successful restore.

Screenshots

2026-02-26_08-41-29

Testing

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

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


🔄 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/533 **Author:** [@cadtoolbox](https://github.com/cadtoolbox) **Created:** 2/26/2026 **Status:** ❌ Closed **Base:** `0.2.2b1` ← **Head:** `feature_ams_maintenance` --- ### 📝 Commits (10+) - [`31b67f1`](https://github.com/maziggy/bambuddy/commit/31b67f10a82811131b9136c6aaa9f129029a3a0f) Bumped version - [`c4fe017`](https://github.com/maziggy/bambuddy/commit/c4fe01759575177d0fe68c0c05eedbb1deb90b0a) Add SpoolBuddy AMS slot config, external slots, and dashboard redesign - [`6aa6a96`](https://github.com/maziggy/bambuddy/commit/6aa6a96b159f5069d961ce2a9cff37ff62e3053a) Increase scale moving average window to reduce weight bouncing - [`4cdf52f`](https://github.com/maziggy/bambuddy/commit/4cdf52fc72deb316fc02a2751c9945ea0e8e86c6) Remove stability flipping as scale report trigger - [`96a27d6`](https://github.com/maziggy/bambuddy/commit/96a27d6b1f6db301115b523e18bbd5e42486bbdd) Minor Spoolbuddy frontend improvements - [`3669219`](https://github.com/maziggy/bambuddy/commit/366921942c94fe52e9402c7cfbd07964cf8f3a20) Updated CI - [`bcde036`](https://github.com/maziggy/bambuddy/commit/bcde036b9622567cea53b24336f9c765f40c0708) Updated CI - [`7bf960a`](https://github.com/maziggy/bambuddy/commit/7bf960aa7b2d3b213cb139b8a7b80f75b6f1cb6b) Updated CI - [`bf2e1d0`](https://github.com/maziggy/bambuddy/commit/bf2e1d027d9e9d435a7834c266c3f6f3f77cc257) Updated .github/ISSUE_TEMPLATE/bug_report.yml - [`9e654a6`](https://github.com/maziggy/bambuddy/commit/9e654a6eb3f3bdde3570e40fa759cce72cdd8814) Updated .github/ISSUE_TEMPLATE/bug_report.yml ### 📊 Changes **42 files changed** (+1842 additions, -52 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/security.yml` (+2 -2) 📝 `CHANGELOG.md` (+7 -6) 📝 `backend/app/api/routes/printers.py` (+71 -0) 📝 `backend/app/api/routes/settings.py` (+6 -3) 📝 `backend/app/core/database.py` (+1 -0) 📝 `backend/app/models/__init__.py` (+4 -0) ➕ `backend/app/models/ams_label.py` (+32 -0) 📝 `backend/app/schemas/printer.py` (+2 -0) 📝 `backend/app/services/bambu_mqtt.py` (+109 -0) 📝 `backend/app/services/printer_manager.py` (+4 -0) ➕ `debug_logs/a1 mini/CubeTest.3mf` (+0 -0) ➕ `debug_logs/a1 mini/CubeTest.gcode.3mf` (+0 -0) ➕ `debug_logs/a1 mini/bambuddy-support-20260218-193933.zip` (+0 -0) ➕ `debug_logs/h2c/Cube + Cube + Cube.gcode.3mf` (+0 -0) ➕ `debug_logs/h2c/bambuddy-support-20260218-110542.zip` (+0 -0) ➕ `debug_logs/h2c/support-info.json` (+143 -0) ➕ `debug_logs/h2d_pro/H2D Pro 5 Color AMS Test.gcode.3mf` (+0 -0) ➕ `debug_logs/h2d_pro/H2D Pro mgtt request from Bambustudio.json` (+56 -0) ➕ `debug_logs/h2d_pro/bambuddy-support-20260218-092343.zip` (+0 -0) ➕ `debug_logs/h2d_pro/support_data/support-info.json` (+204 -0) _...and 22 more files_ </details> ### 📄 Description ## Description Adds two UX improvements to the AMS display on the Printers page: a hover popup on each AMS label exposing hardware details and a user-editable friendly name, and 1-based slot numbers centered inside each filament color circle with auto-inverted contrast. **AMS name hover popup** Hovering the AMS label (e.g. AMS-A) opens a popover showing: - Serial number – sourced from the MQTT sn field on the AMS unit object - Firmware version – parsed from info.module[name="ams/<id>"].sw_ver in the get_version MQTT response - Friendly name – editable text field, stored in a new ams_labels DB table; gated by printers:update permission ## Related Issue <!-- Link to the issue this PR addresses (if applicable) --> Fixes #464 ## Type of Change <!-- Mark the relevant option with an "x" --> - [ ] Bug fix (non-breaking change that fixes an issue) - [X] 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 <!-- List the specific changes made in this PR --> Backend - New AmsLabel model (printer_id, ams_id, label); table auto-created via create_all. - AMSUnit schema gains serial_number and sw_ver fields; both populated in the status route from raw MQTT data. _handle_version_info in bambu_mqtt.py extended to parse ams/<id> modules and write sw_ver/sn back onto the stored AMS unit dict. - Three new REST endpoints: GET /printers/{id}/ams-labels, PUT /printers/{id}/ams-labels/{ams_id}, DELETE /printers/{id}/ams-labels/{ams_id}. Frontend - New AmsNameHoverCard component in PrintersPage.tsx using the same hover-card pattern as NozzleSlotHoverCard. - AMSUnit interface extended with serial_number and sw_ver; three new API client functions added. - Slot numbers in color circles - Each filament circle now renders its 1-based slot number centered inside it. Font color is computed via the existing isLightFilamentColor helper—black text on light filament, white on dark. Applied consistently to regular 4-tray AMS, HT AMS, and external spool slots. Bug Fixes - backend/app/api/routes/settings.py: After copying the backup database file, call reinitialize_database() to point the engine at the restored file, then init_db() to create missing tables (CREATE TABLE IF NOT EXISTS) and apply column migrations — eliminating the need for a manual restart to recover a usable schema. ``` # After shutil.copy2(backup_db, db_path) await reinitialize_database() await init_db() ``` - backend/tests/integration/test_settings_api.py: Added test_restore_reinitializes_database_schema asserting that close_all_connections, reinitialize_database, and init_db are all invoked on a successful restore. ## Screenshots <!-- If applicable, add screenshots to demonstrate your changes --> ![2026-02-26_08-41-29](https://github.com/user-attachments/assets/8de3a152-40ce-40a6-9d0d-70b63616e38b) ## Testing <!-- Describe how you tested your changes --> - [X] I have tested this on my local machine - [X] I have tested with my printer model: X1E ## 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:34:46 +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#1062
No description provided.