diff --git a/backend/app/services/bambu_mqtt.py b/backend/app/services/bambu_mqtt.py index 6523ac7c6..c3b75e427 100644 --- a/backend/app/services/bambu_mqtt.py +++ b/backend/app/services/bambu_mqtt.py @@ -2049,6 +2049,10 @@ class BambuMQTTClient: slot_id = tray_id % 4 ams_mapping2.append({"ams_id": ams_id, "slot_id": slot_id}) + # H2D series requires integer values (0/1) for boolean fields + # Other printers (X1C, P1S, A1, etc.) require actual booleans + is_h2d = self.model and self.model.upper().strip() in ("H2D", "H2D PRO", "H2DPRO", "H2C", "H2S") + command = { "print": { "sequence_id": "20000", @@ -2058,13 +2062,13 @@ class BambuMQTTClient: "file": filename, "md5": "", "bed_type": "auto", - "timelapse": 1 if timelapse else 0, - "bed_leveling": 1 if bed_levelling else 0, + "timelapse": (1 if timelapse else 0) if is_h2d else timelapse, + "bed_leveling": (1 if bed_levelling else 0) if is_h2d else bed_levelling, "auto_bed_leveling": 1 if bed_levelling else 0, - "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, + "flow_cali": (1 if flow_cali else 0) if is_h2d else flow_cali, + "vibration_cali": (1 if vibration_cali else 0) if is_h2d else vibration_cali, + "layer_inspect": (1 if layer_inspect else 0) if is_h2d else layer_inspect, + "use_ams": (1 if use_ams else 0) if is_h2d else use_ams, "cfg": "0", "extrude_cali_flag": 0, "extrude_cali_manual_mode": 0, @@ -2077,6 +2081,9 @@ class BambuMQTTClient: } } + if is_h2d: + logger.info(f"[{self.serial_number}] H2D series detected: using integer format for boolean fields") + # P2S-specific parameter adjustments # P2S printer doesn't support vibration calibration like X1/P1 series if self.model and self.model.upper().strip() in ("P2S", "N7"): diff --git a/pyproject.toml b/pyproject.toml index 7c0551c5c..844c1dab6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,6 @@ ignore = [ "SIM108", # ternary operator (readability preference) "SIM102", # nested if (readability preference) "SIM105", # contextlib.suppress (readability preference) - "UP038", # isinstance tuple syntax (readability preference) ] # Allow autofix for all enabled rules