Commit Graph
1515 Commits
Author SHA1 Message Date
maziggy 90b9523998 Updated commit message (now includes the test fix):
Fix camera button permissions & ffmpeg process leak (#550)

  Camera button on printer card was clickable without camera:view
  permission. ffmpeg processes (~240MB each) accumulated after closing
  camera streams because: (1) stop endpoint called terminate() without
  wait()/kill(), (2) HTTP disconnect detection only ran between frames
  so was blocked when the generator was stuck on stdout read, and
  (3) no mechanism caught processes orphaned by generator abandonment
  or app restarts.

  - Add camera:view permission check + tooltip to camera button
  - Fix stop endpoint: terminate() → wait(2s) → kill() → wait()
  - Add background disconnect monitor (polls every 2s, kills ffmpeg
    directly on disconnect)
  - Add periodic /proc scan (every 60s) that SIGKILLs any ffmpeg
    with rtsps://bblp: not in an active stream
  - Add noCamera i18n key to all 6 locales
  - Fix camera API test mocks for async wait() and pid attribute
2026-02-28 14:38:45 +01:00
maziggy 240eeb4f5d Add H2C dual nozzle variant O1C2 model support (#489)
The H2C dual nozzle variant reports model code O1C2 via MQTT, but only
  O1C was recognized. This caused the camera to use the wrong protocol
  (chamber image on port 6000 instead of RTSP on port 322), producing a
  reconnect loop. Added O1C2 to all model ID maps across 8 files.
2026-02-28 14:38:11 +01:00
maziggy 5df2b82673 Fix A1 Mini "unknown" status from non-UTF-8 MQTT payload (#549)
Some firmware versions send MQTT payloads with non-UTF-8 bytes.
  UnicodeDecodeError was uncaught, silently dropping the entire message
  and leaving printer status as "unknown" with 0°C temps and no AMS.

  Fall back to decode(errors="replace") to keep JSON parseable.
2026-02-28 14:36:56 +01:00
maziggy abd20056ae Fix Windows install syntax error from LF line endings (#544)
The start_bambuddy.bat launcher had Unix (LF) line endings. When a
user's git is configured with core.autocrlf=false or input, the file
is checked out with LF endings and cmd.exe fails with "the syntax of
the command is incorrect" before reaching the hash check.

Add .gitattributes forcing CRLF for *.bat files so they always get
correct line endings on checkout regardless of git config.
2026-02-28 14:36:25 +01:00
maziggy d3bae07edf Fix queue badge showing on printers without matching filament (#486)
The purple queue counter badge in the printer card header used the raw
unfiltered queue item count, so it appeared on ALL printers of the same
model when a job was scheduled for "any [model]" — even printers without
the matching filament color. The PrinterQueueWidget below it (which
shows "Clear Plate & Start") already filtered by filament type + color.

Apply the same filament compatibility filter (type check + color override
check) to the badge count so it only shows on printers that can actually
run the queued jobs.
2026-02-28 14:36:12 +01:00
maziggy b1cc3462ed Fix naive-vs-aware datetime crash from 0.2.1 timezone migration
The timezone fix (ed36eaf) replaced datetime.utcnow() with
datetime.now(timezone.utc) across ~80 call sites, but SQLAlchemy's
SQLite DateTime columns strip tzinfo on read, returning naive datetimes.
Any Python-side comparison (subtraction, <, >) between an aware "now"
and a naive DB value raises TypeError.

Add `if value.tzinfo is None: value = value.replace(tzinfo=timezone.utc)`
guards at all 9 affected comparison sites:
- maintenance.py: last_performed_at subtraction (2 code paths — days-based
  and hours-based intervals both crashed on /maintenance/overview)
- auth.py: API key expires_at check (2 locations)
- print_scheduler.py: scheduled_time comparison
- smart_plug_manager.py: auto_off_pending_since elapsed calc
- smart_plugs.py: power_alert_last_triggered cooldown
- main.py: last_runtime_update elapsed calc
- archives.py: timelapse completed_at fallback
2026-02-28 14:35:02 +01:00
maziggy 233e84c03a Fix naive-vs-aware datetime crash from 0.2.1 timezone migration
The timezone fix (ed36eaf) replaced datetime.utcnow() with
datetime.now(timezone.utc) across ~80 call sites, but SQLAlchemy's
SQLite DateTime columns strip tzinfo on read, returning naive datetimes.
Any Python-side comparison (subtraction, <, >) between an aware "now"
and a naive DB value raises TypeError.

Add `if value.tzinfo is None: value = value.replace(tzinfo=timezone.utc)`
guards at all 8 affected comparison sites:
- maintenance.py: last_performed_at subtraction (500 on /maintenance/overview)
- auth.py: API key expires_at check (2 locations)
- print_scheduler.py: scheduled_time comparison
- smart_plug_manager.py: auto_off_pending_since elapsed calc
- smart_plugs.py: power_alert_last_triggered cooldown
- main.py: last_runtime_update elapsed calc
- archives.py: timelapse completed_at fallback
2026-02-28 14:34:55 +01:00
maziggy 105beb0929 Updated CI 2026-02-28 14:34:46 +01:00
maziggy f8b2ebd695 Added # nosec B108 suppressions for virtual printer tests 2026-02-27 10:41:38 +01:00
MartinNYHC e8c0bae7c8 Merge branch 'main' into 0.2.1 2026-02-27 10:36:44 +01:00
maziggy 5cdeb4207c Updated CHANGELOG 2026-02-27 10:28:55 +01:00
maziggy d91d95a1ec Fix FTP proxy port 990 permission denied in Docker
cap_add: NET_BIND_SERVICE in docker-compose.yml doesn't reliably
propagate to the Python process when combined with the user: directive
(depends on ambient capability support in the container runtime).
Set the file capability directly on the Python binary via setcap in
the Dockerfile, which the kernel honors regardless of runtime config.
2026-02-27 10:25:48 +01:00
maziggy 55c332d91a Housekeeping 2026-02-27 10:05:03 +01:00
maziggy 6e2788517c Updated test_backend.sh 2026-02-27 09:48:31 +01:00
maziggy 94d0f55e1c Fix AMS history chart showing wrong time range (#535)
The chart X axis used dataMin/dataMax domain, compressing the view to
only the data present. A 6h view with 1.5h of data looked like 1.5h.
Pin the X axis to the full selected time range, pad data edges so the
line extends to both ends, and connect through nulls for a continuous
line.
2026-02-27 08:44:24 +01:00
maziggy ad6108c8a7 Fix "Clear Plate" button shown on printers without matching filament color (#486)
When a print was queued to "any printer" with a filament color override
(e.g., white PETG), the "Clear Plate & Start Next" button appeared on
printers that had the right type but wrong color. The backend scheduler
already rejected color mismatches, but the frontend only checked filament
types. Now passes loaded type+color pairs from AMS status to the widget
and filters against filament_overrides, mirroring the backend's
_count_override_color_matches() logic.
2026-02-27 08:03:21 +01:00
maziggy 2c8fbf3e33 Fix queue empty after restart by checkpointing WAL on shutdown (#523)
The SQLite WAL was never checkpointed during container shutdown, leaving
uncommitted data (including schema migrations) in the -wal file. On
restart, partial WAL recovery could cause inconsistent query results,
making the queue appear empty until a filter was applied. Add
PRAGMA wal_checkpoint(TRUNCATE) and engine.dispose() to the lifespan
shutdown handler.
2026-02-27 07:41:03 +01:00
maziggy 4f5a9f4b95 Fix spool form profile dropdown truncating long preset names (#534)
Long filament profile names were cut off because inline filament ID
codes consumed horizontal space in the dropdown. Remove the codes from
dropdown items (selected code still shown below the input) and widen
the modal from max-w-lg to max-w-xl.
2026-02-27 07:30:03 +01:00
maziggy 2284a76381 Fix VP queue mode missing AMS mapping for printer-specific items (#529)
The print scheduler had two code paths for queue items: model-based
(target_model set) and printer-specific (printer_id set). Only the
model-based path computed ams_mapping before starting the print. VP
queue items assigned to a specific printer went through the
printer-specific path with null ams_mapping, causing the printer to
default to the first AMS slot regardless of what the 3MF required.

Add _compute_ams_mapping_for_printer() call to the printer-specific
path, matching the existing model-based behavior.
2026-02-27 07:24:59 +01:00
maziggy a6d326f8fa Fix VP queue mode sending wrong plate_id → HMS 0500_4003 (#529)
When a virtual printer auto-queued a file, PrintQueueItem was created
without plate_id. The scheduler defaulted to plate_id=1, generating
MQTT path "Metadata/plate_1.gcode". For multi-plate 3MF files sliced
on a different plate, the printer couldn't find the gcode and returned
HMS error 0500_4003. Extract plate index from the 3MF's slice_info.config
before creating the queue item.
2026-02-26 10:00:33 +01:00
maziggy f4f09ccc2d Hide unnecessary target model selector on "Any" tab (#528)
When scheduling a print to "Any {model}", a redundant "Target Model"
dropdown appeared even though the G-code is already sliced for a
specific printer model. Changing it would lead to print failures.

Hide the dropdown when slicedForModel is known — the tab label already
communicates the target. The dropdown still appears as a fallback for
legacy files without model metadata.
2026-02-26 09:13:06 +01:00
maziggy 20c291d678 Fix "Clear Plate & Next" shown on printers without correct filament (#527)
The "Clear Plate & Start Next" button appeared on ALL printers of a
model when a job was queued via "Queue to Any X", even printers without
the required filament loaded. Clicking it started a print that fails.

PrinterQueueWidget now filters queue items by filament compatibility —
each item's required_filament_types must all be present in the printer's
loaded filaments (AMS + external spools). If no compatible items exist,
the widget is hidden entirely. Matching is type-only (not color) and
case-insensitive, consistent with the backend scheduler. When filament
data is unavailable, no filtering is applied (graceful degradation).
2026-02-26 08:57:39 +01:00
maziggy 37d9b4c841 Fix manual spool weight overwritten by AMS auto-sync (#525)
Add weight_locked flag to spools that auto-sets when weight_used is
explicitly updated via the API. Both the MQTT AMS remain% auto-sync and
the manual force-sync endpoint skip locked spools. Usage tracker delta
tracking is unaffected. Users can re-enable AMS sync by setting
weight_locked to false.
2026-02-26 08:42:19 +01:00
maziggy fa87e24968 Add print metadata to queue API response (#524)
Queue endpoints now return filament_type, filament_color, layer_height,
nozzle_diameter, and sliced_for_model from the archive or library file.
Previously this data was only available via the archive API.
2026-02-26 08:15:38 +01:00
maziggy 1973a5bead Fix virtual printer queue mode not assigning printer (#518), settings text fields resetting mid-typing
Virtual printer "print_queue" mode created queue items with no printer
assignment. Now sets target_model from the VP's SSDP model code (e.g.
P1S, X1C) for "Any Printer" scheduling, or uses target_printer_id if
configured.

Settings page auto-save onSuccess overwrote localSettings with the
server response, discarding characters typed during the save request.
Removed the stale state overwrite so in-progress input is preserved.
2026-02-26 08:06:56 +01:00
maziggy c770f842f2 Fix "Queue to Any Printer" ignoring filament color override (#486)
When scheduling a print to "any printer" with a filament color override,
the scheduler picked a printer with the correct filament type but wrong
color. _find_idle_printer_for_model() used color matching only for
ranking candidates, not filtering — a printer with 0 color matches was
still selected if it had the right types.

Now requires at least 1 color match when filament overrides specify
colors. Printers with 0 matches are skipped and reported in the
"waiting for filament" reason instead of being treated as candidates.
2026-02-26 07:44:43 +01:00
maziggy 6317e7adce Updated README 2026-02-26 07:26:35 +01:00
MartinNYHC 3c86bdd27f Merge pull request #517 from maziggy/maziggy-patch-1
Make version check mandatory in bug report template
2026-02-24 17:50:36 +01:00
MartinNYHC 18f43e46ac Make version check mandatory in bug report template 2026-02-24 17:50:20 +01:00
MartinNYHC a6a01eb11b Merge pull request #516 from maziggy/maziggy-patch-1
Make 'latest version' field required in bug report
2026-02-24 17:49:36 +01:00
MartinNYHC a5ccdf561a Make 'latest version' field required in bug report 2026-02-24 17:49:20 +01:00
maziggy 8e39b12c5d Updated .github/ISSUE_TEMPLATE/bug_report.yml 2026-02-24 16:49:32 +01:00
maziggy 60f1be8935 Updated .github/ISSUE_TEMPLATE/bug_report.yml 2026-02-24 16:49:13 +01:00
maziggy 59be1b0d4d Updated .github/ISSUE_TEMPLATE/bug_report.yml 2026-02-24 16:48:12 +01:00
maziggy 3dc9ebcb6c Updated .github/ISSUE_TEMPLATE/bug_report.yml 2026-02-24 16:47:50 +01:00
maziggy d92803b557 Fix "Open in Slicer" failing for filenames with special characters
Filenames containing / \ ? or # (e.g. "Abzweigdose/Verteilerdose 70mm")
broke the slicer protocol handler. BambuStudio/OrcaSlicer url_decode()
the entire protocol URL before downloading, which decoded %2F back to /,
creating extra path segments that returned 404. Sanitize these characters
to _ in slicer download URLs — the filename is cosmetic (backend resolves
files by archive ID).
2026-02-24 12:32:46 +01:00
maziggy c2b7b6a99a Fix inconsistent print cost calculation on reprints (#505)
Three independent code paths wrote to archive.cost with conflicting
strategies, causing the same model to produce different prices on each
reprint (e.g. £0.77, £1.54, £2.03).

- Remove add_reprint_cost (Path 3) — redundant cost accumulation that
  double-counted on top of usage tracker
- Fix usage tracker (Path 2) — compute cost from current session's
  results only, not a SUM of all historical SpoolUsageHistory rows
- Remove _reprint_archives tracking set from main.py
- Update test mocks to match simplified query pattern

archive.cost now always reflects the cost of a single print.
2026-02-24 08:58:35 +01:00
maziggy ed36eafbec Fix timestamps off by timezone offset in non-UTC containers (#504)
All backend timestamps used datetime.now() (server local time) or the
deprecated datetime.utcnow(). The frontend's parseUTCDate() assumes
timestamps without timezone indicators are UTC and appends 'Z', so
stored timestamps were off by the timezone offset when the container's
timezone wasn't UTC.

Backend: replaced datetime.now() and datetime.utcnow() with
datetime.now(timezone.utc) across 16 files (~80 call sites) for all
database fields and DB comparisons. Cosmetic timestamps (filenames,
user-facing local time formatting) intentionally left as local time.

Frontend: replaced 13 new Date(backendTimestamp) calls with
parseUTCDate() across 8 files to correctly interpret UTC timestamps.
2026-02-24 08:18:02 +01:00
maziggy 974988c4f1 Fix created admin users not seeing settings button in sidebar (#503)
The sidebar hid Settings based on hardcoded role === 'user' instead of
the settings:read permission, and login set user state directly from the
response instead of re-fetching full auth status with permissions.
2026-02-24 07:52:41 +01:00
maziggy 04ac6bd36e Fix power-off option not gated by printers:control permission (#500)
The "Power off printer when done" checkbox in the print modal and the
auto power off tri-state toggle in the bulk edit modal were accessible
to all users regardless of permissions. Users without printers:control
can now no longer enable auto power off — controls are disabled and
visually dimmed.
2026-02-24 07:46:12 +01:00
maziggy bbf539d156 Bumped version 2026-02-23 14:29:16 +01:00
maziggy 4cf76c53c7 Updated conftest.py 2026-02-23 14:13:37 +01:00
maziggy faff453dec Fix bed cooled notification never triggering (#497)
The bed cooldown monitor was defined at the end of on_print_complete,
after an early return that exits when no archive is found. Prints
started from BambuStudio or the printer's touchscreen have no archive,
so the function returned before the bed cooldown task was ever created.

Moved the bed cooldown block (function def + task creation) to before
the archive_id early-return so it fires for all completed prints.
Also hardened the temperature dict check from truthiness to isinstance.
2026-02-23 13:57:58 +01:00
maziggy 24c4363620 Fix filament fill level display bugs on printer card (#496)
Three related fixes in PrintersPage.tsx:

1. External spool (vt_tray) fill level was missing the AMS remain
   fallback — only checked Spoolman/inventory, ignoring valid AMS data.
   Now uses the same fallback chain as regular and AMS-HT slots.

2. When fill was unknown (null), slot visual showed a full-width gray
   bar ("full") while the hover card showed "—" ("empty"). Removed the
   misleading gray fallback bar from all three slot types so both views
   consistently show "unknown".

3. Fill source priority always preferred AMS remain over Spoolman and
   inventory, even when those sources were more accurate (e.g. spools
   with usage tracking or migrated from Spoolman). Reversed priority to
   Spoolman → Inventory → AMS remain. Fixed fillSource label to reflect
   the actual data source (was always 'ams' even when using fallback).
2026-02-23 13:23:59 +01:00
maziggy 5cb1ca3ae2 Spoolbuddy frontend work 2026-02-23 13:02:46 +01:00
maziggy 0597392a9d Cleaned up spoolbuddy folder 2026-02-23 12:39:24 +01:00
maziggy 414dc4a511 Updated RPI install script 2026-02-23 11:34:43 +01:00
maziggy eba4184097 Updated RPI install script 2026-02-23 11:29:17 +01:00
maziggy 09e6bfd121 moved from scale_diag import NAU7802 and NAU7802() inside the try/except block in ScaleReader.__init__. Previously, NAU7802() opened /dev/i2c-0 in its
constructor before the try/except, so the FileNotFoundError was unhandled and crashed the entire daemon via asyncio.gather().

Now when the scale hardware isn't available (no /dev/i2c-0), it logs "Scale init failed" and sets self._ok = False, so scale_poll_loop will skip polling with "Scale not
available, skipping scale polling" — same graceful degradation the NFC reader already has.
2026-02-23 11:19:58 +01:00
maziggy 851b039dd8 Added Spoolbuddy RPI install script 2026-02-23 10:30:48 +01:00