Backend changes:

1. bambu_mqtt.py: Added hms_errors to the completion callback data, which includes the HMS error codes when a print fails
  2. archive.py: Updated update_archive_status() to accept an optional failure_reason parameter
  3. main.py: Added auto-detection of failure reasons:
    - status == "aborted" → failure_reason = "User cancelled"
    - status == "failed" with HMS errors → maps module codes to reasons:
        - Module 0x07 (Filament) → "Filament runout"
      - Module 0x0C (Motion Controller) → "Layer shift"
      - Module 0x05 (Nozzle) → "Clogged nozzle"

  Frontend changes:

  1. ArchivesPage.tsx:
    - Badge now shows "cancelled" for aborted prints, "failed" for failed prints
    - "Failed Prints" collection and "Hide Failed" filter now include both failed and aborted statuses
  2. EditArchiveModal.tsx: Failure reason field now shows for both failed and aborted prints

  New tests added:
  - test_hms_errors_included_in_failed_completion_callback
  - test_aborted_status_when_cancelled

  The HMS error module mapping is basic and can be expanded as you observe more failure types. The actual Bambu HMS error codes are documented in their wiki - we can add
  more mappings as needed.
This commit is contained in:
maziggy
2025-12-13 10:13:54 +01:00
parent f5cec45dbf
commit e85e5fa33e
9 changed files with 727 additions and 495 deletions
+3 -3
View File
@@ -144,7 +144,7 @@ export function EditArchiveModal({ archive, onClose, existingTags = [] }: EditAr
project_id: projectId,
notes: notes || undefined,
tags: tags || undefined,
failure_reason: archive.status === 'failed' ? (failureReason || undefined) : undefined,
failure_reason: (archive.status === 'failed' || archive.status === 'aborted') ? (failureReason || undefined) : undefined,
});
};
@@ -297,8 +297,8 @@ export function EditArchiveModal({ archive, onClose, existingTags = [] }: EditAr
</div>
</div>
{/* Failure Reason - only show for failed prints */}
{archive.status === 'failed' && (
{/* Failure Reason - only show for failed/aborted prints */}
{(archive.status === 'failed' || archive.status === 'aborted') && (
<div>
<label className="block text-sm text-bambu-gray mb-1">Failure Reason</label>
<select