1
0
Fork 0
mirror of https://github.com/maziggy/bambuddy.git synced 2026-05-09 08:25:54 +02:00

[PR #892] [MERGED] Add Load/Unload filament buttons to printer controls #1132

Closed
opened 2026-05-07 00:16:11 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/maziggy/bambuddy/pull/892
Author: @NNeerr00
Created: 4/4/2026
Status: Merged
Merged: 4/5/2026
Merged by: @maziggy

Base: devHead: dev


📝 Commits (1)

  • e3cde14 Add Load/Unload External filament buttons to printer controls

📊 Changes

11 files changed (+242 additions, -1 deletions)

View changed files

📝 backend/app/api/routes/printers.py (+46 -0)
📝 backend/app/services/bambu_mqtt.py (+88 -0)
📝 frontend/src/api/client.ts (+8 -0)
📝 frontend/src/i18n/locales/de.ts (+6 -0)
📝 frontend/src/i18n/locales/en.ts (+6 -0)
📝 frontend/src/i18n/locales/fr.ts (+6 -0)
📝 frontend/src/i18n/locales/it.ts (+6 -0)
📝 frontend/src/i18n/locales/ja.ts (+6 -0)
📝 frontend/src/i18n/locales/pt-BR.ts (+6 -0)
📝 frontend/src/i18n/locales/zh-CN.ts (+6 -0)
📝 frontend/src/pages/PrintersPage.tsx (+58 -1)

📄 Description

CAUTION: THIS IMPLEMENTATION HAS BEEN HEAVILY ASSITED BY AI!
Tested on my own setup: P1S, P1P, With and Without AMS

Closes #891

Description

New dedicated MQTT methods, API endpoints, and UI buttons for loading/unloading filament. Includes state guards to prevent load when filament is already loaded and unload when nothing is loaded.

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

backend/app/services/bambu_mqtt.py

  • Added load_external_filament() -> tuple[bool, str] — sends
    ams_change_filament with ams_id=255, slot_id=254, target=254.
    Refuses if filament is already loaded (tray_now != 255).
  • Added unload_external_filament() -> tuple[bool, str] — sends
    ams_change_filament with ams_id=255, slot_id=255, target=255.
    Refuses if nothing is loaded (tray_now == 255). Uses current
    nozzle temp (defaults to 210 if cold).

backend/app/api/routes/printers.py

  • Added POST /{printer_id}/filament/load-external — permission
    PRINTERS_CONTROL, calls client.load_external_filament().
  • Added POST /{printer_id}/filament/unload-external — permission
    PRINTERS_CONTROL, calls client.unload_external_filament().

Frontend

frontend/src/api/client.ts

  • Added loadExternalFilament(printerId) and
    unloadExternalFilament(printerId) API methods.

frontend/src/pages/PrintersPage.tsx

  • Imported ArrowDownToLine, ArrowUpFromLine from lucide-react.
  • Added loadExternalMutation and unloadExternalMutation (same
    pattern as stop/pause/resume).
  • Added both to isControlBusy check.
  • Added two cyan-themed buttons below the controls section,
    left-aligned. Disabled when printing, offline, busy, or missing
    permission. Spinner on pending.

i18n (all 7 locales)

en.ts, de.ts, ja.ts, it.ts, fr.ts, pt-BR.ts,

zh-CN.ts

  • Added loadExternal / unloadExternal button labels ("Load" /
    "Unload").
  • Added 4 toast keys: filamentLoadExternalSent,
    filamentUnloadExternalSent, failedToLoadExternalFilament,
    failedToUnloadExternalFilament.

Testing

  • I have tested this on my local machine
  • I have tested with my printer model: P1S, P1P, With and without AMS

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

CAUTION: THIS IMPLEMENTATION HAS BEEN HEAVILY ASSITED BY AI! AND SHOULD BE CHECKED? I GUESS
Its working for me currenty. I hope it will be a good basis to build on


🔄 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/892 **Author:** [@NNeerr00](https://github.com/NNeerr00) **Created:** 4/4/2026 **Status:** ✅ Merged **Merged:** 4/5/2026 **Merged by:** [@maziggy](https://github.com/maziggy) **Base:** `dev` ← **Head:** `dev` --- ### 📝 Commits (1) - [`e3cde14`](https://github.com/maziggy/bambuddy/commit/e3cde14a0b1017ff8c0d5d1ebb970138d34d3898) Add Load/Unload External filament buttons to printer controls ### 📊 Changes **11 files changed** (+242 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/app/api/routes/printers.py` (+46 -0) 📝 `backend/app/services/bambu_mqtt.py` (+88 -0) 📝 `frontend/src/api/client.ts` (+8 -0) 📝 `frontend/src/i18n/locales/de.ts` (+6 -0) 📝 `frontend/src/i18n/locales/en.ts` (+6 -0) 📝 `frontend/src/i18n/locales/fr.ts` (+6 -0) 📝 `frontend/src/i18n/locales/it.ts` (+6 -0) 📝 `frontend/src/i18n/locales/ja.ts` (+6 -0) 📝 `frontend/src/i18n/locales/pt-BR.ts` (+6 -0) 📝 `frontend/src/i18n/locales/zh-CN.ts` (+6 -0) 📝 `frontend/src/pages/PrintersPage.tsx` (+58 -1) </details> ### 📄 Description CAUTION: THIS IMPLEMENTATION HAS BEEN HEAVILY ASSITED BY AI! Tested on my own setup: P1S, P1P, With and Without AMS Closes #891 ## Description New dedicated MQTT methods, API endpoints, and UI buttons for loading/unloading filament. Includes state guards to prevent load when filament is already loaded and unload when nothing is loaded. ## Type of Change - [ ] 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 ### Backend #### `backend/app/services/bambu_mqtt.py` - Added `load_external_filament() -> tuple[bool, str]` — sends `ams_change_filament` with `ams_id=255, slot_id=254, target=254`. Refuses if filament is already loaded (`tray_now != 255`). - Added `unload_external_filament() -> tuple[bool, str]` — sends `ams_change_filament` with `ams_id=255, slot_id=255, target=255`. Refuses if nothing is loaded (`tray_now == 255`). Uses current nozzle temp (defaults to 210 if cold). #### `backend/app/api/routes/printers.py` - Added `POST /{printer_id}/filament/load-external` — permission `PRINTERS_CONTROL`, calls `client.load_external_filament()`. - Added `POST /{printer_id}/filament/unload-external` — permission `PRINTERS_CONTROL`, calls `client.unload_external_filament()`. ### Frontend #### `frontend/src/api/client.ts` - Added `loadExternalFilament(printerId)` and `unloadExternalFilament(printerId)` API methods. #### `frontend/src/pages/PrintersPage.tsx` - Imported `ArrowDownToLine`, `ArrowUpFromLine` from lucide-react. - Added `loadExternalMutation` and `unloadExternalMutation` (same pattern as stop/pause/resume). - Added both to `isControlBusy` check. - Added two cyan-themed buttons below the controls section, left-aligned. Disabled when printing, offline, busy, or missing permission. Spinner on pending. ### i18n (all 7 locales) #### `en.ts`, `de.ts`, `ja.ts`, `it.ts`, `fr.ts`, `pt-BR.ts`, `zh-CN.ts` - Added `loadExternal` / `unloadExternal` button labels ("Load" / "Unload"). - Added 4 toast keys: `filamentLoadExternalSent`, `filamentUnloadExternalSent`, `failedToLoadExternalFilament`, `failedToUnloadExternalFilament`. ## Testing - [x] I have tested this on my local machine - [x] I have tested with my printer model: P1S, P1P, With and without AMS ## 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 - [ ] I have tested my changes thoroughly ## Additional Notes CAUTION: THIS IMPLEMENTATION HAS BEEN HEAVILY ASSITED BY AI! AND SHOULD BE CHECKED? I GUESS Its working for me currenty. I hope it will be a good basis to build on --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-07 00:16:11 +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-maziggy-1#1132
No description provided.