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:
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:
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:
{
"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.