Commit Graph
1763 Commits
Author SHA1 Message Date
maziggy 63a905daf2 Bumped version 2026-03-16 12:46:25 +01:00
maziggy b889de91ba Allow spool assignment to empty AMS slots and fix profile label (#717)
Previously the "Assign Spool" button only appeared on configured slots,
  forcing users to manually configure first — redundant since assignment
  auto-configures the slot. Now shows on empty slots too. Also fixed the
  AMS hover card showing generic material type instead of the spool's
  slicer preset name after assignment.
2026-03-16 09:24:04 +01:00
maziggy a388ab791f Deleted broken install/start_bambuddy.bat 2026-03-15 16:50:49 +01:00
maziggy d9049e65b1 Updated CONTRIBUTING.md 2026-03-15 16:02:43 +01:00
maziggy fa6edfbcde Fix stored XSS vulnerabilities and unauthenticated auth toggle
- Sanitize project notes with DOMPurify before rendering via
    dangerouslySetInnerHTML (ProjectDetailPage.tsx)
  - Replace hand-rolled HTML sanitizer with DOMPurify in ProjectPageModal
    to prevent attribute injection via crafted 3MF href values
  - Block /api/v1/auth/setup when auth is already enabled to prevent
    unauthenticated clients from disabling authentication remotely
2026-03-15 15:31:49 +01:00
maziggy 0feed83ce4 Fix P2S camera TLS compatibility via OpenSSL proxy (#661)
The Debian ffmpeg package uses GnuTLS, whose hardened defaults reject
  TLS renegotiation and legacy ciphers that some Bambu printer firmwares
  (notably P2S) rely on — causing RTSP sessions to drop after a few
  seconds.

  Add a local TLS termination proxy (Python ssl/OpenSSL) that handles
  the TLS connection to the printer and exposes a plain RTSP port to
  ffmpeg. The proxy rewrites RTSP request-line URLs (rtsp://proxy →
  rtsps://printer) while preserving Authorization headers so Digest
  auth hashes remain valid.

  Also:
  - Reduce RTSP reconnect delay from 1.0s to 0.2s
  - Add ffmpeg fast-start flags (-probesize 32, -analyzeduration 0,
    -fflags nobuffer, -flags low_delay)
  - Fix external camera double rate-limiting causing choppy streams
  - Apply TLS proxy to external camera rtsps:// URLs and snapshot capture
  - Update orphan ffmpeg cleanup to match rtsp:// (proxied) URLs
  - Add unit tests for RTSP URL rewriting and proxy lifecycle
2026-03-15 11:52:32 +01:00
maziggy c5791e0b54 Fix spool assignment applying wrong filament profile (#681)
The Bambu Cloud API returns the base filament_id for versioned
  setting IDs (e.g. GFSL99 → GFL99 for all "Generic PLA" variants),
  so assigning a spool with a specific variant like "Generic PLA Silk"
  (GFSL99_01) would configure the AMS slot with the base "Generic PLA"
  profile (GFL99) instead of the correct one (GFL96).

  Added a post-resolution cross-check: if the resolved filament_id maps
  to a different name than the spool's stored preset name, reverse-lookup
  the correct filament_id from the built-in filament table.
2026-03-15 09:54:57 +01:00
Dakota G c52505cd3a [Fix]: Ensures AMS-HT devices are properly identified in Spoolman (#711)
[Fix]: Ensures AMS-HT devices are properly identified in Spoolman (#711)
2026-03-15 09:28:30 +01:00
maziggy bbc5ccb982 Library Upload Doesn't Show New File Until Page Reload ([#704](https://github.com/maziggy/bambuddy/issues/704)) — After uploading a file in the Library file manager, the file list didn't update until the user reloaded the browser. The upload endpoint used db.flush() instead of db.commit(), so the new row was only written to the database *after* the response was sent to the client. The frontend immediately refetched the file list upon receiving the response, but a new database session couldn't see the uncommitted row — resulting in stale data. Fixed by committing before the response is returned. Also fixed the same race condition in folder create, folder update, and file update endpoints. Reported by @shadowjig.
Printer File Manager Doesn't Auto-Refresh ([#704](https://github.com/maziggy/bambuddy/issues/704)) — The printer file manager (SD card browser) only fetched the file list once when opened. Files uploaded from BambuStudio/OrcaSlicer while the modal was open wouldn't appear until the user clicked the refresh button or reopened the modal. Now auto-refreshes every 30 seconds while open. Reported by @shadowjig.

Database Connection Pool Exhaustion Under Load ([#704](https://github.com/maziggy/bambuddy/issues/704)) — Background tasks (print scheduler FTP uploads, camera captures, notification sends, timelapse stitching) held database sessions open during slow network I/O, consuming connection pool slots for seconds at a time. With the default pool of 15 connections (size 5 + overflow 10), concurrent operations during print start/complete events could exhaust the pool, causing `QueuePool limit reached` errors and `greenlet_spawn` failures in RFID spool auto-assignment. Doubled the pool to 30 connections (size 10 + overflow 20). Reported by @shadowjig.
2026-03-15 09:15:18 +01:00
Dakota G 30b34bc255 [Fix]: Changes SMTP testing to use saved settings in the database (#710)
[Fix]: Changes SMTP testing to use saved settings in the database (#710)
2026-03-15 09:13:47 +01:00
maziggy 79f4a62308 Redact printer access codes from support bundle logs
RTSP stream URLs (rtsps://bblp:<code>@<ip>:322/...) were not covered
  by the credential sanitizer, leaking access codes in support bundles
  and bug report logs. Extended the URL regex to match rtsps:// and added
  access codes to the sensitive string collection for exact-match
  redaction in both export paths.
2026-03-15 08:42:17 +01:00
maziggy 5a8aa61f44 Bump PyJWT >=2.12.0 (CVE-2026-32597) and flatted >=3.4.0
PyJWT: fixes auth token handling vulnerability (direct dependency).
  flatted: fixes unbounded recursion DoS in parse() (transitive, ESLint only).
v0.2.2b4-daily.20260314
2026-03-14 15:47:25 +01:00
maziggy 14855ba8f4 Add ambient drying mode and fix block mode humidity auto-stop (#292)
Ambient drying: automatically dry filament on idle printers when
  humidity exceeds threshold, regardless of queue state. Separate toggle
  from queue auto-drying — both can run simultaneously. Uses the same
  presets, humidity threshold, and power constraint detection.

  Fix: block mode (wait for drying) previously skipped the humidity
  auto-stop check for already-drying printers, causing drying to
  continue indefinitely. Now only prevents starting new drying.
2026-03-14 15:06:07 +01:00
maziggy cffba4a911 Add queue auto-drying, configurable drying presets, and AMS PSU detection (#292)
Queue auto-drying: scheduler automatically starts drying on idle printers
  with scheduled queue prints when AMS humidity exceeds the configured
  threshold. Uses conservative parameters (lowest temp, longest duration)
  for mixed filaments. Drying stops when humidity drops below threshold
  (30-minute minimum prevents oscillation), when scheduled items are
  removed, or when the feature is disabled. Optional "block queue" mode
  delays the next print until drying completes.

  Configurable presets: temperature and duration per filament type,
  editable in Settings → Print Queue, used by both manual drying popover
  and queue auto-drying. Separate presets for AMS 2 Pro (n3f) and AMS-HT
  (n3s) reflecting different heating capabilities.

  PSU detection: drying button disabled with tooltip when dry_sf_reason
  indicates insufficient power. Parses drying status bits and dry_sf_reason
  from AMS info hex string via MQTT.

  Backend: print_scheduler.py (+316 lines), bambu_mqtt.py, printer_manager,
  schemas, settings route. Frontend: PrintersPage drying presets prop,
  SettingsPage drying config UI, i18n (7 locales). Tests: 27 new tests in
  test_scheduler_auto_drying.py covering conservative params, presets,
  state sync, stop logic, minimum drying time, and auto-stop regressions.
2026-03-14 14:21:36 +01:00
maziggy 97d8108ba6 Updated .github/ISSUE_TEMPLATE/bug_report.yml 2026-03-14 12:10:46 +01:00
maziggy 658ac3de6a Housekeeping 2026-03-14 12:09:36 +01:00
Dakota G 47afcec1c5 [Fix]: Allow SMTP to be configured before Advanced Authentication is enabled (#700)
[Fix]: Allow SMTP to be configured before Advanced Authentication is enabled (#700)
2026-03-14 11:34:34 +01:00
maziggy 9f93c04f6f Revert " Camera P2S + snapshot fix (#661):"
This reverts commit 7ea78a2969.
2026-03-14 10:33:21 +01:00
maziggy 7ea78a2969 Camera P2S + snapshot fix (#661):
Fix P2S camera stream dropping and snapshot capture race (#661)

  P2S firmware's TLS renegotiation is rejected by Debian's hardened GnuTLS
  defaults, causing ffmpeg RTSP sessions to drop after ~3 seconds. Add
  GnuTLS config allowing unsafe renegotiation and legacy ciphers. Also add
  ffmpeg fast-start flags, reduce reconnect delay from 1.0s to 0.2s,
  remove double rate-limiting on external camera streams, and fix orphan
  cleanup killing snapshot capture ffmpeg processes (exit code -9).

  Or as a single combined commit:
  Fix P2S camera streaming, snapshot race, and energy stats (#661, #695)

  Camera: P2S firmware's TLS renegotiation rejected by Debian's hardened
  GnuTLS defaults, dropping RTSP sessions after ~3s. Add GnuTLS compat
  config, ffmpeg fast-start flags, reduce reconnect delay to 0.2s, remove
  external camera double rate-limiting, and register snapshot ffmpeg PIDs
  with the orphan tracker to prevent SIGKILL during capture.
2026-03-14 10:31:46 +01:00
maziggy d8770b2bce Fix energy costs not updating per timeframe in statistics (#695)
In "total" energy tracking mode, the stats endpoint queried smart plug
  lifetime counters which can't be filtered by date range. Energy costs
  and kWh stayed the same regardless of timeframe selection. Fall back to
  per-print archive data when date filters are active.
2026-03-14 10:18:27 +01:00
maziggy 95625aa860 Fix daily build tags falsely triggering update notification
parse_version() misclassified "0.2.2b4-daily.20260313" as a release
  because the daily suffix made the last dot-segment ("20260313") contain
  no alpha chars, bypassing prerelease detection. Strip -daily.YYYYMMDD
  suffix before parsing so daily builds compare as their base beta version.
2026-03-13 16:16:28 +01:00
maziggy c2cf041af2 Update CI Node.js version from 20 to 22 LTS
Node 20 is being deprecated on GitHub Actions runners.
  Bump to Node 22 (Active LTS) in ci.yml and security.yml.
2026-03-13 15:34:22 +01:00
maziggy 4db87505c7 Housekeeping v0.2.2b4-daily.20260313 2026-03-13 14:35:25 +01:00
maziggy 81db4eabaf Fix smart_plugs UNIQUE constraint migration not firing on some databases (#689)
The migration that removes the UNIQUE constraint on smart_plugs.printer_id
  used an exact substring match ("printer_id INTEGER UNIQUE") to detect the
  constraint. Databases created with older SQLAlchemy versions may express
  the constraint differently (quoted column names, table-level UNIQUE clause,
  or separate UNIQUE indexes), causing the migration to silently skip.

  Users hit "IntegrityError: UNIQUE constraint failed: smart_plugs.printer_id"
  when assigning a second HA switch to a printer.

  Replace the exact string match with regex pattern matching that handles
  inline constraints, table-level UNIQUE(printer_id), quoted column names,
  and standalone UNIQUE indexes.
2026-03-13 13:36:47 +01:00
maziggy e314305623 Fix HMS notifications firing for unknown/phantom error codes
Printers send many undocumented HMS codes (e.g. 0501_0002, 0501_0004,
  0300_0001) that don't correspond to real errors — calibration status,
  firmware state, etc. The frontend already filters these out (only shows
  codes in ERROR_DESCRIPTIONS), but the backend notified for all codes
  with severity >= 2, causing spurious email/push notifications on every
  backend restart when a printer has active phantom codes.

  Flip the logic: only send notifications for HMS codes with a known
  description in the backend's HMS_ERROR_DESCRIPTIONS dictionary. Also
  fix the log message to report the actual number of notifications sent,
  not the pre-filter count.
2026-03-13 13:23:01 +01:00
maziggy ecc9ec11f1 Fix HA switch badge toggle and multi-plug crash
Non-script HA entities (switch/light/input_boolean) on the printer card
  always sent turn_on when clicked, which is a no-op when the switch is
  already on. Now sends toggle for non-script entities so the badge click
  actually changes the switch state. Script entities still use turn_on.

  Also fix SmartPlugManager._get_plug_for_printer() using
  scalar_one_or_none() which crashes with MultipleResultsFound when
  multiple plugs are assigned to the same printer (e.g., Tasmota + HA
  switch). Now fetches all plugs and returns the main non-script plug.

  Add tests for both fixes: _get_plug_for_printer multi-plug handling
  (5 tests) and canonicalFilamentType/filamentTypesCompatible/autoMatch
  PA-CF equivalence (8 tests).
2026-03-13 13:11:12 +01:00
maziggy 5a4a2260b1 Fix PA-CF/PA12-CF/PAHT-CF type matching and force color match click target (#688)
Bambu Lab firmware treats PA-CF, PA12-CF, and PAHT-CF as interchangeable,
  but the print scheduler and filament override UI used exact string matching.
  A 3MF requiring PA-CF wouldn't match PA12-CF in the AMS, leaving the
  override dropdown disabled and preventing scheduler assignment.

  Add a filament type equivalence system (both backend and frontend) so
  these PA variants are treated as compatible in scheduler assignment,
  AMS slot matching, force color match validation, and the override dropdown.

  Also fix the "Force color match" checkbox click target being too wide
  (entire row instead of just the checkbox/label) by changing flex to
  inline-flex on the label element.
2026-03-13 12:56:31 +01:00
maziggy cfec18eca4 Fix floating camera drag/resize not working on iOS/iPadOS (#687)
The embedded camera viewer only handled mouse events (mousedown,
  mousemove, mouseup) for window dragging and resizing. On iOS/iPadOS,
  touch input doesn't trigger mouse events, so the camera window
  couldn't be repositioned — touch just scrolled the page underneath.

  Add touch event handlers (touchstart, touchmove, touchend, touchcancel)
  alongside mouse handlers for both the header drag handle and the
  bottom-right resize handle. Uses preventDefault on touchmove to
  prevent page scrolling during drag.
2026-03-13 12:44:51 +01:00
maziggy 220717f174 Fix inventory usage tracker missing external spool mapping (#677)
When all higher-priority slot-to-tray mapping methods failed (MQTT
  mapping, print command mapping, queue mapping, color matching), the
  internal usage tracker fell back to slot_id - 1 which can never reach
  external spool IDs (254/255) or AMS-HT IDs (128+). Added position-based
  resolution using sorted available tray IDs, matching the Spoolman fix
  from PR #686.
2026-03-13 12:08:11 +01:00
Dakota G fb29eb4cd7 [Fix]: Properly track filament usage data in Spoolman (#686)
Properly track filament usage data in Spoolman#686
2026-03-13 11:59:44 +01:00
maziggy adb0500e67 Fix AMS fill level showing 0% for non-Viewer users (#676)
When inventory spool assignments had stale weight_used values, the fill
  level fallback chain (Spoolman → Inventory → AMS remain) used nullish
  coalescing (??), which doesn't fall through on 0. A stale inventory
  fill of 0% permanently shadowed the correct real-time AMS remain value.
  Viewer users were unaffected because their group lacked the
  inventory:view_assignments permission, so the query never fired.

  Now when inventory says 0% but AMS hardware reports positive remain,
  the inventory value is bypassed in favor of the live AMS data.
2026-03-13 11:21:37 +01:00
maziggy 0b6facc91c Add first layer complete notification with camera snapshot (#679)
Notify users when the first layer finishes printing so they can check
  adhesion remotely. Triggers once per print when layer 2 begins
  (layer_num >= 2, capped at <= 5 to handle reconnects). Includes a
  camera snapshot attachment. Adds the on_first_layer_complete toggle
  to all notification providers, with backend/frontend/i18n support
  across all 7 locales.
2026-03-13 10:53:21 +01:00
maziggy 685d04df67 Fix virtual printer proxy mode always defaulting to X1C model
When creating a virtual printer in proxy mode, the model was always set
  to X1C because the frontend hides the model dropdown and the backend
  used a hardcoded default. Now auto-inherits the model from the target
  printer in proxy mode — on create, on target printer change, and on
  mode switch to proxy.
2026-03-13 10:21:46 +01:00
maziggy f21e502b8f Add remote AMS drying controls (#292)
Start, monitor, and stop drying sessions for AMS 2 Pro (n3f) and
  AMS-HT (n3s) directly from the Printers page. Flame icon in AMS card
  header opens a popover with filament-based temperature/duration presets
  from BambuStudio. Live countdown status bar shows time remaining.

  Backend: cache module_type from MQTT get_version, expose dry_time and
  module_type in both WebSocket and REST paths, add supports_drying()
  with firmware gating, add server-side guard on start_drying endpoint.

  Frontend: drying button, popover with filament select + temp/duration
  sliders, status bar, start/stop mutations. i18n for all 7 locales.

  Supported: X1/X1C (fw 01.09+), P1P/P1S (fw 01.08+), H2D (fw 01.02.30+),
  H2D Pro, X1E. Not supported: P2S, A1, A1 Mini, H2S, H2C.
v0.2.2b3-daily.20260312
2026-03-12 16:46:10 +01:00
maziggy f1eb375964 Fix cloud profiles shared across all users (#665)
Cloud credentials were stored globally — one Bambu Cloud account per
  Bambuddy instance. When auth was enabled, any user logging into Cloud
  overwrote everyone else's credentials. Credentials are now stored
  per-user: each user gets their own independent Cloud login.

  Also fixed cloud data endpoints (settings, fields, preset CRUD)
  requiring settings:read/settings:update permissions instead of
  cloud:auth — users who had "Cloud Auth" enabled but "Settings"
  disabled couldn't load profiles after logging in.
2026-03-12 13:02:13 +01:00
maziggy 3aa1382987 Fix P2S camera stream disconnecting after a few seconds (#661)
The P2S firmware drops RTSP sessions after a few seconds with an I/O
  error. The backend treated this as fatal, ending the MJPEG stream and
  forcing the frontend through a full reconnection cycle. Added transparent
  auto-reconnection: when ffmpeg's RTSP connection dies, it respawns
  immediately and continues streaming MJPEG frames to the browser with
  only a brief freeze (~1s). Up to 30 reconnections before giving up.
2026-03-12 11:34:27 +01:00
maziggy 3452f70726 Fix interface aliases not shown in virtual printer interface select
The Docker image (python:3.13-slim) didn't include iproute2, so the
  `ip` command wasn't available. The code fell back to ioctl-based
  enumeration which can only return one IP per interface — aliases like
  eth0:1 were completely invisible. Added iproute2 to the Dockerfile.
2026-03-12 11:16:12 +01:00
maziggy fea6350462 Housekeeping 2026-03-12 10:50:18 +01:00
maziggy add4c0ef5a Fix local profiles not shown in AMS slot configuration
The compatible_printers filter on local presets parsed the stored JSON
  array (e.g. '["BBL X1C 0.4 nozzle"]') as a semicolon-delimited string,
  so matching always failed and every local preset was silently skipped.
  Removed the filter entirely — user-imported profiles should be usable
  on any printer.
2026-03-11 15:33:46 +01:00
maziggy 374895f959 Fix ethernet badge false positive and MQTT thread crash (#585)
Three bugs: (1) home_flag bit 18 is set on all printers regardless
    of connection type, so every ethernet-capable model showed the badge
    even on WiFi. Replaced with wifi_signal heuristic — ethernet printers
    with WiFi disabled report a hardcoded -90 dBm sentinel. (2) The lazy
    import used `from app.utils.printer_models` which crashes with
    ModuleNotFoundError in paho-mqtt's background thread (correct path:
    backend.app.utils.printer_models). This killed the thread, causing
    all printers to go stale after 60s and disconnect/reconnect in a
    loop. (3) WiFi-only models excluded via model-based gating.
2026-03-11 14:35:05 +01:00
maziggy 42eab0354d Bumped version 2026-03-11 13:26:16 +01:00
maziggy 26a3b2172d Fix ethernet badge shown on WiFi-only printers (#585)
home_flag bit 18 is set on all printers regardless of hardware,
    causing the ethernet badge to appear on WiFi-only models (A1, P1P,
    etc.). The previous fix removed the feature entirely, so ethernet
    printers lost their badge too.

    Now only trusts bit 18 on models with an ethernet port (X1C, X1E,
    P1S, P2S, H2D, H2D Pro, H2C, H2S). WiFi-only models always show
    the WiFi signal badge.
2026-03-11 12:56:23 +01:00
maziggy 1ad44cd41f Updated docker-publish-daily-beta.sh 2026-03-11 11:01:19 +01:00
maziggy 7eb82f58fa Updated CHANGELOG 2026-03-11 10:13:35 +01:00
maziggy c873b74fe6 Merge branch '0.2.2b3' into 0.2.3b1 2026-03-11 10:05:02 +01:00
maziggy d374e5f70b Fix debug logging endpoint 500 error after version upgrade
The GET /api/v1/support/debug-logging endpoint returned 500 when the
  database contained a timezone-aware enabled_at timestamp written by
  0.2.2b3. The duration calculation mixed offset-aware and offset-naive
  datetimes, raising TypeError. Strip tzinfo when reading the stored value.
2026-03-11 09:58:51 +01:00
maziggy f4758e4464 Add Home Assistant as notification provider (#656)
Sends persistent notifications to the HA dashboard using the existing
  HA connection from Settings. Zero config — just select "Home Assistant"
  as provider type. Users can forward notifications to mobile via HA
  automations.
2026-03-11 09:58:17 +01:00
maziggy 3788dd723c Added debug logging for ffmpeg process 2026-03-11 09:57:55 +01:00
maziggy f69b0413f0 Fix bed cooled notification never firing (#497)
Two bugs prevented bed cooldown notifications from working:

  1. Stale temperature data: After print completion, the printer sends
     partial MQTT updates without bed_temper, leaving the cached value
     frozen at the end-of-print temperature. The monitor polled for 30
     minutes seeing the stale value above threshold, then timed out.
     Fix: send periodic pushall commands to force fresh temperature data.

  2. Missing fields in provider create endpoint: on_bed_cooled and all 7
     queue event toggles were omitted from the NotificationProvider
     constructor, silently discarding user selections on create (update
     worked fine via dynamic setattr).

  Also added debug logging to the bed cooldown polling loop.
2026-03-11 09:57:55 +01:00
maziggy 1402293072 Updated README 2026-03-11 09:57:55 +01:00