Commit Graph
1847 Commits
Author SHA1 Message Date
maziggy aeca15b585 Add SpoolBuddy integration as optional filament management add-on
SpoolBuddy turns a Raspberry Pi 4B with a PN5180 NFC reader and
NAU7802 scale into a filament management station that integrates
with Bambuddy via REST API and WebSocket.

Backend: SpoolBuddyDevice model, 10 REST endpoints (/spoolbuddy/*),
6 WebSocket broadcast types, background offline-detection watchdog.

RPi daemon: asyncio service with concurrent NFC polling (300ms,
MIFARE Classic + Bambu HKDF key derivation), scale reading (10 SPS,
5-sample moving average, stability detection), and 10s heartbeat
with exponential backoff reconnect.

Frontend: kiosk-optimized 1024x600 UI at /spoolbuddy with Dashboard
(live weight + NFC spool detection), AMS Overview, Inventory,
Printers, and Settings pages. useSpoolBuddyState reducer hook
driven by WebSocket CustomEvents.

i18n: all 6 locales (en, de, fr, it, ja, pt-BR).
2026-02-22 15:27:54 +01:00
maziggy a71e5db2bc Set up scale readings 2026-02-22 14:28:24 +01:00
maziggy c1ecd6ee91 Updated requirements.txt 2026-02-22 13:55:35 +01:00
maziggy 1260851961 Set up PN5180 NFC reader 2026-02-22 13:51:13 +01:00
maziggy 8f8ef9ea35 Updated update_website_wiki.sh 2026-02-22 12:42:07 +01:00
maziggy 9b51db2748 Changed PN5180 pinout 2026-02-22 11:24:52 +01:00
maziggy 5de9adb940 Added Spoolbuddy cabling plan 2026-02-22 10:51:43 +01:00
maziggy e450c3b728 Add visual spool grouping and optional brand/subtype in quick-add (#480)
Group toggle in inventory toolbar collapses identical unused/unassigned
spools into expandable rows/cards with count badges. Grouping key uses
material, subtype, brand, color, and label weight. Brand and subtype
fields now appear in quick-add mode as optional (no asterisk, no
validation). Quantity field restricted to quick-add mode only.
2026-02-22 10:05:03 +01:00
maziggy 7232ddb5a6 Fix finish photo not captured when archive has no source 3MF (#484)
When the 3MF source file wasn't downloaded from the printer (e.g. FTP
failure on P2S), archive.file_path was null. The finish photo capture
silently skipped because it derived the save directory from file_path.

Now falls back to archive/{id}/ directory and logs a warning.
2026-02-21 17:19:47 +01:00
maziggy 7584a2455c Fix File Manager rename not updating displayed name (#460)
The rename endpoint updated `filename` but not `file_metadata.print_name`,
which the UI uses as the primary display name. Since print_name is extracted
from the 3MF at upload, it always took precedence over the renamed filename.

Now also updates print_name in file metadata when present.
2026-02-21 16:48:42 +01:00
maziggy 257b4748e5 Fix developer mode detection always reporting null
The MQTT "fun" field is an integer in the JSON payload, but the
parser used int(value, 16) which requires a string. This raised
TypeError on every message, silently swallowed by the except clause,
so developer_mode was never set.
2026-02-21 16:18:19 +01:00
maziggy 2ed32ad1e1 Bumped version 2026-02-21 16:09:31 +01:00
maziggy 294bd74940 Fix AMS slot auto-config falling back to Generic instead of spool's slicer preset
Two bugs caused spool assignments to always configure AMS slots with
generic Bambu filament IDs (e.g. GFB99 "Generic ABS") instead of the
spool's actual slicer preset:

1. PFUS* IDs (cloud-synced custom presets) were blanket-rejected and
   replaced with generic IDs in both assign_spool and configure_ams_slot
2. Generic fallback IDs (GFB99, GFL99, etc.) were treated as "good"
   presets by the slot-reuse logic, making them sticky once set

New priority: spool's own slicer_filament > slot's non-generic preset
(same material) > generic fallback.
v0.2.1b2
2026-02-21 13:06:10 +01:00
maziggy 0e87c377e6 Add developer LAN mode detection and warning banner
Parse the MQTT "fun" field bit 0x20000000 to detect whether connected
printers have Developer LAN Mode enabled. Show a persistent orange
warning banner when any printer lacks it, since newer firmware silently
rejects MQTT write commands without developer mode.

- Parse fun field into developer_mode on PrinterState
- Add /printers/developer-mode-warnings lightweight polling endpoint
- Include developer_mode in printer status API and support bundle
- Orange banner with affected printer names and wiki link
- Translations for all 6 locales (en, de, fr, it, ja, pt-BR)
- 7 backend + 4 frontend tests
2026-02-21 12:06:16 +01:00
maziggy 055243683c Fix archive endpoints crash with "Is a directory" for BambuStudio prints (#475)
When FTP download of a 3MF fails (e.g. BambuStudio-initiated prints),
the fallback archive has file_path="". Path.exists() on
settings.base_dir / "" resolves to the base directory itself and
returns True, so ZipFile() then fails with [Errno 21] Is a directory.

Replace .exists() with .is_file() across all 15 archive route checks
and 1 in main.py. Add file_path truthiness guard for finish photo
capture to prevent saving photos under the base directory.
2026-02-21 11:35:18 +01:00
maziggy 7c5741b23c Fix wrong AMS unit displayed with dual AMS on P2S (#420)
P2S firmware sends local slot IDs (0-3) in tray_now, not global tray
IDs, when multiple AMS units are connected. The UI highlighted the
wrong AMS unit (e.g., AMS-A instead of AMS-B). Usage tracking was
unaffected because it uses the MQTT mapping field.

Added disambiguation in _handle_ams_data for single-nozzle printers
with ams_exist_bits indicating >1 AMS: cross-references tray_now with
the MQTT mapping field (snow-encoded) to resolve the correct global
tray ID. Falls back to raw value when no mapping is available or
ambiguous. No behavior change for single-AMS printers or dual-nozzle
(H2D) printers.
2026-02-21 11:07:24 +01:00
maziggy 16fa84bc16 Add bulk spool addition and stock spools
Add Quick Add mode to the spool form for simplified entry (material +
color + weight only), and a quantity field (1-100) for creating multiple
identical spools at once. Stock spools (no slicer profile) are computed
rather than stored — any spool without slicer_filament shows an amber
"Stock" badge. New filter chips (All/Stock/Configured) on the inventory
page. Backend bulk endpoint creates N spools in one transaction.

Backend:
- SpoolBulkCreate schema with quantity validation (1-100)
- POST /inventory/spools/bulk endpoint

Frontend:
- Quick Add toggle in SpoolFormModal (create mode only)
- Quantity field in FilamentSection (both modes)
- bulkCreateSpools API method and bulkCreateMutation
- Stock column (hidden by default) and stock filter chips
- Inline error rendering moved into FilamentSection
- CellCtx extended with t() for translatable cell content

Tests:
- 13 backend tests (schema validation + endpoint logic)
- 10 frontend tests (validateForm quickAdd + UI behavior)

i18n: 6 locales (en, de, fr, it, ja, pt-BR)
Docs: CHANGELOG, README, website features, wiki inventory
2026-02-21 10:39:18 +01:00
maziggy 7d46b44561 Fix PCTG filament misidentified as PC (#478) 2026-02-21 10:01:26 +01:00
maziggy e6236301b4 Fix phantom prints from lingering SD card files (#477)
Three bugs allowed uploaded gcode files to survive on the printer's SD
card, causing firmware restarts to auto-start old prints hours later.

1. The post-print cleanup retry loop always broke after attempt 1
   regardless of delete success — delete_file_async returns False on
   failure instead of raising, so the except-based retry never fired.

2. When start_print() failed after uploading, the file was never cleaned
   up since on_print_complete never fires for prints that never started.

3. Cleanup failures were logged at DEBUG level, invisible in production.
2026-02-21 09:51:42 +01:00
maziggy 608a10eabb Fix filament not deducted from backup spool after runout auto-switch (#459)
When a spool runs empty mid-print and the AMS auto-switches to a backup,
the entire print weight was attributed to the original spool. Track tray
changes during the print via tray_change_log on PrinterState, then split
the 3MF weight across trays using per-layer gcode segment boundaries at
print completion. Falls back to linear layer-ratio splitting when gcode
data is unavailable.
2026-02-21 09:30:39 +01:00
maziggy 9f06890c84 Housekeeping 2026-02-21 09:02:21 +01:00
maziggy 442059bf2a Fix finish photo 404 for prints started from BambuStudio (#474)
When a print was started from BambuStudio (not Bambuddy), the
auto-archive has an empty file_path. The photo save code uses
base_dir / Path("").parent which resolves correctly, but the
serve/upload/delete endpoints used (base_dir / "").parent which
goes one directory level too high — returning 404 despite the
photo existing on disk.
2026-02-21 08:53:41 +01:00
maziggy 6884e95103 Fix ntfy notifications failing when server disables attachments (#466)
ntfy servers with attachments disabled reject thumbnail uploads with
"attachments not allowed" (HTTP 400 / code 40014), causing the entire
notification to fail. Now automatically retries without the image so
the notification still gets delivered.
2026-02-21 08:42:54 +01:00
maziggy d7a15c79bb Filter non-actionable HMS errors from notifications (#470)
Infrastructure/auth HMS error codes like 0500_0007 (MQTT command
verification failed) triggered false-alarm printer error notifications
even though they don't indicate actual print problems.

- Add suppress list for non-actionable error codes: 0500_0007 (MQTT
  auth failure), 0500_4001 (cloud connection failure), 0500_400E
  (print cancelled by user)
- Skip suppressed codes in the notification loop so they are still
  tracked in HMS state and shown in the UI, but don't fire notifications
2026-02-21 08:36:16 +01:00
maziggy 839be41133 Fix support bundle leaking personal data (#473)
The log sanitizer only used regex patterns, missing arbitrary user-chosen
strings (printer names, usernames). Tasmota smart plug credentials were
logged verbatim in URLs by httpx.

- Make _sanitize_log_content() database-aware: query Printer names/serials,
  User usernames, and Bambu Cloud email for exact-string replacement
  (longest-first, skip <3 chars to prevent over-redaction)
- Fix serial regex leaking first 3 chars (remove capture group partial
  redaction), add case-insensitive flag
- Move Tasmota credentials from URL-embedded (http://user:pass@host) to
  httpx auth= parameter so they never appear in logs
- Add URL credentials regex as defense-in-depth for user:pass@ in logs
- Add 'username' and 'path' to settings sensitive_keys filter (catches
  smtp_username, slicer_binary_path in support-info.json)
2026-02-21 08:17:59 +01:00
maziggy 5e92bd319f Sync 2026-02-20 19:52:42 +01:00
maziggy 7c0eeed8d5 Both workflows now parse package-lock.json directly instead of trusting npm ls. The lockfile correctly marks minimatch as dev: true and doesn't contain npm/tar at all —
so all three npm-internal packages will be filtered out regardless of which npm version CI uses.
2026-02-20 19:32:07 +01:00
maziggy b7cc68122b Both workflows now parse package-lock.json directly instead of trusting npm ls. The lockfile correctly marks minimatch as dev: true and doesn't contain npm/tar at all —
so all three npm-internal packages will be filtered out regardless of which npm version CI uses.
2026-02-20 19:31:41 +01:00
maziggy baf823e51c Fix ntfy notifications failing with "Illegal header value" (#466)
When sending notifications with image attachments (progress/error
events), the message body was placed in an HTTP Message header. Messages
containing newlines (e.g. "Printer: file.stl\nRemaining: 4h 52m") were
rejected by httpx since HTTP headers cannot contain newline characters.
Escape newlines to literal \n which ntfy renders as line breaks.
2026-02-20 19:28:16 +01:00
maziggy 4991192246 Updated CI 2026-02-20 19:22:50 +01:00
maziggy fce89490f7 Updated CI 2026-02-20 19:22:32 +01:00
maziggy 802bfe330a Updated CI 2026-02-20 19:19:20 +01:00
maziggy fea89a7ece Updated CI 2026-02-20 19:18:59 +01:00
maziggy 5d48ab88f0 Updated CI 2026-02-20 19:10:56 +01:00
maziggy 63efc2281d Sync 2026-02-20 19:10:36 +01:00
maziggy 63b668f0ed Updated CI 2026-02-20 19:10:26 +01:00
KeyboredandMartinNYHC 8b081dbd9a Allow external materials/brands to be used when adding spool (#455)
* feat(spool-form): enhance brand and material selection in color section

* feat(spool-form): change input field behavoiur when deleting all chars, fix scroll menu theming

* feat(spool-form): add available materials to SpoolFormModal and FilamentSection

* refactor(ColorSection): remove unnecessary hasCatalogMatch variable

* feat(SpoolFormModal): add bilateral brand and material filtering logic

* feat(ColorCatalogSettings): improve input field sizes and layout for color and material selection

* Refactor colorCatalog settings and dependencies, allow custom materials, fix ml-12 marging, show catalog colors on brand/material selection

* Refactor ColorCatalogSettings and ColorSection components; remove  onBlur logic in FilamentSection

* Prioritize exact matches in search results

* Added inventory.useCustomMaterial to locales

* Remove unused filteredCatalogColors logic and update button rendering; update types file to import Printer and SpoolKProfile

* Fix indentation for useCustomMaterial

* Refactor showCatalogSection logic to only depend on matched catalog colors

* Remove extra newline before brand dropdown

* Clean up ColorSection.tsx by removing blank lines

Removed unnecessary blank lines in ColorSection.tsx.

* Ensure material property is a string in ColorSection component

---------

Co-authored-by: MartinNYHC <mz@v8w.de>
2026-02-20 18:34:24 +01:00
maziggy 2c0d1c2fe6 Updated CI 2026-02-20 18:29:50 +01:00
maziggy 6ab48fa338 Updated CI 2026-02-20 18:28:34 +01:00
maziggy 1404242e0c Fix cost tracking issues 2026-02-20 16:31:16 +01:00
MartinNYHC 965000c3ca Merge branch '0.2.1b2' into feature/cost_tracker 2026-02-20 16:26:01 +01:00
Wesley Reuel Marques SilvaandMartinNYHC ceb2de7164 Adding the energy cost from 2 to 3 decimal precision (#416)
* Adding the energy cost from 2 to 3 decimal precision

* Complying with pr

* Complying with PR

* Complying with PR

* Fix energy cost display precision in ProjectDetailPage

* Change energy cost formatting to two decimal places

* Change decimal precision for energy cost display

---------

Co-authored-by: MartinNYHC <mz@v8w.de>
2026-02-20 16:23:00 +01:00
Keybored 85645ce184 Merge branch '0.2.1b2' into feature/cost_tracker 2026-02-20 15:44:34 +01:00
maziggy 57920d116a Changed SECURITY.md 2026-02-20 15:28:47 +01:00
maziggy 40403ae584 Fix inventory date format and AMS-HT slot labels (#463)
Two bugs in the inventory page:

1. Dates always displayed as DD/MM/YY regardless of the user's date
   format setting. The page had a local formatDate() hardcoding en-GB
   locale. Replaced with the shared formatDateOnly() from utils/date.ts.

2. AMS-HT slot locations showed accented characters (e.g., "Á1") instead
   of proper labels (e.g., "HT-A"). The code used String.fromCharCode(65
   + ams_id), which produces garbled chars for AMS-HT IDs (128+). Now
   uses the shared formatSlotLabel() from utils/amsHelpers.ts.
2026-02-20 15:22:44 +01:00
Matteo Parenti 53c826d1d1 Add integration tests for cost tracking with archive_id and print_name fallback; implement cleanup fixtures for temporary files 2026-02-20 14:35:06 +01:00
maziggy b22f091dd0 Fix SD card cleanup silently failing after print completion (#374)
The post-print SD card cleanup used printer_manager.get_printer(),
which returns a PrinterInfo object with only name and serial_number.
The code then accessed .ip_address, .access_code, and .model, which
don't exist on PrinterInfo — raising AttributeError on every print
completion. The outer except Exception handler silently swallowed it
at debug level.

Result: uploaded gcode files were never deleted from the printer's
SD card root. On some printers (e.g. P1S), files left in root
auto-start on power cycle, causing phantom prints.

Replaced with a DB query for the Printer model, matching the pattern
used everywhere else in on_print_complete().
2026-02-20 14:30:26 +01:00
maziggy 732ab8cb6d Fix "Any Model" queue jobs stuck in "Waiting" after plate clear (#435)
MQTT raw data returns AMS unit and tray IDs as strings (e.g. "0"),
but _build_loaded_filaments() compared them to integers without
casting. After the scheduler assigned an idle printer to an "Any
Model" job, it crashed computing AMS mapping with:

  '>=' not supported between instances of 'str' and 'int'

The exception prevented the assignment from committing, so the
scheduler retried every 30 seconds in an infinite loop. The job
stayed in "Waiting" and the "Clear Plate" button kept reappearing.

Cast ams_id and tray_id to int(), matching the pattern already used
for external spool IDs on line 550.
2026-02-20 14:22:09 +01:00
maziggy 3f201594f1 Fix spool usage lost when spool runs empty mid-print (#459)
When a spool ran empty during a print and the AMS auto-switched to a
backup, on_ams_change eagerly deleted the SpoolAssignment (fingerprint
mismatch). on_print_complete then queried the now-deleted assignment
and silently dropped usage.

Snapshot all spool assignments into PrintSession at print start. At
completion, prefer the snapshot over live DB queries in both the 3MF
primary path and the AMS remain% delta fallback. Fall back to live
query for backward compatibility with in-flight sessions started
before upgrade.
2026-02-20 14:08:35 +01:00
Matteo Parenti 427b08f9f6 Add archive_id to SpoolUsageHistory model and update cost calculations in usage_tracker 2026-02-20 13:39:41 +01:00