mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-18 03:54:17 +02:00
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)
This commit is contained in:
+5
-2
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user