From 6890c16efd41926286b0d26453a01a67880ef050 Mon Sep 17 00:00:00 2001 From: maziggy Date: Thu, 5 Feb 2026 07:10:18 +0100 Subject: [PATCH] Fix HMS notification display and filtering for H2D - Mask HMS error codes to 16 bits to fix malformed display (H2D sends code 0x2001B which displayed as "0C00_2001B" instead of "0C00_001B") - Filter notifications to severity >= 2, skipping informational messages (H2D sends severity 1 camera status that isn't a real error) --- backend/app/main.py | 7 +++++-- backend/app/services/bambu_mqtt.py | 12 ++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/backend/app/main.py b/backend/app/main.py index 18dccad8e..476bd1d79 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -488,7 +488,8 @@ async def on_printer_status_change(printer_id: int, state: PrinterState): if new_error_codes: # Get the actual new errors for the notification - new_errors = [e for e in current_hms_errors if f"{e.attr:08x}" in new_error_codes] + # Filter to severity >= 2 (skip informational/status messages like H2D sends) + new_errors = [e for e in current_hms_errors if f"{e.attr:08x}" in new_error_codes and e.severity >= 2] try: async with async_session() as db: @@ -518,8 +519,10 @@ async def on_printer_status_change(printer_id: int, state: PrinterState): for error in new_errors: module_name = module_names.get(error.module, f"Module 0x{error.module:02X}") # Build short code like "0700_8010" + # Mask to 16 bits to handle printers that send larger values error_code_int = int(error.code.replace("0x", ""), 16) if error.code else 0 - short_code = f"{(error.attr >> 16) & 0xFFFF:04X}_{error_code_int:04X}" + error_code_masked = error_code_int & 0xFFFF + short_code = f"{(error.attr >> 16) & 0xFFFF:04X}_{error_code_masked:04X}" error_type = f"{module_name} Error" # Look up human-readable description diff --git a/backend/app/services/bambu_mqtt.py b/backend/app/services/bambu_mqtt.py index 4346510fe..6523ac7c6 100644 --- a/backend/app/services/bambu_mqtt.py +++ b/backend/app/services/bambu_mqtt.py @@ -2058,13 +2058,13 @@ class BambuMQTTClient: "file": filename, "md5": "", "bed_type": "auto", - "timelapse": timelapse, - "bed_leveling": bed_levelling, + "timelapse": 1 if timelapse else 0, + "bed_leveling": 1 if bed_levelling else 0, "auto_bed_leveling": 1 if bed_levelling else 0, - "flow_cali": flow_cali, - "vibration_cali": vibration_cali, - "layer_inspect": layer_inspect, - "use_ams": use_ams, + "flow_cali": 1 if flow_cali else 0, + "vibration_cali": 1 if vibration_cali else 0, + "layer_inspect": 1 if layer_inspect else 0, + "use_ams": 1 if use_ams else 0, "cfg": "0", "extrude_cali_flag": 0, "extrude_cali_manual_mode": 0,