# Bambu Lab 3D Printer Integraton

**URL:** <https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381>\
**Category:** Items & Sitemaps\
**Tags:** mqtt, 3dprint, openhab3\
**Created:** [April 28, 2023, 7:23pm UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381 "2023-04-28T19:23:28Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Franco](https://community.openhab.org/user_avatar/community.openhab.org/franco/32/73665_2.png) [@Franco](https://community.openhab.org/u/Franco)\
**Post date:** [April 28, 2023, 7:23pm UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/1 "2023-04-28T19:23:29Z")

</div>

Hello together,

maybe today i can finally give something back to the great openhab community, at least to all that own a bambu lab 3D printer.

This week I recognized that there is a bambu lab printer integration for home assistant. Its realized over mqtt so not too difficult to integrate into openhab.

I own a X1C but settings should be quite same for the other models.

So let come the the interessting part. The X1C is an own Mqtt Broker.  
Whats necessary:

- access code (can be found in printer panel unter network)
- serial number (also in the printer panel under device informations)
- IP address

Im working with text configuration. Yet i only realized one item but the rest should be easy.

Thing:

```csv
Bridge mqtt:broker:bambuX1C "Bambu X1C Broker" [ host="YOUR_IP", 
                                                    secure=true, 
                                                    username="bblp", 
                                                    password="ACCESS CODE"
                                                     ]    

Thing mqtt:topic:stats "Bambu X1C stats" (mqtt:broker:bambuX1C) {   
     Channels:
        Type string : gcode_state "Status" [stateTopic="device/SERIALNUMBER/report", transformationPattern="JSONPATH:$.print.gcode_state"]
} 

```

Item:

```csv
String bambuX1C_Status "X1C Status" {channel="mqtt:topic:stats:gcode_state"}

```

In homeassistant they do a lot of transforming by node red. I think maybe the only difficult thing left ist to find out what has to be send for commands to the printer.  
All available informations can be found in this example protocoll:

```csv
{
    "print": {
        "ams": {
            "ams": [
                {
                    "humidity": "5",
                    "id": "0",
                    "temp": "-40.0",
                    "tray": [
                        {
                            "bed_temp": "0",
                            "bed_temp_type": "0",
                            "drying_temp": "0",
                            "drying_time": "0",
                            "id": "0",
                            "nozzle_temp_max": "260",
                            "nozzle_temp_min": "220",
                            "remain": -1,
                            "tag_uid": "0000000000000000",
                            "tray_color": "FFFFFFFF",
                            "tray_diameter": "0.00",
                            "tray_id_name": "",
                            "tray_info_idx": "GFG99",
                            "tray_sub_brands": "",
                            "tray_type": "PETG",
                            "tray_uuid": "00000000000000000000000000000000",
                            "tray_weight": "0",
                            "xcam_info": "000000000000000000000000"
                        },
                        {
                            "bed_temp": "0",
                            "bed_temp_type": "0",
                            "drying_temp": "0",
                            "drying_time": "0",
                            "id": "1",
                            "nozzle_temp_max": "230",
                            "nozzle_temp_min": "190",
                            "remain": -1,
                            "tag_uid": "0000000000000000",
                            "tray_color": "7C4B00FF",
                            "tray_diameter": "0.00",
                            "tray_id_name": "",
                            "tray_info_idx": "GFL00",
                            "tray_sub_brands": "",
                            "tray_type": "PLA",
                            "tray_uuid": "00000000000000000000000000000000",
                            "tray_weight": "0",
                            "xcam_info": "000000000000000000000000"
                        },
                        {
                            "bed_temp": "40",
                            "bed_temp_type": "1",
                            "drying_temp": "80",
                            "drying_time": "8",
                            "id": "2",
                            "nozzle_temp_max": "220",
                            "nozzle_temp_min": "220",
                            "remain": 8,
                            "tag_uid": "D53E550500000100",
                            "tray_color": "FFFFFFFF",
                            "tray_diameter": "1.75",
                            "tray_id_name": "S00-W0",
                            "tray_info_idx": "GFS00",
                            "tray_sub_brands": "Support W",
                            "tray_type": "Support",
                            "tray_uuid": "C802F69ED5824CAFA04D0C13C8F285AA",
                            "tray_weight": "250",
                            "xcam_info": "100E100EE803E8030000803F"
                        },
                        {
                            "bed_temp": "0",
                            "bed_temp_type": "0",
                            "drying_temp": "0",
                            "drying_time": "0",
                            "id": "3",
                            "nozzle_temp_max": "260",
                            "nozzle_temp_min": "220",
                            "remain": -1,
                            "tag_uid": "0000000000000000",
                            "tray_color": "443089FF",
                            "tray_diameter": "0.00",
                            "tray_id_name": "",
                            "tray_info_idx": "GFG99",
                            "tray_sub_brands": "",
                            "tray_type": "PETG",
                            "tray_uuid": "00000000000000000000000000000000",
                            "tray_weight": "0",
                            "xcam_info": "000000000000000000000000"
                        }
                    ]
                }
            ],
            "ams_exist_bits": "1",
            "insert_flag": true,
            "power_on_flag": true,
            "tray_exist_bits": "f",
            "tray_is_bbl_bits": "f",
            "tray_now": "1",
            "tray_read_done_bits": "f",
            "tray_reading_bits": "0",
            "tray_tar": "1",
            "version": 53
        },
        "ams_rfid_status": 2,
        "ams_status": 768,
        "bed_target_temper": 57.0,
        "bed_temper": 57.0,
        "big_fan1_speed": "10",
        "big_fan2_speed": "15",
        "chamber_temper": 39.0,
        "command": "push_status",
        "cooling_fan_speed": "15",
        "fail_reason": "0",
        "fan_gear": 16757503,
        "force_upgrade": false,
        "gcode_file": "/data/Metadata/plate_1.gcode",
        "gcode_file_prepare_percent": "100",
        "gcode_start_time": "1680174906",
        "gcode_state": "RUNNING",
        "heatbreak_fan_speed": "15",
        "hms": [
            {
                "attr": 201327360,
                "code": 131076
            }
        ],
        "home_flag": 1463,
        "hw_switch_state": 1,
        "ipcam": {
            "ipcam_dev": "1",
            "ipcam_record": "enable",
            "resolution": "1080p",
            "timelapse": "enable"
        },
        "layer_num": 285,
        "lifecycle": "product",
        "lights_report": [
            {
                "mode": "on",
                "node": "chamber_light"
            },
            {
                "mode": "flashing",
                "node": "work_light"
            }
        ],
        "maintain": 3,
        "mc_percent": 82,
        "mc_print_error_code": "0",
        "mc_print_stage": "2",
        "mc_print_sub_stage": 0,
        "mc_remaining_time": 38,
        "mess_production_state": "active",
        "nozzle_target_temper": 235.0,
        "nozzle_temper": 235.0,
        "online": {
            "ahb": false,
            "rfid": false
        },
        "print_error": 0,
        "print_gcode_action": 0,
        "print_real_action": 0,
        "print_type": "cloud",
        "profile_id": "4097567",
        "project_id": "4097867",
        "sdcard": true,
        "sequence_id": "2021",
        "spd_lvl": 2,
        "spd_mag": 100,
        "stg": [
            2,
            14,
            13
        ],
        "stg_cur": 0,
        "subtask_id": "7822827",
        "subtask_name": "Untitled_plate_1",
        "task_id": "7822826",
        "total_layer_num": 401,
        "upgrade_state": {
            "ahb_new_version_number": "",
            "ams_new_version_number": "",
            "consistency_request": false,
            "dis_state": 0,
            "err_code": 0,
            "force_upgrade": false,
            "message": "",
            "module": "null",
            "new_version_state": 2,
            "ota_new_version_number": "",
            "progress": "0",
            "sequence_id": 0,
            "status": "IDLE"
        },
        "upload": {
            "file_size": 0,
            "finish_size": 0,
            "message": "Good",
            "oss_url": "",
            "progress": 0,
            "sequence_id": "0903",
            "speed": 0,
            "status": "idle",
            "task_id": "",
            "time_remaining": 0,
            "trouble_id": ""
        },
        "wifi_signal": "-44dBm",
        "xcam": {
            "allow_skip_parts": false,
            "buildplate_marker_detector": true,
            "first_layer_inspector": true,
            "halt_print_sensitivity": "medium",
            "print_halt": true,
            "printing_monitor": true,
            "spaghetti_detector": true
        },
        "xcam_status": "0"
    }
}​

```

Hopefully i can go on with the expansion soon 🙂  
Or maybe some of you join 😉

UPDATE:  
i just found out that its more complex than expected. The item bambuX1C\_Status for example can include the state “Running” but it frequently switches to a structure with multiple values. I guess thats the reason why the homeassistant guys set node red inbetween to handle these special things.

I have no idea about node red but i will try to figure out how to use their work for openhab.

---

<div class="post-metadata">

**Author:** ![Franco](https://community.openhab.org/user_avatar/community.openhab.org/franco/32/73665_2.png) [@Franco](https://community.openhab.org/u/Franco)\
**Post date:** [April 29, 2023, 9:57pm UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/2 "2023-04-29T21:57:27Z")

</div>

Heres a bigger update.

I followed this guide to setup the homeassistant guide for integration with node red. (preparation of json, import, change of few nodes)

> **[crydteam](https://crydteam.de/)**

I just renamed some parts from “homeassistant” to “openhab” else the first part of each state topic has to be renamed.

Some of the values are already looking quide good.

So here are the new files:  
Things:

```csv
Thing mqtt:topic:bambuLab "Bambu X1C" (mqtt:broker:OWN_BROKER_HERE) {
    Type string : state "Status" [stateTopic="openhab/sensor/X1C_Bambu_X1C/print_status/state"]
    Type string : wifi "Empfang" [stateTopic="openhab/sensor/X1C_Bambu_X1C/wifi_signal/state"]
    //Type string : reset_filter "Reset Filter" [stateTopic="openhab/button/X1C_Bambu_X1C/reset_filter/state"]
    Type switch : chamber_light "Licht" [stateTopic="openhab/light/X1C_Bambu_X1C/chamber_light/state"]
    //Type string : ams_count "Anzahl AMS" [stateTopic="openhab/sensor/X1C_Bambu_X1C/ams_count/state"]
    Type number : aux_part_fan "aux_part_fan" [stateTopic="openhab/sensor/X1C_Bambu_X1C/aux_part_fan/state"]
    Type number : bed_temperature "Bett Temperatur" [stateTopic="openhab/sensor/X1C_Bambu_X1C/bed_temperature/state"]
    //Type string : big_fan1 "big_fan1" [stateTopic="openhab/sensor/X1C_Bambu_X1C/big_fan1/state"]
    //Type string : big_fan2 "big_fan2" [stateTopic="openhab/sensor/X1C_Bambu_X1C/big_fan2/state"]
    Type number : chamber_temperature "Kammer Temperatur" [stateTopic="openhab/sensor/X1C_Bambu_X1C/chamber_temperature/state"]
    Type number : cooling_fan "cooling_fan" [stateTopic="openhab/sensor/X1C_Bambu_X1C/cooling_fan/state"]
    Type string : fail_reason "Fehler Ursache" [stateTopic="openhab/sensor/X1C_Bambu_X1C/fail_reason/state"]
    //Type string : fan_gear "fan_gear" [stateTopic="openhab/sensor/X1C_Bambu_X1C/fan_gear/state"]
    Type string : filam_bak "filam_bak" [stateTopic="openhab/sensor/X1C_Bambu_X1C/filam_bak/state"]
    Type string : gcode "gcode" [stateTopic="openhab/sensor/X1C_Bambu_X1C/gcode/state"]
    Type number : heatbreak_fan "heatbreak_fan" [stateTopic="openhab/sensor/X1C_Bambu_X1C/heatbreak_fan/state"]
    //Type string : ipcam "ipcam" [stateTopic="openhab/sensor/X1C_Bambu_X1C/ipcam/state"]
    //Type string : layer_num "Layer" [stateTopic="openhab/sensor/X1C_Bambu_X1C/layer_num/state"]
    //Type string : machine_name "Drucker Name" [stateTopic="openhab/sensor/X1C_Bambu_X1C/machine_name/state"]
    //Type string : machine_serial "Seriennummer" [stateTopic="openhab/sensor/X1C_Bambu_X1C/machine_serial/state"]
    Type string : maintain "maintain" [stateTopic="openhab/sensor/X1C_Bambu_X1C/maintain/state"]
    Type string : mess_production_state "mess_production_state" [stateTopic="openhab/sensor/X1C_Bambu_X1C/mess_production_state/state"]
    //Type string : model "model" [stateTopic="openhab/sensor/X1C_Bambu_X1C/model/state"]
    //Type string : nozzle_diameter "Nozzle Größe" [stateTopic="openhab/sensor/X1C_Bambu_X1C/nozzle_diameter/state"]
    Type number : nozzle_temperature "Nozzle Temperatur" [stateTopic="openhab/sensor/X1C_Bambu_X1C/nozzle_temperature/state"]
    Type string : print "print" [stateTopic="openhab/sensor/X1C_Bambu_X1C/print/state"]
    Type string : print_end_time "Ende" [stateTopic="openhab/sensor/X1C_Bambu_X1C/print_end_time/state"]
    Type string : print_progress "Fortschritt" [stateTopic="openhab/sensor/X1C_Bambu_X1C/print_progress/state"]
    Type string : print_remaining_time "Dauer" [stateTopic="openhab/sensor/X1C_Bambu_X1C/print_remaining_time/state"]
    //Type string : print_start_epoch "print_start_epoch" [stateTopic="openhab/sensor/X1C_Bambu_X1C/print_start_epoch/state"]
    //Type string : print_start_time "Startzeit" [stateTopic="openhab/sensor/X1C_Bambu_X1C/print_start_time/state"]
    //Type string : queue_number "queue_number" [stateTopic="openhab/sensor/X1C_Bambu_X1C/queue_number/state"]
    //Type string : sdcard "sdcard" [stateTopic="openhab/sensor/X1C_Bambu_X1C/sdcard/state"]
    Type string : speed "Geschwindigkeit" [stateTopic="openhab/sensor/X1C_Bambu_X1C/speed/state"]
    Type string : stage "stage" [stateTopic="openhab/sensor/X1C_Bambu_X1C/stage/state"]
    Type string : status "Status" [stateTopic="openhab/sensor/X1C_Bambu_X1C/status/state"]
    Type string : subtask "subtask" [stateTopic="openhab/sensor/X1C_Bambu_X1C/subtask/state"]
    Type string : task_id "task_id" [stateTopic="openhab/sensor/X1C_Bambu_X1C/task_id/state"]
    //Type string : total_layer_num "total_layer_num" [stateTopic="openhab/sensor/X1C_Bambu_X1C/total_layer_num/state"]
    Type string : upgrade_state "upgrade_state" [stateTopic="openhab/sensor/X1C_Bambu_X1C/upgrade_state/state"]
    //Type string : upload "Upload" [stateTopic="openhab/sensor/X1C_Bambu_X1C/upload/state"]
    Type string : vt_tray "vt_tray" [stateTopic="openhab/sensor/X1C_Bambu_X1C/vt_tray/state"]
    Type string : work_light "work_light" [stateTopic="openhab/sensor/X1C_Bambu_X1C/work_light/state"]
    //Type string : xcam "xcam" [stateTopic="openhab/sensor/X1C_Bambu_X1C/xcam/state"]
}

Thing mqtt:topic:ams0 "Bambu AMS" (mqtt:broker:Zigbee2Mqtt) {
    Type string : ams "AMS" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/AMS/state"]
    Type number : humidity "humidity" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/humidity/state"]
    Type string : humidity_level "humidity_level" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/humidity_level/state"]
    Type string : id "id" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/id/state"]
    Type string : printer_name "printer_name" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/printer_name/state"]
    Type string : printer_serial "printer_serial" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/printer_serial/state"]
    Type number : temp "temp" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/temp/state"]
    Type string : tray_0_material "tray_0 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_0/state"]
    Type string : tray_1_material "tray_1 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_1/state"]
    Type string : tray_2_material "tray_2 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_2/state"]
    Type string : tray_3_material "tray_3 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_3/state"] 
    Type string : tray_0_color "tray_0 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_0/attr", transformationPattern="JSONPATH:$.color", ValueTransformation="REGEX:(.{7}).*"]
    Type string : tray_1_color "tray_1 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_1/attr", transformationPattern="JSONPATH:$.color"]
    Type string : tray_2_color "tray_2 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_2/attr", transformationPattern="JSONPATH:$.color"]
    Type string : tray_3_color "tray_3 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_3/attr", transformationPattern="JSONPATH:$.color"] 
    
} 

```

Items:

```csv
Switch WaitPrinterCoolAndIdle "Drucker Aussschaltverzögerung"
 
//bambu x1c 
Group gX1C
String X1C_State "Zustand" (gX1C) {channel="mqtt:topic:bambuLab:state"}
String X1C_Wifi "Empfang" (gX1C) {channel="mqtt:topic:bambuLab:wifi"}
//String X1C_reset_filter "Reset Filter" (gX1C) {channel="mqtt:topic:bambuLab:reset_filter"}
Switch X1C_chamber_light "Licht" (gX1C) {channel="mqtt:topic:bambuLab:chamber_light"}
//String X1C_ams_count "Anzahl AMS" (gX1C) {channel="mqtt:topic:bambuLab:ams_count"}
Number X1C_aux_part_fan "aux_part_fan" (gX1C) {channel="mqtt:topic:bambuLab:aux_part_fan"}
Number X1C_bed_temperature "Bett Temperatur [%.1f °C]" (gX1C) {channel="mqtt:topic:bambuLab:bed_temperature"}
//String X1C_big_fan1 "big_fan1" (gX1C) {channel="mqtt:topic:bambuLab:big_fan1"}
//String X1C_big_fan2 "big_fan2" (gX1C) {channel="mqtt:topic:bambuLab:big_fan2"}
Number X1C_chamber_temperature "Kammer Temperatur [%.1f °C]" (gX1C) {channel="mqtt:topic:bambuLab:chamber_temperature"}
Number X1C_cooling_fan "cooling_fan" (gX1C) {channel="mqtt:topic:bambuLab:cooling_fan"}
String X1C_fail_reason "Fehler Ursache" (gX1C) {channel="mqtt:topic:bambuLab:fail_reason"}
//String X1C_fan_gear "fan_gear" (gX1C) {channel="mqtt:topic:bambuLab:fan_gear"}
String X1C_filam_bak "filam_bak" (gX1C) {channel="mqtt:topic:bambuLab:filam_bak"}
String X1C_gcode "gcode" (gX1C) {channel="mqtt:topic:bambuLab:gcode"}
String X1C_heatbreak_fan "heatbreak_fan" (gX1C) {channel="mqtt:topic:bambuLab:heatbreak_fan"}
String X1C_ipcam "ipcam" (gX1C) {channel="mqtt:topic:bambuLab:ipcam"}
String X1C_layer_num "Layer" (gX1C) {channel="mqtt:topic:bambuLab:layer_num"}
String X1C_machine_name "machine_name" (gX1C) {channel="mqtt:topic:bambuLab:machine_name"}
//String X1C_machine_serial "machine_serial" (gX1C) {channel="mqtt:topic:bambuLab:machine_serial"}
String X1C_maintain "maintain" (gX1C) {channel="mqtt:topic:bambuLab:maintain"}
String X1C_mess_production_state "mess_production_state" (gX1C) {channel="mqtt:topic:bambuLab:mess_production_state"}
//String X1C_model "model" (gX1C) {channel="mqtt:topic:bambuLab:model"}
//String X1C_nozzle_diameter "nozzle_diameter" (gX1C) {channel="mqtt:topic:bambuLab:nozzle_diameter"}
Number X1C_nozzle_temperature "nozzle_temperature [%.1f °C]" (gX1C) {channel="mqtt:topic:bambuLab:nozzle_temperature"}
String X1C_print "print" (gX1C) {channel="mqtt:topic:bambuLab:print"}
String X1C_print_end_time "Druck Ende" (gX1C) {channel="mqtt:topic:bambuLab:print_end_time"}
Number X1C_print_progress "Fortschritt [%s] %" (gX1C) {channel="mqtt:topic:bambuLab:print_progress"}
String X1C_print_remaining_time "Druck Dauer" (gX1C) {channel="mqtt:topic:bambuLab:print_remaining_time"}
//String X1C_print_start_epoch "print_start_epoch" (gX1C) {channel="mqtt:topic:bambuLab:print_start_epoch"}
//String X1C_print_start_time "print_start_time" (gX1C) {channel="mqtt:topic:bambuLab:print_start_time"}
//String X1C_queue_number "queue_number" (gX1C) {channel="mqtt:topic:bambuLab:queue_number"}
//String X1C_sdcard "sdcard" (gX1C) {channel="mqtt:topic:bambuLab:sdcard"}
String X1C_speed "speed" (gX1C) {channel="mqtt:topic:bambuLab:speed"}
String X1C_stage "stage" (gX1C) {channel="mqtt:topic:bambuLab:stage"}
String X1C_status "Verbindungsstatus" (gX1C) {channel="mqtt:topic:bambuLab:status"}
String X1C_subtask "subtask" (gX1C) {channel="mqtt:topic:bambuLab:subtask"}
String X1C_task_id "task_id" (gX1C) {channel="mqtt:topic:bambuLab:task_id"}
//String X1C_total_layer_num "total_layer_num" (gX1C) {channel="mqtt:topic:bambuLab:total_layer_num"}
String X1C_upgrade_state "upgrade_state" (gX1C) {channel="mqtt:topic:bambuLab:upgrade_state"}
//String X1C_upload "upload" (gX1C) {channel="mqtt:topic:bambuLab:upload"}
String X1C_vt_tray "vt_tray" (gX1C) {channel="mqtt:topic:bambuLab:vt_tray"}
Switch X1C_work_light "work_light" (gX1C) {channel="mqtt:topic:bambuLab:work_light"}
//String X1C_xcam "xcam" (gX1C) {channel="mqtt:topic:bambuLab:xcam"}

//bambu ams
Group gAMS0
String AMS0_ams "ams" (gAMS0) {channel="mqtt:topic:ams0:ams"}
Number AMS0_humidity "humidity [%d %%]" (gAMS0) {channel="mqtt:topic:ams0:humidity"}
String AMS0_humidity_level "humidity_level" (gAMS0) {channel="mqtt:topic:ams0:humidity_level"}
String AMS0_id "id" (gAMS0) {channel="mqtt:topic:ams0:id"}
String AMS0_printer_name "printer_name" (gAMS0) {channel="mqtt:topic:ams0:printer_name"}
String AMS0_printer_serial "printer_serial" (gAMS0) {channel="mqtt:topic:ams0:printer_serial"}
Number AMS0_temp "temp [%.1f °C]" (gAMS0) {channel="mqtt:topic:ams0:temp"}
String AMS0_tray_0_Material "tray_0 Material" (gAMS0) {channel="mqtt:topic:ams0:tray_0_material"}
String AMS0_tray_1_Material "tray_1 Material" (gAMS0) {channel="mqtt:topic:ams0:tray_1_material"}
String AMS0_tray_2_Material "tray_2 Material" (gAMS0) {channel="mqtt:topic:ams0:tray_2_material"}
String AMS0_tray_3_Material "tray_3 Material" (gAMS0) {channel="mqtt:topic:ams0:tray_3_material"}
String AMS0_tray_0_Color "tray_0 Farbe" (gAMS0) {channel="mqtt:topic:ams0:tray_0_color"}
String AMS0_tray_1_Color "tray_1 Farbe" (gAMS0) {channel="mqtt:topic:ams0:tray_1_color"}
String AMS0_tray_2_Color "tray_2 Farbe" (gAMS0) {channel="mqtt:topic:ams0:tray_2_color"}
String AMS0_tray_3_Color "tray_3 Farbe" (gAMS0) {channel="mqtt:topic:ams0:tray_3_color"}

//others
Switch X1C_cooledDown "Drucker abgekühlt" (gX1C) 
Switch X1C_printFinished "Druck abgeschlossen" (gX1C) 

```

---

<div class="post-metadata">

**Author:** ![raston](https://community.openhab.org/letter_avatar_proxy/v4/letter/r/e56c9b/32.png) [@raston](https://community.openhab.org/u/raston)\
**Post date:** [May 28, 2023, 7:33pm UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/3 "2023-05-28T19:33:12Z")

</div>

This is fantastic work, thank you! I just got a Bambu X1Carbon (best 3D printer I’ve ever used) but am missing my Octoprint integration, so my home automation system can’t, say, shut down the printer after a job is done in the middle of the night, or just tell me when the job’s done.

Are there any new developments?

Following with keen interest,

ST

---

<div class="post-metadata">

**Author:** ![Franco](https://community.openhab.org/user_avatar/community.openhab.org/franco/32/73665_2.png) [@Franco](https://community.openhab.org/u/Franco)\
**Post date:** [May 28, 2023, 7:44pm UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/4 "2023-05-28T19:44:00Z")

</div>

Yes indeed I made some further configuration for e.g. turning the light on and off. For initial setup I made all items as string.

Also I made rules which will send an Openhab notification at print finished and also will shut down the printer by switching a power plug after the printer temperatures are below a Limit.

I will post it as soon as I’m on my computer.

---

<div class="post-metadata">

**Author:** ![Franco](https://community.openhab.org/user_avatar/community.openhab.org/franco/32/73665_2.png) [@Franco](https://community.openhab.org/u/Franco)\
**Post date:** [May 29, 2023, 4:04am UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/5 "2023-05-29T04:04:13Z")

</div>

I updated the items and things. Some are comment out because i dont know what to do with them yet. I also added item switches for printer finished and printer cooled down.

Heres is how i realized the autmatic power off function. The item EnablePrinterPowerMan controls the visibility of the printers power switch to prevent someone press it while printer is printing or not cooled down.

```php
var Number temperatureLimit = 40

rule "01 - set temperature cooled down"
when
    Item X1C_nozzle_temperature changed or
    Item X1C_bed_temperature changed or
    Item X1C_State changed to "IDLE"
then
    if (X1C_nozzle_temperature.state <= temperatureLimit
        && X1C_bed_temperature.state <= temperatureLimit) {
            if (X1C_cooledDown.state != ON) {
                X1C_cooledDown.sendCommand(ON)
                if (X1C_State.state == "IDLE") {
                    if (EnablePrinterPowerMan != ON) EnablePrinterPowerMan.sendCommand(ON)
                } 
            }
        }
    else {
        if (X1C_cooledDown.state != OFF) X1C_cooledDown.sendCommand(OFF)
        if (EnablePrinterPowerMan.state != OFF) EnablePrinterPowerMan.sendCommand(OFF)
    }
end

rule "02 - set print finished"
when
    Item X1C_print_progress changed to 100 or
    Item X1C_print_progress changed to 0
then
    if (X1C_print_progress.state == 100) {
        X1C_printFinished.sendCommand(ON)
        sendNotification(Email.state.toString,"Druck ist fertig")
    }
    else X1C_printFinished.sendCommand(OFF)
end

rule "03 - turn off printer"
when
    Item X1C_printFinished changed to ON or
    Item X1C_cooledDown changed to ON
then
    if (X1C_printFinished.state == ON){
        if (X1C_cooledDown.state == ON) {
            //DEBUG: sendNotification(Email.state.toString,"Drucker wird ausgeschalten. Temp Nozzle:" + X1C_nozzle_temperature.state.toString)
            if (PowerSwitchPrinter != OFF) PowerSwitchPrinter.sendCommand(OFF)
            if (EnablePrinterPowerMan != ON) EnablePrinterPowerMan.sendCommand(ON)
        }
    } 
end

rule "04 - printer error message"
when
    Item X1C_fail_reason changed from 0
then
    sendNotification(Email.state.toString,"Drucker Fehlercode " + X1C_fail_reason.state.toString)
end

```

ToDo:

- decode hex color code to color name would be nice but don’t know how to do it (just a nice to have)
- decode error codes, but looks like Bambu wiki uses hex codes, the item gives decimal numbers (another nice to have)
- decode action id. Already done in home assistant link below
- set bed temp. Therefore the gcode item has to be used. would be useful to have a rule which send a alarm if chamber is preheated for materials like abs

In the home assistant forum they do a lot of fancy stuff:

> **[Bambu Lab X1 X1C MQTT](https://community.home-assistant.io/t/bambu-lab-x1-x1c-mqtt/489510/61)**
>
> Updated to latest firmware (01.03.00.00) and have noticed a few minor changes. AMS Humidity is now in levels/tiers and no longer a %, which may explain what @planetix was getting if they were on early firmware. This is less granular, and I’ve...

---

<div class="post-metadata">

**Author:** ![tacticaljack](https://community.openhab.org/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tacticaljack](https://community.openhab.org/u/tacticaljack)\
**Post date:** [June 27, 2023, 1:43am UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/6 "2023-06-27T01:43:18Z")

</div>

Awesome work. I am running openHAB 2.5 with 3.x on the test machine. I received my X1C a few weeks ago. This is fantastic and I am anxious to add my X1C to openHAB. Thanks for all the research you are doing.

---

<div class="post-metadata">

**Author:** ![Broncosis](https://community.openhab.org/user_avatar/community.openhab.org/broncosis/32/68554_2.png) [@Broncosis](https://community.openhab.org/u/Broncosis)\
**Post date:** [June 27, 2023, 6:03am UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/7 "2023-06-27T06:03:34Z")

</div>

ok I have some of this working but my AMS says offline unintaized is it using zigbee ?

---

<div class="post-metadata">

**Author:** ![Broncosis](https://community.openhab.org/user_avatar/community.openhab.org/broncosis/32/68554_2.png) [@Broncosis](https://community.openhab.org/u/Broncosis)\
**Post date:** [June 27, 2023, 6:17am UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/8 "2023-06-27T06:17:33Z")

</div>

super awsome thank you so much I figured I would put  
the output of google translate for the english Readers save them the  
trouble of fussing with all the names

this is the items file

```auto
Switch WaitPrinterCoolAndIdle "Printer off delay"

// bamboo x1c
Group gX1C
String X1C_State "Condition" (gX1C) {channel="mqtt:topic:bambuLab:state"}
String X1C_Wifi "Reception" (gX1C) {channel="mqtt:topic:bambuLab:wifi"}
//String X1C_reset_filter "Reset Filter" (gX1C) {channel="mqtt:topic:bambuLab:reset_filter"}
Switch X1C_chamber_light "Light" (gX1C) {channel="mqtt:topic:bambuLab:chamber_light"}
//String X1C_ams_count "Number of AMS" (gX1C) {channel="mqtt:topic:bambuLab:ams_count"}
Number X1C_aux_part_fan "aux_part_fan" (gX1C) {channel="mqtt:topic:bambuLab:aux_part_fan"}
Number X1C_bed_temperature "Bed temperature [%.1f °C]" (gX1C) {channel="mqtt:topic:bambuLab:bed_temperature"}
//String X1C_big_fan1 "big_fan1" (gX1C) {channel="mqtt:topic:bambuLab:big_fan1"}
//String X1C_big_fan2 "big_fan2" (gX1C) {channel="mqtt:topic:bambuLab:big_fan2"}
Number X1C_chamber_temperature "Chamber temperature [%.1f °C]" (gX1C) {channel="mqtt:topic:bambuLab:chamber_temperature"}
Number X1C_cooling_fan "cooling_fan" (gX1C) {channel="mqtt:topic:bambuLab:cooling_fan"}
String X1C_fail_reason "Error reason" (gX1C) {channel="mqtt:topic:bambuLab:fail_reason"}
//String X1C_fan_gear "fan_gear" (gX1C) {channel="mqtt:topic:bambuLab:fan_gear"}
String X1C_filam_bak "filam_bak" (gX1C) {channel="mqtt:topic:bambuLab:filam_bak"}
String X1C_gcode "gcode" (gX1C) {channel="mqtt:topic:bambuLab:gcode"}
String X1C_heatbreak_fan "heatbreak_fan" (gX1C) {channel="mqtt:topic:bambuLab:heatbreak_fan"}
String X1C_ipcam "ipcam" (gX1C) {channel="mqtt:topic:bambuLab:ipcam"}
String X1C_layer_num "Layer" (gX1C) {channel="mqtt:topic:bambuLab:layer_num"}
String X1C_machine_name "machine_name" (gX1C) {channel="mqtt:topic:bambuLab:machine_name"}
//String X1C_machine_serial "machine_serial" (gX1C) {channel="mqtt:topic:bambuLab:machine_serial"}
String X1C_maintain "maintain" (gX1C) {channel="mqtt:topic:bambuLab:maintain"}
String X1C_mess_production_state "mess_production_state" (gX1C) {channel="mqtt:topic:bambuLab:mess_production_state"}
//String X1C_model "model" (gX1C) {channel="mqtt:topic:bambuLab:model"}
//String X1C_nozzle_diameter "nozzle_diameter" (gX1C) {channel="mqtt:topic:bambuLab:nozzle_diameter"}
Number X1C_nozzle_temperature "nozzle_temperature [%.1f °C]" (gX1C) {channel="mqtt:topic:bambuLab:nozzle_temperature"}
String X1C_print "print" (gX1C) {channel="mqtt:topic:bambuLab:print"}
String X1C_print_end_time "End of print" (gX1C) {channel="mqtt:topic:bambuLab:print_end_time"}
Number X1C_print_progress "Progress [%s] %" (gX1C) {channel="mqtt:topic:bambuLab:print_progress"}
String X1C_print_remaining_time "Print duration" (gX1C) {channel="mqtt:topic:bambuLab:print_remaining_time"}
//String X1C_print_start_epoch "print_start_epoch" (gX1C) {channel="mqtt:topic:bambuLab:print_start_epoch"}
//String X1C_print_start_time "print_start_time" (gX1C) {channel="mqtt:topic:bambuLab:print_start_time"}
//String X1C_queue_number "queue_number" (gX1C) {channel="mqtt:topic:bambuLab:queue_number"}
//String X1C_sdcard "sdcard" (gX1C) {channel="mqtt:topic:bambuLab:sdcard"}
String X1C_speed "speed" (gX1C) {channel="mqtt:topic:bambuLab:speed"}
String X1C_stage "stage" (gX1C) {channel="mqtt:topic:bambuLab:stage"}
String X1C_status "connection status" (gX1C) {channel="mqtt:topic:bambuLab:status"}
String X1C_subtask "subtask" (gX1C) {channel="mqtt:topic:bambuLab:subtask"}
String X1C_task_id "task_id" (gX1C) {channel="mqtt:topic:bambuLab:task_id"}
//String X1C_total_layer_num "total_layer_num" (gX1C) {channel="mqtt:topic:bambuLab:total_layer_num"}
String X1C_upgrade_state "upgrade_state" (gX1C) {channel="mqtt:topic:bambuLab:upgrade_state"}
//String X1C_upload "upload" (gX1C) {channel="mqtt:topic:bambuLab:upload"}
String X1C_vt_tray "vt_tray" (gX1C) {channel="mqtt:topic:bambuLab:vt_tray"}
Switch X1C_work_light "work_light" (gX1C) {channel="mqtt:topic:bambuLab:work_light"}
//String X1C_xcam "xcam" (gX1C) {channel="mqtt:topic:bambuLab:xcam"}

// bamboo ams
Group gAMS0
String AMS0_ams "ams" (gAMS0) {channel="mqtt:topic:ams0:ams"}
Number AMS0_humidity "humidity [%d %%]" (gAMS0) {channel="mqtt:topic:ams0:humidity"}
String AMS0_humidity_level "humidity_level" (gAMS0) {channel="mqtt:topic:ams0:humidity_level"}
String AMS0_id "id" (gAMS0) {channel="mqtt:topic:ams0:id"}
String AMS0_printer_name "printer_name" (gAMS0) {channel="mqtt:topic:ams0:printer_name"}
String AMS0_printer_serial "printer_serial" (gAMS0) {channel="mqtt:topic:ams0:printer_serial"}
Number AMS0_temp "temp [%.1f °C]" (gAMS0) {channel="mqtt:topic:ams0:temp"}
String AMS0_tray_0_Material "tray_0 Material" (gAMS0) {channel="mqtt:topic:ams0:tray_0_material"}
String AMS0_tray_1_Material "tray_1 Material" (gAMS0) {channel="mqtt:topic:ams0:tray_1_material"}
String AMS0_tray_2_Material "tray_2 Material" (gAMS0) {channel="mqtt:topic:ams0:tray_2_material"}
String AMS0_tray_3_Material "tray_3 Material" (gAMS0) {channel="mqtt:topic:ams0:tray_3_material"}
String AMS0_tray_0_Color "tray_0 color" (gAMS0) {channel="mqtt:topic:ams0:tray_0_color"}
String AMS0_tray_1_Color "tray_1 color" (gAMS0) {channel="mqtt:topic:ams0:tray_1_color"}
String AMS0_tray_2_Color "tray_2 color" (gAMS0) {channel="mqtt:topic:ams0:tray_2_color"}
String AMS0_tray_3_Color "tray_3 color" (gAMS0) {channel="mqtt:topic:ams0:tray_3_color"}

//others
Switch X1C_cooledDown "Printer cooled down" (gX1C)
Switch X1C_printFinished "Print finished" (gX1C)

```

things file

```auto
Bridge mqtt:broker:bambuX1C "Bambu X1C Broker" [ host="IP", 
                                                    secure=true, 
                                                    username="bblp", 
                                                    password="accesscode"
                                                     ]    

Thing mqtt:topic:stats "Bambu X1C stats" (mqtt:broker:bambuX1C) {   
     Channels:
        Type string : gcode_state "Status" [stateTopic="device/"Serial number"/report", transformationPattern="JSONPATH:$.print.gcode_state"]

}

Thing mqtt:topic:bambuLab "Bambu X1C" (mqtt:broker:"your broker") {
     Type string : state "Status" [stateTopic="openhab/sensor/X1C_Bambu_X1C/print_status/state"]
     Type string : wifi "reception" [stateTopic="openhab/sensor/X1C_Bambu_X1C/wifi_signal/state"]
     //Type string : reset_filter "Reset Filter" [stateTopic="openhab/button/X1C_Bambu_X1C/reset_filter/state"]
     Type switch : chamber_light "Light" [stateTopic="openhab/light/X1C_Bambu_X1C/chamber_light/state"]
     //Type string : ams_count "Number of AMS" [stateTopic="openhab/sensor/X1C_Bambu_X1C/ams_count/state"]
     Type number : aux_part_fan "aux_part_fan" [stateTopic="openhab/sensor/X1C_Bambu_X1C/aux_part_fan/state"]
     Type number : bed_temperature "bed temperature" [stateTopic="openhab/sensor/X1C_Bambu_X1C/bed_temperature/state"]
     //Type string : big_fan1 "big_fan1" [stateTopic="openhab/sensor/X1C_Bambu_X1C/big_fan1/state"]
     //Type string : big_fan2 "big_fan2" [stateTopic="openhab/sensor/X1C_Bambu_X1C/big_fan2/state"]
     Type number : chamber_temperature "chamber temperature" [stateTopic="openhab/sensor/X1C_Bambu_X1C/chamber_temperature/state"]
     Type number : cooling_fan "cooling_fan" [stateTopic="openhab/sensor/X1C_Bambu_X1C/cooling_fan/state"]
     Type string : fail_reason "Error reason" [stateTopic="openhab/sensor/X1C_Bambu_X1C/fail_reason/state"]
     //Type string : fan_gear "fan_gear" [stateTopic="openhab/sensor/X1C_Bambu_X1C/fan_gear/state"]
     Type string : filam_bak "filam_bak" [stateTopic="openhab/sensor/X1C_Bambu_X1C/filam_bak/state"]
     Type string : gcode "gcode" [stateTopic="openhab/sensor/X1C_Bambu_X1C/gcode/state"]
     Type number : heatbreak_fan "heatbreak_fan" [stateTopic="openhab/sensor/X1C_Bambu_X1C/heatbreak_fan/state"]
     //Type string : ipcam "ipcam" [stateTopic="openhab/sensor/X1C_Bambu_X1C/ipcam/state"]
     //Type string : layer_num "Layer" [stateTopic="openhab/sensor/X1C_Bambu_X1C/layer_num/state"]
     //Type string : machine_name "Printer Name" [stateTopic="openhab/sensor/X1C_Bambu_X1C/machine_name/state"]
     //Type string : machine_serial "serial number" [stateTopic="openhab/sensor/X1C_Bambu_X1C/machine_serial/state"]
     Type string : maintain "maintain" [stateTopic="openhab/sensor/X1C_Bambu_X1C/maintain/state"]
     Type string : mess_production_state "mess_production_state" [stateTopic="openhab/sensor/X1C_Bambu_X1C/mess_production_state/state"]
     //Type string : model "model" [stateTopic="openhab/sensor/X1C_Bambu_X1C/model/state"]
     //Type string : nozzle_diameter "Nozzle Size" [stateTopic="openhab/sensor/X1C_Bambu_X1C/nozzle_diameter/state"]
     Type number : nozzle_temperature "Nozzle Temperature" [stateTopic="openhab/sensor/X1C_Bambu_X1C/nozzle_temperature/state"]
     Type string : print "print" [stateTopic="openhab/sensor/X1C_Bambu_X1C/print/state"]
     Type string : print_end_time "End" [stateTopic="openhab/sensor/X1C_Bambu_X1C/print_end_time/state"]
     Type string : print_progress "Progress" [stateTopic="openhab/sensor/X1C_Bambu_X1C/print_progress/state"]
     Type string : print_remaining_time "duration" [stateTopic="openhab/sensor/X1C_Bambu_X1C/print_remaining_time/state"]
     //Type string : print_start_epoch "print_start_epoch" [stateTopic="openhab/sensor/X1C_Bambu_X1C/print_start_epoch/state"]
     //Type string : print_start_time "Start time" [stateTopic="openhab/sensor/X1C_Bambu_X1C/print_start_time/state"]
     //Type string : queue_number "queue_number" [stateTopic="openhab/sensor/X1C_Bambu_X1C/queue_number/state"]
     //Type string : sdcard "sdcard" [stateTopic="openhab/sensor/X1C_Bambu_X1C/sdcard/state"]
     Type string : speed "speed" [stateTopic="openhab/sensor/X1C_Bambu_X1C/speed/state"]
     Type string : stage "stage" [stateTopic="openhab/sensor/X1C_Bambu_X1C/stage/state"]
     Type string : status "Status" [stateTopic="openhab/sensor/X1C_Bambu_X1C/status/state"]
     Type string : subtask "subtask" [stateTopic="openhab/sensor/X1C_Bambu_X1C/subtask/state"]
     Type string : task_id "task_id" [stateTopic="openhab/sensor/X1C_Bambu_X1C/task_id/state"]
     //Type string : total_layer_num "total_layer_num" [stateTopic="openhab/sensor/X1C_Bambu_X1C/total_layer_num/state"]
     Type string : upgrade_state "upgrade_state" [stateTopic="openhab/sensor/X1C_Bambu_X1C/upgrade_state/state"]
     //Type string : upload "Upload" [stateTopic="openhab/sensor/X1C_Bambu_X1C/upload/state"]
     Type string : vt_tray "vt_tray" [stateTopic="openhab/sensor/X1C_Bambu_X1C/vt_tray/state"]
     Type string : work_light "work_light" [stateTopic="openhab/sensor/X1C_Bambu_X1C/work_light/state"]
     //Type string : xcam "xcam" [stateTopic="openhab/sensor/X1C_Bambu_X1C/xcam/state"]
}

Thing mqtt:topic:ams0 "Bambu AMS" (mqtt:broker:Zigbee2Mqtt) {
     Type string : ams "AMS" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/AMS/state"]
     Type number : humidity "humidity" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/humidity/state"]
     Type string : humidity_level "humidity_level" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/humidity_level/state"]
     Type string : id "id" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/id/state"]
     Type string : printer_name "printer_name" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/printer_name/state"]
     Type string : printer_serial "printer_serial" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/printer_serial/state"]
     Type number : temp "temp" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/temp/state"]
     Type string : tray_0_material "tray_0 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_0/state"]
     Type string : tray_1_material "tray_1 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_1/state"]
     Type string : tray_2_material "tray_2 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_2/state"]
     Type string : tray_3_material "tray_3 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_3/state"]
     Type string : tray_0_color "tray_0 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_0/attr", transformationPattern="JSONPATH:$.color", ValueTransformation="REGEX:(.{7}).*"]
     Type string : tray_1_color "tray_1 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_1/attr", transformationPattern="JSONPATH:$.color"]
     Type string : tray_2_color "tray_2 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_2/attr", transformationPattern="JSONPATH:$.color"]
     Type string : tray_3_color "tray_3 Material" [stateTopic="openhab/sensor/AMS_0_Bambu_X1C/tray_3/attr", transformationPattern="JSONPATH:$.color"]
    
}

```

again this is amazing amount of work

---

<div class="post-metadata">

**Author:** ![sidamos](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/ba9def/32.png) [@sidamos](https://community.openhab.org/u/sidamos)\
**Post date:** [June 30, 2023, 4:41pm UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/9 "2023-06-30T16:41:46Z")

</div>

Is this also working with the P1P?

---

<div class="post-metadata">

**Author:** ![Franco](https://community.openhab.org/user_avatar/community.openhab.org/franco/32/73665_2.png) [@Franco](https://community.openhab.org/u/Franco)\
**Post date:** [June 30, 2023, 4:54pm UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/10 "2023-06-30T16:54:12Z")

</div>

Yes, i read somewhere thats its working with few differences depending in the hardware

---

<div class="post-metadata">

**Author:** ![Franco](https://community.openhab.org/user_avatar/community.openhab.org/franco/32/73665_2.png) [@Franco](https://community.openhab.org/u/Franco)\
**Post date:** [August 30, 2023, 7:07pm UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/11 "2023-08-30T19:07:05Z")

</div>

Hey,

due to several awesome updates from bambu lab, also the mqtt stopped working for me.

But fortunately there are updates for the node red flow. Even better i found the website of the original developer of the code. Theres an configurator to just generate the flow ready to run.

> **[Add BambuLabs Printer to Home Assistant](https://wolfwithsword.com/bambulab-to-home-assistant-nodered-configurator/)**
>
> Connect your Bambu Lab 3D Printer to Home Assistant using Node Red and MQTT!

Really awesome work!

Just used it and my most important items like state and progress are working fine instant.  
Also the flow itself looks much more structured know and brings several improvements.

Also looks like P1S is supported in experimental version.

---

<div class="post-metadata">

**Author:** ![helipus](https://community.openhab.org/letter_avatar_proxy/v4/letter/h/958977/32.png) [@helipus](https://community.openhab.org/u/helipus)\
**Post date:** [November 22, 2023, 1:58pm UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/12 "2023-11-22T13:58:31Z")

</div>

Would someone make the community happy and write a Bambu Lab Binding for openhab? This would be so awesome!

---

<div class="post-metadata">

**Author:** ![jimtng](https://community.openhab.org/user_avatar/community.openhab.org/jimtng/32/98543_2.png) [@jimtng](https://community.openhab.org/u/jimtng)\
**Post date:** [January 23, 2024, 6:34am UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/13 "2024-01-23T06:34:20Z")

</div>

I’d prefer not to have to use nodered. I’ll have to look into how it’s done within that flow.

---

<div class="post-metadata">

**Author:** ![fals3illusion](https://community.openhab.org/user_avatar/community.openhab.org/fals3illusion/32/18884_2.png) [@fals3illusion](https://community.openhab.org/u/fals3illusion)\
**Post date:** [January 24, 2024, 4:34am UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/14 "2024-01-24T04:34:37Z")

</div>

I got mine working, i am using node red as a middle man and that is updating everything to my mqtt server. I am using my own broker, not the one that the printer has for everything.

Follow this link to get the node red flow

> **[Add BambuLabs Printer to Home Assistant](https://wolfwithsword.com/bambulab-to-home-assistant-nodered-configurator/)**
>
> Connect your Bambu Lab 3D Printer to Home Assistant using Node Red and MQTT!

---

<div class="post-metadata">

**Author:** ![Franco](https://community.openhab.org/user_avatar/community.openhab.org/franco/32/73665_2.png) [@Franco](https://community.openhab.org/u/Franco)\
**Post date:** [January 24, 2024, 5:04am UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/15 "2024-01-24T05:04:35Z")

</div>

Sounds like you want to connect direct to the printer but I think that’s not possible.

As mentioned, you need to setup node red and connect it to your own mqtt broker. Therefore you also need the credentials of your broker, not of the Bambu cloud.

With the link above you can enter all your relevant data like credentials, lan code, broker IP, etc. To import the node into your node red.

Little additon:  
You also can get the MQTT informations without node red but the problem is that there are a lot of transformations in the mqtt structure. The node does a lot of transformation here so i highly recommend to not use bambus mqtt without.

---

<div class="post-metadata">

**Author:** ![hafniumzinc](https://community.openhab.org/letter_avatar_proxy/v4/letter/h/b9bd4f/32.png) [@hafniumzinc](https://community.openhab.org/u/hafniumzinc)\
**Post date:** [November 20, 2024, 7:10pm UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/16 "2024-11-20T19:10:42Z")

</div>

Here are the two Thing configurations we use to monitor prints on a Bambu Labs X1C printer with AMS.

You will need the MQTT Binding and the JSONPATH Transformation Service installed.

## MQTT broker Thing

```yaml
UID: mqtt:broker:x1c
label: X1C
thingTypeUID: mqtt:broker
configuration:
  secure: true
  password: <YOUR_ACCESS_CODE>
  protocol: TCP
  port: 8883
  host: <YOUR_PRINTER_IP_ADDRESS>
  username: bblp

```

## MQTT Thing

Replace `00M09A360201584` with the serial number of your printer

```yaml
UID: mqtt:topic:x1c:x1c_data
label: X1C Data
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:x1c
channels:
  - id: layer_num
    channelTypeUID: mqtt:number
    label: Current layer number
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.layer_num
  - id: mc_percent
    channelTypeUID: mqtt:number
    label: Percent complete
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.mc_percent
  - id: mc_reminaing_time
    channelTypeUID: mqtt:string
    label: Time remaining
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.mc_remaining_time
  - id: subtask_name
    channelTypeUID: mqtt:string
    label: Print name
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.subtask_name
  - id: total_layer_num
    channelTypeUID: mqtt:number
    label: Total layers
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.total_layer_num
  - id: print_error
    channelTypeUID: mqtt:number
    label: Print error
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.print_error
  - id: AMSSlot0
    channelTypeUID: mqtt:string
    label: AMS Slot 0
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.ams.ams[0].tray[0].tray_type
  - id: AMSSlot1
    channelTypeUID: mqtt:string
    label: AMS Slot 1
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.ams.ams[0].tray[1].tray_type
  - id: AMSSlot2
    channelTypeUID: mqtt:string
    label: AMS Slot 2
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.ams.ams[0].tray[2].tray_type
  - id: AMSSlot3
    channelTypeUID: mqtt:string
    label: AMS Slot 3
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.ams.ams[0].tray[3].tray_type
  - id: gcode_state
    channelTypeUID: mqtt:string
    label: GCode State
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.gcode_state
  - id: AMSSlot0Colour
    channelTypeUID: mqtt:string
    label: AMS Slot 0 Colour
    description: ""
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.ams.ams[0].tray[0].tray_color
  - id: AMSSlot1Colour
    channelTypeUID: mqtt:string
    label: AMS Slot 1 Colour
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.ams.ams[0].tray[1].tray_color
  - id: AMSSlot2Colour
    channelTypeUID: mqtt:string
    label: AMS Slot 2 Colour
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.ams.ams[0].tray[2].tray_color
  - id: AMSSlot3Colour
    channelTypeUID: mqtt:string
    label: AMS Slot 3 Colour
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.ams.ams[0].tray[3].tray_color
  - id: bed_temper
    channelTypeUID: mqtt:number
    label: Bed temperature
    description: ""
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.bed_temper
  - id: chamber_temper
    channelTypeUID: mqtt:number
    label: Chamber temperature
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.chamber_temper
  - id: nozzle_temper
    channelTypeUID: mqtt:number
    label: Nozzle temperature
    configuration:
      stateTopic: device/00M09A360201584/report
      transformationPattern: JSONPATH:$.print.nozzle_temper

```

---

<div class="post-metadata">

**Author:** ![rpwong](https://community.openhab.org/user_avatar/community.openhab.org/rpwong/32/36036_2.png) [@rpwong](https://community.openhab.org/u/rpwong)\
**Post date:** [November 20, 2024, 7:39pm UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/17 "2024-11-20T19:39:51Z")

</div>

There’s also an OctoPrint plugin for Bambu Labs. It connects to the printer over WiFi.

[https://github.com/jneilliii/OctoPrint-BambuPrinter](https://github.com/jneilliii/OctoPrint-BambuPrinter)

I already had OctoPrint connected to openHAB using MQTT, so this made for a relatively easy transition.

---

<div class="post-metadata">

**Author:** ![Sascha\_Billian](https://community.openhab.org/user_avatar/community.openhab.org/sascha_billian/32/17056_2.png) [@Sascha\_Billian](https://community.openhab.org/u/Sascha_Billian)\
**Post date:** [January 30, 2025, 9:15pm UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/18 "2025-01-30T21:15:42Z")

</div>

Many thanks for this - works flawlessly - at least with the current firmware of the printer 😉 . If you want the filament color displayed e.g. like this:

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/c/4/c41660880bdff7cd94ba2e3af77f554a253676a7.png)  
you need to convert the strings from the color channel to an HSB. I’ve used this script here (with a little help from ChatGPT because i’m lazy):

```yaml
(function(input) {
    // Ensure the input is a string and has the expected length
    if (typeof input !== 'string' || input.length !== 8) {
        return "Invalid Input"; // Handle invalid input length
    }

    // Extract RGB and Alpha components from the input hex string
    var redHex = input.substring(0, 2);
    var greenHex = input.substring(2, 4);
    var blueHex = input.substring(4, 6);
    var alphaHex = input.substring(6, 8);

    // Convert the hex RGB values to decimal
    var red = parseInt(redHex, 16);
    var green = parseInt(greenHex, 16);
    var blue = parseInt(blueHex, 16);

    // Convert the alpha hex value to a decimal float (0 to 1 range)
    var alpha = parseInt(alphaHex, 16) / 255;
		
		//normalize RGB
		var r = red / 255
		var g = green / 255
		var b = blue / 255
		
		var max = Math.max(r, g, b);
    var min = Math.min(r, g, b);
    var delta = max - min;
		
		var h = 0;
		if (delta !== 0) {
			if (max === r) {
				h = (g - b) / delta;
			} else if (max === g) {
				h = 2 + (b - r) / delta;
			} else {
				h = 4 + (r - g) / delta;
			}
				h = (h * 60) % 360;
			if (h < 0) h += 360;
    }

		// Calculate Saturation
		var s = (max === 0) ? 0 : (delta / max);

		// Calculate Brightness
		var v = max;
		
		h = parseFloat(h.toFixed(1));
		s = parseFloat((s * 100).toFixed(1));
		v = parseFloat((v * 100).toFixed(1));

    // Return HSB as an array
    //return [h, s * 100, v * 100];

    // Return the RGBA formatted string
    return `${h},${s},${v}`;
		
})(input);

```

and this script then is used for the channel profile

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/2/e/2e84077f86a1dcc51f1e0a37ff004b1575e301d6.png)

---

<div class="post-metadata">

**Author:** ![Franco](https://community.openhab.org/user_avatar/community.openhab.org/franco/32/73665_2.png) [@Franco](https://community.openhab.org/u/Franco)\
**Post date:** [January 30, 2025, 9:30pm UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/19 "2025-01-30T21:30:20Z")

</div>

Wow, that’s awesome. I was thinking before how to display the colors but that’s not so easy.

---

<div class="post-metadata">

**Author:** ![dheneghan](https://community.openhab.org/letter_avatar_proxy/v4/letter/d/65b543/32.png) [@dheneghan](https://community.openhab.org/u/dheneghan)\
**Post date:** [January 30, 2026, 12:24pm UTC](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381/20 "2026-01-30T12:24:31Z")

</div>

> [@Sascha\_Billian](#):
>
> I’ve used this script here

I maybe being a little dumb here, but how / where do you create the script? Is it a matter of manually creating a file called (in your example) BambuLabRGBA.js into the ‘scripts’ folder’, or can this be created through and managed through UI?

Thanks

[Next page](https://community.openhab.org/t/bambu-lab-3d-printer-integraton/146381.md?page=2)
