NEWS
Bambu lab 3d Drucker MQTT Integration
-
@darkdevil Hast Du einen speziellen User eingegeben? Auch alle Haken in dem mqtt Einstellungen rausgemacht? - Hast Du die mqtt-In Nodes im NR Adapter deaktiviert? Hast Du mit Node Red eine Verbindung zum Drucker bekommen?
Es sieht ja so aus, als ob Du kurzfristig eine Verbindung bekommst.
-
@mickym im Adapter habe ich einen Benutzer angegeben, den ich zum verbinden einer ftp session gefunden habe.
Node Red Instanz war zum testen deaktiviert.im NR scheint es (was die Verbindung angeht) zu funktionieren:
-
@darkdevil Hast Du denn einen Benutzer in der KonfigurationsNode zum Mqtt eingegeben?
Steht in dieser Konfig Node was drin
oder ist das auch leer?
Wenn das leer ist, dann lösch den Benutzer und das Passwort aus dem Mqtt-Adapter wieder raus.Diese node findest Du in Node Red unter den Konfigurationsnodes
Wenn das alles nicht tut - dann schau nochmal was in der mqtt-in Node rein kommt. Wenn da was kommt, kannst Du das auch 1:1 in einen datenpunkt schrieben und dann kannst Blockly nutzen, wenn Du die Aufbereitung des Flows nicht haben willst.
-
@mickym die Konfigurations Node ist bei mir auch leer.
Ich habe es nun wieder aus dem MQTT Adapter gelöscht --> gleiches Ergebnis, kurz grün, dann wieder rot und der log schaut auch gleich aus. -
@mickym Gut häng doch mal hinter die JSON Node in dem Flow eine Debug Node und schau ob da was rauskommt.
Also hinter diese JSON Node eine Debug Node und dann schauen, ob was im Debug Fenster ankommt.
-
[ { "id": "fbda6ab16491b918", "type": "tab", "label": "BambuLab MQTT", "disabled": false, "info": "", "env": [] }, { "id": "b63936933d6718a9", "type": "group", "z": "fbda6ab16491b918", "name": "Bambu MQTT Relay", "style": { "stroke": "#92d04f", "label": true, "color": "#92d04f" }, "nodes": [ "85a9b62dec56686f", "f0ac48e8460b12a0", "5c367f2212abe141", "40155163e3d59c06", "308c7be0f82f461d", "39a4770fa1fc1777", "3da211fd02aff2b9", "5678a3ce4a8f5d67", "26aa40960854ec51", "e12f341a9e40698e", "fda8b9ba79fa309e", "1e6068e0118d2dfd", "5e6a6e6ea5ca4541", "300dd4c827f5abcc", "c7595281a2fe5bc1", "95dd1a5d886b82ca", "7f3dad831d862a52", "775372f61de286fa", "38048b141dacd8da", "ea10b24f970624c1", "36959b72c70ac04b", "351620dbc0c937e8", "6bc6130f6f75dbd9", "91c69f3a14b529e8", "4de3085f3b41fba0", "e1c99f8d68c8e5da", "97073d2f9837be3b", "33d641172ea15f52", "2b4a89cd577c152b", "e1ed1e0da67cb538", "4f2d53943d36ead0", "df4d56238cfce43d", "549ec2b83d24e9dd", "6e4e7051841b05d2", "0af828ce7b9fc6ef", "d0210d5fb650ba72", "4c6205700a4bfb9d", "48a003b2ef74e4c8", "14b042af241de5a3", "6c254b07b897c7b0", "baeafcd14d273f74", "02885eaa14bd1bd7", "d7ddd0f8a1dda1f2", "7737b523af5be617", "42c658325fab7ba4", "ee18800da74cdc68", "bfae5ba327c7de3d", "13046cc6bb2536a2", "350cde4dd40f370a", "61ee03b8aee13566", "8244c1008745f8df", "e4fd22daebe2148c", "d7fd1c370524b77c", "c119f821e0acfd65", "b640027ca87eeb35", "8d1d3c87020d67e3", "72dac0f433d8f194", "5561f934d8e6effa", "938202b3e4751f79", "01b54b49661354ed", "7612824c458d393d", "50e11989454e7893", "e79a30aeed48dd69", "c31bf5134ba91b2d", "155c79ce29b03f6e", "a4449d2df258142b", "033f118fea045668", "633c649e4b780650", "4e0ebad5eb247125", "c66ef79ed4be761e", "acede6b98324ff69", "d5ca9d9e44ae0bc4", "5e3181a46a9545b5", "e9a0d71f1da0b460", "09b4a36ef01b1e79", "2f2e0d476582dc0e" ], "x": 14, "y": -1, "w": 2252, "h": 1007 }, { "id": "e79a30aeed48dd69", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 1420, "y": 980, "wires": [ [] ] }, { "id": "c31bf5134ba91b2d", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 500, "y": 980, "wires": [ [] ] }, { "id": "155c79ce29b03f6e", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 460, "y": 360, "wires": [ [] ] }, { "id": "b640027ca87eeb35", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 1000, "y": 580, "wires": [ [ "baeafcd14d273f74" ] ] }, { "id": "8d1d3c87020d67e3", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 1540, "y": 360, "wires": [ [ "4f2d53943d36ead0" ] ] }, { "id": "72dac0f433d8f194", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 840, "y": 780, "wires": [ [ "300dd4c827f5abcc", "91c69f3a14b529e8", "2b4a89cd577c152b" ] ] }, { "id": "5561f934d8e6effa", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 1360, "y": 800, "wires": [ [ "7612824c458d393d" ] ] }, { "id": "938202b3e4751f79", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 1000, "y": 820, "wires": [ [ "6bc6130f6f75dbd9" ] ] }, { "id": "01b54b49661354ed", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 1560, "y": 620, "wires": [ [ "df4d56238cfce43d", "549ec2b83d24e9dd" ] ] }, { "id": "7612824c458d393d", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 1860, "y": 800, "wires": [ [ "d5ca9d9e44ae0bc4" ] ] }, { "id": "50e11989454e7893", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 1791, "y": 654, "wires": [ [ "7612824c458d393d" ] ] }, { "id": "a4449d2df258142b", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 460, "y": 260, "wires": [ [ "40155163e3d59c06" ] ] }, { "id": "033f118fea045668", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 560, "y": 60, "wires": [ [ "d7fd1c370524b77c" ] ] }, { "id": "633c649e4b780650", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 1080, "y": 800, "wires": [ [ "300dd4c827f5abcc", "6bc6130f6f75dbd9" ] ] }, { "id": "4e0ebad5eb247125", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 940, "y": 500, "wires": [ [ "c66ef79ed4be761e" ] ] }, { "id": "c66ef79ed4be761e", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 1060, "y": 500, "wires": [ [ "633c649e4b780650" ] ] }, { "id": "acede6b98324ff69", "type": "junction", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "x": 500, "y": 200, "wires": [ [ "033f118fea045668" ] ] }, { "id": "85a9b62dec56686f", "type": "mqtt in", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Bambu X1C", "topic": "device/hier seriennummer eintragen/report", "qos": "2", "datatype": "json", "broker": "84f61d394ba2ab34", "nl": false, "rap": true, "rh": 0, "inputs": 0, "x": 130, "y": 220, "wires": [ [ "5c367f2212abe141" ] ] }, { "id": "f0ac48e8460b12a0", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Inject Machine Details", "func": "let machine_name = \"X1C\";\nlet machine_serial = \"hier seriennummer eintragen\";\nlet manufacturer = \"Bambu Labs\";\nlet model = \"X1 Carbon\"\nif(msg.payload.mc_print != undefined) {\n msg.payload.mc_print.machine_name = machine_name;\n msg.payload.mc_print.machine_serial = machine_serial;\n msg.payload.mc_print.manufacturer = manufacturer;\n if(msg.payload.mc_print.param.includes(\"[AMS]\")) {\n msg.payload.mc_print.model = \"AMS\";\n }\n else {\n msg.payload.mc_print.model = model;\n }\n}\n\nif (msg.payload.print != undefined) {\n msg.payload.print.machine_name = machine_name;\n msg.payload.print.machine_serial = machine_serial;\n msg.payload.print.manufacturer = manufacturer;\n msg.payload.print.model = model;\n\n if (msg.payload.print.ams !== undefined) {\n for (var ams of msg.payload.print.ams.ams) {\n ams.printer_name = machine_name\n ams.printer_serial = machine_serial\n }\n }\n msg.payload.print.status = \"online\";\n msg.payload.print.reset_filter = \"\";\n}\n\n\n\nnode.send(msg);\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 180, "y": 260, "wires": [ [ "a4449d2df258142b" ] ] }, { "id": "5c367f2212abe141", "type": "json", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "property": "payload.print", "action": "obj", "pretty": false, "x": 370, "y": 220, "wires": [ [ "f0ac48e8460b12a0" ] ] }, { "id": "40155163e3d59c06", "type": "switch", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "hask", "v": "mc_print", "vt": "str" }, { "t": "hask", "v": "print", "vt": "str" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 3, "x": 610, "y": 240, "wires": [ [ "acede6b98324ff69" ], [ "ee18800da74cdc68" ], [] ] }, { "id": "308c7be0f82f461d", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Known Filament Translator", "func": "// Bambu spools are not needed for translation if they have the rfid tags\n// but this can be used to overwrite them for HA displaying only\n// This only overwrites the tray_type and tray_sub_brands, if you want other fields overwritten you can add them\n// e.g. tray_diameter, tray_weight, temps etc\n\nvar PolyLite_PLA = {\n \"tray_info_idx\": \"GFL00\", \n \"tray_type\": \"PLA\",\n \"tray_sub_brands\": \"PolyLite PLA\"\n}\n\nvar PolyTerra_PLA = {\n \"tray_info_idx\": \"GFL01\",\n \"tray_type\": \"PLA\",\n \"tray_sub_brands\": \"PolyTerra PLA\"\n}\n\nvar Bambu_ABS = {\n \"tray_info_idx\": \"GFB00\",\n \"tray_type\": \"ABS\"\n}\n\nvar Bambu_PACF = {\n \"tray_info_idx\": \"GFN03\",\n \"tray_type\": \"PC-CF\"\n}\n\nvar Bambu_PC = {\n \"tray_info_idx\": \"GFC00\",\n \"tray_type\": \"PC\"\n}\n\nvar Bambu_PLA_Basic = {\n \"tray_info_idx\": \"GFA00\",\n \"tray_type\": \"PLA\",\n \"tray_sub_brands\": \"PLA Basic\"\n}\nvar Bambu_PLA_Matte = {\n \"tray_info_idx\": \"GFA01\",\n \"tray_type\": \"PLA\",\n \"tray_sub_brands\": \"PLA Matte\"\n}\n\nvar Support_G = {\n \"tray_info_idx\": \"GFS01\",\n \"tray_type\": \"Support\",\n \"tray_sub_brands\": \"Support G\"\n}\n\nvar Support_W = {\n \"tray_info_idx\": \"GFS00\",\n \"tray_type\": \"Support\",\n \"tray_sub_brands\": \"Support W\"\n}\n\nvar Bambu_TPU_95A = {\n \"tray_info_idx\": \"GFU01\",\n \"tray_type\": \"TPU\",\n \"tray_sub_brands\": \"TPU 95A\"\n}\n\nvar Generic_ABS = {\n \"tray_info_idx\": \"GFB99\",\n \"tray_type\": \"ABS\",\n \"tray_sub_brands\": \"ABS\"\n}\n\nvar Generic_ASA = {\n \"tray_info_idx\": \"GFB98\",\n \"tray_type\": \"ASA\",\n \"tray_sub_brands\": \"ASA\"\n}\n\nvar Generic_PA = {\n \"tray_info_idx\": \"GFN99\",\n \"tray_type\": \"PA\",\n \"tray_sub_brands\": \"PA\"\n}\n\nvar Generic_PACF = {\n \"tray_info_idx\": \"GFN98\",\n \"tray_type\": \"PA-CF\",\n \"tray_sub_brands\": \"PA-CF\"\n}\n\nvar Generic_PC = {\n \"tray_info_idx\": \"GFC99\",\n \"tray_type\": \"PC\",\n \"tray_sub_brands\": \"PC\"\n} \n\nvar Generic_PETG = {\n \"tray_info_idx\": \"GFG99\",\n \"tray_type\": \"PETG\",\n \"tray_sub_brands\": \"PETG\"\n}\nvar Generic_PLA = {\n \"tray_info_idx\": \"GFL99\",\n \"tray_type\": \"PLA\",\n \"tray_sub_brands\": \"PLA\"\n}\nvar Generic_PLACF = {\n \"tray_info_idx\": \"GFL98\",\n \"tray_type\": \"PLA-CF\",\n \"tray_sub_brands\": \"PLA-CF\"\n}\nvar Generic_PVA = {\n \"tray_info_idx\": \"GFS99\",\n \"tray_type\": \"PVA\",\n \"tray_sub_brands\": \"PVA\"\n}\nvar Generic_TPU = {\n \"tray_info_idx\": \"GFU99\",\n \"tray_type\": \"TPU\",\n \"tray_sub_brands\": \"TPU\"\n}\n\nvar filament_library = {\n \"GFU99\": Generic_TPU,\n \"GFS99\": Generic_PVA,\n \"GFL98\": Generic_PLACF,\n \"GFL99\": Generic_PLA,\n \"GFG99\": Generic_PETG,\n \"GFC99\": Generic_PC,\n \"GFN98\": Generic_PACF,\n \"GFN99\": Generic_PA,\n \"GFB98\": Generic_ASA,\n \"GFB99\": Generic_ABS,\n \"GFU01\": Bambu_TPU_95A,\n \"GFS00\": Support_W,\n \"GFS01\": Support_G,\n \"GFA01\": Bambu_PLA_Matte,\n \"GFA00\": Bambu_PLA_Basic,\n \"GFC00\": Bambu_PC,\n \"GFN03\": Bambu_PACF,\n \"GFB00\": Bambu_ABS,\n \"GFL01\": PolyTerra_PLA,\n \"GFL00\": PolyLite_PLA\n}\n\nif (msg.payload.print.ams !== undefined) {\n for (var ams of msg.payload.print.ams.ams) {\n for (var tray of ams.tray) {\n if (tray.tray_info_idx !== undefined && tray.tray_info_idx !== \"\") {\n if(filament_library.hasOwnProperty(tray.tray_info_idx)) {\n var match = filament_library[tray.tray_info_idx];\n tray.tray_type = match.tray_type;\n tray.tray_sub_brands = match.tray_sub_brands;\n if (tray.tray_diameter == \"0.00\") {\n tray.tray_diameter = \"1.75\";\n }\n }\n }\n }\n }\n}\n\nnode.send(msg);", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 680, "y": 300, "wires": [ [ "39a4770fa1fc1777" ] ] }, { "id": "39a4770fa1fc1777", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Fan Speed Translator", "func": "var percentages = {\n \"0\": 0,\n \"1\": 10,\n \"2\": 20,\n \"4\": 30,\n \"5\": 40,\n \"7\": 50,\n \"9\": 60,\n \"10\": 70,\n \"12\": 80,\n \"13\": 90,\n \"15\": 100\n}\n\n//msg.payload.print.big_fan1_speed_pct = percentages[msg.payload.print.big_fan1_speed]\n//msg.payload.print.big_fan2_speed_pct = percentages[msg.payload.print.big_fan2_speed]\n//msg.payload.print.heatbreak_fan_speed_pct = percentages[msg.payload.print.heatbreak_fan_speed]\n//msg.payload.print.cooling_fan_speed_pct = percentages[msg.payload.print.cooling_fan_speed]\n\n// Overwrite\nmsg.payload.print.big_fan1_speed = percentages[msg.payload.print.big_fan1_speed]\nmsg.payload.print.big_fan2_speed = percentages[msg.payload.print.big_fan2_speed]\nmsg.payload.print.heatbreak_fan_speed = percentages[msg.payload.print.heatbreak_fan_speed]\nmsg.payload.print.cooling_fan_speed = percentages[msg.payload.print.cooling_fan_speed]\n\n\nnode.send(msg)", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 660, "y": 340, "wires": [ [ "3da211fd02aff2b9" ] ] }, { "id": "3da211fd02aff2b9", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Set AMS Tray Statuses", "func": "\nif (msg.payload.print.ams != undefined && msg.payload.print.ams.tray_now !== undefined) {\n for (var ams of msg.payload.print.ams.ams) {\n for (var tray of ams.tray) {\n if (tray.tray_type == undefined || tray.tray_type == \"\") {\n tray.tray_type = \"Empty\";\n tray.tray_color = \"#808080\";\n } \n else {\n tray.tray_color = \"#\" + tray.tray_color;\n }\n\n tray.in_use = false;\n\n var id = parseInt(tray.id);\n var used_id = parseInt(msg.payload.print.ams.tray_now);\n\n if (used_id == (id + 4* parseInt(ams.id))) {\n tray.in_use = true;\n }\n\n tray.ams_id = ams.id;\n }\n }\n}\nnode.send(msg);\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 670, "y": 380, "wires": [ [ "26aa40960854ec51" ] ] }, { "id": "5678a3ce4a8f5d67", "type": "change", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Primary Organize", "rules": [ { "t": "move", "p": "payload.print", "pt": "msg", "to": "payload.printer", "tot": "msg" }, { "t": "delete", "p": "payload.print", "pt": "msg" }, { "t": "move", "p": "payload.printer.ams", "pt": "msg", "to": "payload.ams", "tot": "msg" }, { "t": "delete", "p": "payload.printer.lights_report", "pt": "msg" }, { "t": "delete", "p": "payload.printer.spd_lvl", "pt": "msg" }, { "t": "delete", "p": "payload.printer.spd_mag", "pt": "msg" }, { "t": "move", "p": "payload.printer.xcam_status", "pt": "msg", "to": "payload.printer.xcam.status", "tot": "msg" }, { "t": "set", "p": "payload.printer.ams_count", "pt": "msg", "to": "$count(msg.payload.ams.ams)\t", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 650, "y": 540, "wires": [ [ "1e6068e0118d2dfd" ] ] }, { "id": "26aa40960854ec51", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Organize Lights", "func": "var lights = {};\nif (msg.payload.print.lights_report !== undefined) {\n for (var element of msg.payload.print.lights_report) {\n lights[element.node] = element.mode;\n }\n}\nmsg.payload.print.lights = lights\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 640, "y": 420, "wires": [ [ "e12f341a9e40698e" ] ] }, { "id": "e12f341a9e40698e", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Stage Parser", "func": "\nfunction parseAction(actionId) {\n if(actionId === undefined) {\n return \"\";\n }\n switch (actionId) {\n case -2:\n return \"Offline\";\n case -1:\n return \"Idle\";\n case 0:\n return \"Printing\"; // idle or printing\n case 1:\n return \"Auto bed leveling\";\n case 2:\n return \"Heatbed preheating\";\n case 3:\n return \"Sweeping XY mech mode\";\n case 4:\n return \"Changing filament\";\n case 5:\n return \"M400 pause\";\n case 6:\n return \"Paused due to filament runout\";\n case 7:\n return \"Heating hotend\";\n case 8:\n return \"Calibrating extrusion\";\n case 9:\n return \"Scanning bed surface\";\n case 10:\n return \"Inspecting first layer\";\n case 11:\n return \"Identifying build plate type\";\n case 12:\n return \"Calibrating Micro Lidar\";\n case 13:\n return \"Homing toolhead\";\n case 14:\n return \"Cleaning nozzle tip\";\n case 15:\n return \"Checking extruder temperature\";\n case 16:\n return \"Printing was paused by the user\";\n case 17:\n return \"Pause of front cover falling\";\n case 18:\n return \"Calibrating the micro lidar\";\n case 19:\n return \"Calibrating extrusion flow\";\n case 20:\n return \"Paused due to nozzle temperature malfunction\";\n case 21:\n return \"Paused due to heat bed temperature malfunction\";\n default:\n return actionId.toString()\n }\n}\n\nvar current_action = parseAction(msg.payload.print.stg_cur);\n\nvar translated_stages = [];\nif(msg.payload.print.stg != undefined) {\n for (var stage of msg.payload.print.stg) {\n translated_stages.push(parseAction(stage))\n }\n}\n\n// Overwrite\nmsg.payload.print.stg_cur = current_action;\nmsg.payload.print.stg = translated_stages;\nnode.send(msg);", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 630, "y": 460, "wires": [ [ "fda8b9ba79fa309e" ] ] }, { "id": "fda8b9ba79fa309e", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Translate X1C Speed Profile", "func": "var spd = {}\nspd.level = msg.payload.print.spd_lvl;\nspd.modifier = msg.payload.print.spd_mag;\n\nif (msg.payload.print !== undefined) {\n switch (msg.payload.print.spd_lvl) {\n case 1:\n spd.profile = \"Silent\";\n break;\n case 2:\n spd.profile = \"Standard\";\n break;\n case 3:\n spd.profile = \"Sport\";\n break;\n case 4:\n spd.profile = \"Ludicrous\";\n break;\n default:\n spd.profile = \"Undefined\";\n break;\n }\n}\n\nmsg.payload.print.speed = spd;\ndelete msg.payload.print.spd;\n\nnode.send(msg);", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 680, "y": 500, "wires": [ [ "5678a3ce4a8f5d67" ] ] }, { "id": "1e6068e0118d2dfd", "type": "split", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "splt": "\\n", "spltType": "str", "arraySplt": 1, "arraySpltType": "len", "stream": false, "addname": "topic", "x": 610, "y": 580, "wires": [ [ "5e6a6e6ea5ca4541" ] ] }, { "id": "5e6a6e6ea5ca4541", "type": "switch", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "printer", "vt": "str" }, { "t": "eq", "v": "ams", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 730, "y": 580, "wires": [ [ "b640027ca87eeb35" ], [ "c7595281a2fe5bc1" ] ] }, { "id": "300dd4c827f5abcc", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "AMS Config", "func": "let data = {};\nlet payload = {};\nlet device = {};\n\nvar printer_name = \"X1C_\";\nprinter_name = printer_name + msg.machine_name.match(/AMS_\\d+_(.*)/)[1];\n\n// Filter UoM from payload\nif (msg.topic == \"wifi_signal\")\n msg.payload = msg.payload.match(/^-?\\d+/)[0];\n\n// Inject config\nif (msg.topic.match(/temper/)) {\n msg.device_class = \"temperature\";\n}\nif (msg.topic.match(/temp/)) {\n msg.device_class = \"temperature\";\n}\nif (msg.topic == \"wifi_signal\") {\n msg.device_class = \"signal_strength\"\n msg.unit_of_measurement = \"dBm\";\n}\n\nif(msg.topic == \"humidity\") {\n msg.device_class = \"humidity\";\n msg.unit_of_measurement = \"%\";\n}\n\nfunction getFriendlyName(str) {\n var i, word = str.split('_');\n for (i = 0; i < word.length; i++) {\n word[i] = word[i].charAt(0).toUpperCase() + word[i].slice(1);\n }\n return word.join(' ');\n}\n\nlet base_topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic;\ndata.topic = base_topic + \"/config\";\npayload.name = getFriendlyName(msg.topic);\n\ndevice.identifiers = [];\ndevice.identifiers[0] = msg.machine_name;\ndevice.manufacturer = \"Bambu Labs\";\ndevice.model = \"AMS\";\ndevice.name = msg.machine_name;\ndevice.via_device = printer_name;\n\n\npayload.device = device;\npayload.unique_id = msg.machine_name + \"_\" + msg.topic;\npayload.object_id = payload.unique_id;\n\n//payload.force_update = true;\n\nif (!msg.topic.includes(\"tray\")){\n //payload.expire_after = 3600;\n}\nelse {\n payload.icon = \"mdi:printer-3d-nozzle\";\n}\n\nif(msg.topic.match(/serial/)) {\n payload.icon = \"mdi:barcode\";\n}\nif (msg.topic == \"printer_name\") {\n payload.icon = \"mdi:printer-3d\";\n}\nif (msg.device_class != undefined)\n payload.device_class = msg.device_class;\n\nif (msg.unit_of_measurement != undefined)\n payload.unit_of_measurement = msg.unit_of_measurement;\n\nif (payload.device_class == \"temperature\") {\n payload.unit_of_measurement = \"°C\";\n payload.temperature_unit = \"°C\";\n}\n\nif (!msg.topic.includes(\"tray\")) {\n payload.availability_topic = \"iobroker/\" + \"sensor\" + \"/\" + printer_name + \"/\" + \"status\" + \"/state\";\n}\n\npayload.state_topic = base_topic + \"/state\";\npayload.json_attributes_topic = base_topic + \"/attr\";\ndata.payload = payload;\n\ndata.qos = 1;\ndata.retain = true;\nnode.send(data);", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1210, "y": 780, "wires": [ [ "5561f934d8e6effa" ] ] }, { "id": "c7595281a2fe5bc1", "type": "change", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Organize AMS", "rules": [ { "t": "move", "p": "payload.ams", "pt": "msg", "to": "ams", "tot": "msg" }, { "t": "delete", "p": "payload", "pt": "msg" }, { "t": "move", "p": "ams", "pt": "msg", "to": "payload", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 640, "y": 640, "wires": [ [ "95dd1a5d886b82ca" ] ] }, { "id": "95dd1a5d886b82ca", "type": "split", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "splt": "\\n", "spltType": "str", "arraySplt": 1, "arraySpltType": "len", "stream": false, "addname": "topic", "x": 610, "y": 680, "wires": [ [ "7f3dad831d862a52" ] ] }, { "id": "7f3dad831d862a52", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "ams", "func": "msg.topic = \"AMS\";//_\" + msg.payload.id;\n\nmsg.machine_name = msg.topic + \"_\" + msg.payload.id + \"_\" + msg.payload.printer_name;\nnode.send(msg);", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 730, "y": 680, "wires": [ [ "97073d2f9837be3b" ] ] }, { "id": "775372f61de286fa", "type": "change", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "rules": [ { "t": "set", "p": "payload.gcode_end_time", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1360, "y": 280, "wires": [ [ "38048b141dacd8da" ] ] }, { "id": "38048b141dacd8da", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Set EndTime", "func": "if (msg.payload.gcode_start_time !== \"N/A\" && msg.payload.gcode_end_time !== undefined && msg.payload.gcode_end_time != \"N/A\") {\n var endTime = msg.payload.gcode_end_time + ((parseInt(msg.payload.mc_remaining_time) * 60) * 1000);\n endTime = Math.round(endTime / 60000) * 60000;\n var startSeconds = msg.payload.gcode_start_epoch.toString().slice(0,-5);\n endTime = endTime + parseInt(startSeconds);\n msg.payload.gcode_end_time = endTime;\n msg.payload.gcode_start_time = parseInt(msg.payload.gcode_start_time);\n node.send(msg);\n}\nelse if (msg.payload.gcode_end_time == \"N/A\" || msg.payload.gcode_start_Time == \"N/A\") {\n msg.payload.gcode_start_time = \"N/A\";\n msg.payload.gcode_end_time = \"N/A\";\n node.send(msg);\n}\n\nif(msg.payload.gcode_start_time == \"N/A\") {\n msg.payload.gcode_end_time = \"N/A\";\n}\nelse {\n node.send(msg);\n}", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1290, "y": 320, "wires": [ [ "ea10b24f970624c1" ] ] }, { "id": "ea10b24f970624c1", "type": "switch", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "property": "payload.gcode_end_time", "propertyType": "msg", "rules": [ { "t": "eq", "v": "N/A", "vt": "str" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 1430, "y": 320, "wires": [ [ "8d1d3c87020d67e3" ], [ "c119f821e0acfd65" ] ] }, { "id": "36959b72c70ac04b", "type": "switch", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "property": "payload.gcode_start_time", "propertyType": "msg", "rules": [ { "t": "neq", "v": "N/A", "vt": "str" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 1090, "y": 240, "wires": [ [ "775372f61de286fa" ], [ "38048b141dacd8da" ] ] }, { "id": "351620dbc0c937e8", "type": "change", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Preserve Start Epoch", "rules": [ { "t": "set", "p": "payload.gcode_start_epoch", "pt": "msg", "to": "payload.gcode_start_time", "tot": "msg", "dc": true } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1140, "y": 200, "wires": [ [ "02885eaa14bd1bd7" ] ], "info": "This is useful to keep as it will act as\r\na unique ID for each print" }, { "id": "6bc6130f6f75dbd9", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "AMS State", "func": "// Filter UoM from payload\nif (msg.topic == \"wifi_signal\")\n msg.payload = msg.payload.match(/^-?\\d+/)[0];\nif (msg.topic.match(/tray_\\d+/)) {\n var oldTopic = msg.topic;\n msg.topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic + \"/attr\";\n node.send(msg);\n msg.topic = oldTopic;\n msg.payload = msg.payload.type;\n}\n\n\nmsg.topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic + \"/state\";\n\nnode.send(msg);", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1210, "y": 820, "wires": [ [ "5561f934d8e6effa" ] ] }, { "id": "91c69f3a14b529e8", "type": "split", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "splt": "\\n", "spltType": "str", "arraySplt": 1, "arraySpltType": "len", "stream": false, "addname": "topic", "x": 690, "y": 820, "wires": [ [ "4de3085f3b41fba0" ] ] }, { "id": "4de3085f3b41fba0", "type": "switch", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "property": "topic", "propertyType": "msg", "rules": [ { "t": "neq", "v": "tray", "vt": "str" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 810, "y": 820, "wires": [ [ "633c649e4b780650" ], [ "e1c99f8d68c8e5da" ] ] }, { "id": "e1c99f8d68c8e5da", "type": "split", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "splt": "\\n", "spltType": "str", "arraySplt": 1, "arraySpltType": "len", "stream": false, "addname": "topic", "x": 610, "y": 860, "wires": [ [ "33d641172ea15f52" ] ] }, { "id": "97073d2f9837be3b", "type": "change", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Change Humdiity Name", "rules": [ { "t": "move", "p": "payload.humidity", "pt": "msg", "to": "payload.humidity_level", "tot": "msg" }, { "t": "delete", "p": "payload.humidity", "pt": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 910, "y": 680, "wires": [ [ "72dac0f433d8f194" ] ] }, { "id": "33d641172ea15f52", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "tray", "func": "msg.topic = msg.topic + \"_\" + msg.payload.id;\nnode.send(msg);\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 730, "y": 860, "wires": [ [ "42c658325fab7ba4" ] ] }, { "id": "2b4a89cd577c152b", "type": "change", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Set Status", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "online", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 930, "y": 740, "wires": [ [ "938202b3e4751f79" ] ] }, { "id": "e1ed1e0da67cb538", "type": "comment", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "AMS", "info": "AMS Split", "x": 810, "y": 640, "wires": [] }, { "id": "4f2d53943d36ead0", "type": "change", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Remove Useless", "rules": [ { "t": "delete", "p": "payload.command", "pt": "msg" }, { "t": "delete", "p": "payload.force_upgrade", "pt": "msg" }, { "t": "delete", "p": "payload.hms", "pt": "msg" }, { "t": "delete", "p": "payload.home_flag", "pt": "msg" }, { "t": "delete", "p": "payload.hw_switch_state", "pt": "msg" }, { "t": "delete", "p": "payload.lifecycle", "pt": "msg" }, { "t": "delete", "p": "payload.online", "pt": "msg" }, { "t": "delete", "p": "payload.ams_rfid_status", "pt": "msg" }, { "t": "delete", "p": "payload.ams_status", "pt": "msg" }, { "t": "delete", "p": "payload.manufacturer", "pt": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1310, "y": 400, "wires": [ [ "6e4e7051841b05d2" ] ] }, { "id": "df4d56238cfce43d", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "X1C Config", "func": "let data = {};\nlet payload = {};\nlet device = {};\n\n// Filter UoM from payload\nif (msg.topic == \"wifi_signal\")\n msg.payload = msg.payload.match(/^-?\\d+/)[0];\n\n// Inject config\nif (msg.topic.match(/temperature/)) {\n msg.device_class = \"temperature\";\n}\nif (msg.topic == \"wifi_signal\") {\n msg.device_class = \"signal_strength\"\n msg.unit_of_measurement = \"dBm\";\n}\n\nif (msg.topic.match(/(.*)fan(.*)/) && msg.topic !== \"fan_gear\") {\n msg.unit_of_measurement = \"%\";\n msg.icon = \"mdi:fan\"\n}\nif (msg.topic.match(/serial/)) {\n msg.icon = \"mdi:barcode\";\n}\nif (msg.topic == \"status\" || msg.topic == \"print_state\") {\n payload.icon = \"mdi:printer-3d\";\n}\nif(msg.topic == \"sdcard\") {\n msg.icon = \"mdi:sd\"\n}\nif (msg.topic == \"print_progress\") {\n msg.unit_of_measurement = \"%\";\n}\nif(msg.topic == \"print_remaining_time\") {\n msg.unit_of_measurement = \"min\";\n msg.device_class = \"duration\";\n}\nelse if (msg.topic.match(/time/)) {\n msg.icon = \"mdi:clock\";\n}\nif(msg.topic == \"speed\") {\n msg.icon = \"mdi:speedometer\"\n}\n\n\nfunction getFriendlyName(str) {\n var i, word = str.split('_');\n for (i = 0; i < word.length; i++) {\n word[i] = word[i].charAt(0).toUpperCase() + word[i].slice(1);\n }\n return word.join(' ');\n}\n\nlet type = \"sensor\";\nif(msg.topic == \"chamber_light\") {\n type = \"light\";\n} \n\nif(msg.topic == \"reset_filter\") {\n type = \"button\";\n}\n\nlet base_topic = \"iobroker/\"+ type + \"/\" + msg.machine_name + \"/\" + msg.topic;\ndata.topic = base_topic + \"/config\";\npayload.name = getFriendlyName(msg.topic);\n\ndevice.identifiers = [];\ndevice.identifiers[0] = msg.machine_name;\ndevice.manufacturer = \"Bambu Labs\";\ndevice.model = msg.model;\ndevice.name = msg.machine_name;\n\nif( msg.icon != undefined) {\n payload.icon = msg.icon\n}\n\npayload.device = device;\npayload.unique_id = msg.machine_name + \"_\" + msg.topic;\npayload.object_id = payload.unique_id;\n\n//payload.force_update = true;\n//payload.expire_after = 3600;\n\n//if (msg.topic.match(/time/) || msg.topic.match(/epoch/)) {\n //payload.expire_after = 300;\n//}\n\nif (msg.device_class != undefined)\n payload.device_class = msg.device_class;\n\nif (msg.unit_of_measurement != undefined)\n payload.unit_of_measurement = msg.unit_of_measurement;\n\nif (payload.device_class == \"temperature\") {\n payload.unit_of_measurement = \"°C\";\n payload.temperature_unit = \"°C\";\n}\n\npayload.state_topic = base_topic + \"/state\";\npayload.json_attributes_topic = base_topic + \"/attr\";\nif (type == \"light\") {\n payload.command_topic = base_topic + \"/set\";\n delete payload.json_attributes_topic;\n}\n\nif (type == \"button\") {\n delete payload.state_topic;\n delete payload.json_attributes_topic;\n payload.command_topic = \"iobroker/\" + \"button\" + \"/\" + msg.machine_name + \"/\" + msg.topic;\n payload.availability_topic = \"iobroker/\" + \"sensor\" + \"/\" + msg.machine_name + \"/\" + \"status\" + \"/state\";\n}\n\nif (msg.topic == \"speed\") {\n payload.command_topic = \"iobroker/\" + \"select\" + \"/\" + msg.machine_name + \"/\" + msg.topic + \"/set\";\n payload.availability_topic = \"iobroker/\" + \"sensor\" + \"/\" + msg.machine_name + \"/\" + \"status\" + \"/state\";\n payload.options = [\"Silent\", \"Standard\", \"Sport\", \"Ludicrous\"];\n}\n\nif (msg.topic != \"status\" && msg.topic != \"print_status\"\n && msg.topic != \"machine_name\" && msg.topic != \"machine_serial\") {\n payload.availability_topic = \"iobroker/\" + \"sensor\" + \"/\" + msg.machine_name + \"/\" + \"status\" + \"/state\";\n\n}\n\ndata.payload = payload;\n\ndata.qos = 1;\ndata.retain = true;\n\nnode.send(data);", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1690, "y": 620, "wires": [ [ "50e11989454e7893" ] ] }, { "id": "549ec2b83d24e9dd", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "X1C State", "func": "// Filter UoM from payload\n\nif (msg.topic == \"wifi_signal\")\n msg.payload = msg.payload.match(/^-?\\d+/)[0];\nelse if (msg.topic == \"xcam\") {\n var oldTopic = msg.topic;\n msg.topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic + \"/attr\";\n node.send(msg);\n msg.topic = oldTopic;\n msg.payload = msg.payload.status;\n}\nelse if (msg.topic == \"upload\") {\n var oldTopic = msg.topic;\n msg.topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic + \"/attr\";\n node.send(msg);\n msg.topic = oldTopic;\n msg.payload = msg.payload.message;\n}\nelse if (msg.topic == \"upgrade_state\") {\n var oldTopic = msg.topic;\n msg.topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic + \"/attr\";\n node.send(msg);\n msg.topic = oldTopic;\n msg.payload = msg.payload.status;\n}\nelse if (msg.topic == \"stage\") {\n var oldTopic = msg.topic;\n msg.topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic + \"/attr\";\n \n var current = msg.payload.current;\n var prev = {};\n var count = 0;\n for (var stg of msg.payload.prev) {\n prev[count.toString()] = stg;\n count += 1;\n }\n msg.payload = prev;\n node.send(msg);\n msg.topic = oldTopic;\n msg.payload = current;\n}\nelse if (msg.topic == \"ipcam\") {\n var oldTopic = msg.topic;\n msg.topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic + \"/attr\";\n node.send(msg);\n msg.topic = oldTopic;\n msg.payload = msg.payload.ipcam_dev;\n}\nelse if (msg.topic == \"subtask\") {\n var oldTopic = msg.topic;\n msg.topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic + \"/attr\";\n node.send(msg);\n msg.topic = oldTopic;\n msg.payload = msg.payload.name;\n}\nelse if (msg.topic == \"print\") {\n var oldTopic = msg.topic;\n msg.topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic + \"/attr\";\n node.send(msg);\n msg.topic = oldTopic;\n msg.payload = msg.payload.type;\n} \nelse if (msg.topic == \"bed_temperature\") {\n var oldTopic = msg.topic;\n msg.topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic + \"/attr\";\n node.send(msg);\n msg.topic = oldTopic;\n msg.payload = msg.payload.temperature;\n}\nelse if (msg.topic == \"nozzle_temperature\") {\n var oldTopic = msg.topic;\n msg.topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic + \"/attr\";\n node.send(msg);\n msg.topic = oldTopic;\n msg.payload = msg.payload.temperature;\n}\nelse if (msg.topic == \"chamber_temperature\") {\n msg.payload = msg.payload.temperature;\n}\nelse if (msg.topic == \"gcode\") {\n var oldTopic = msg.topic;\n msg.topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic + \"/attr\";\n node.send(msg);\n msg.topic = oldTopic;\n msg.payload = msg.payload.file;\n}\nelse if (msg.topic == \"speed\") {\n var oldTopic = msg.topic;\n msg.topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic + \"/attr\";\n node.send(msg);\n msg.topic = oldTopic;\n msg.payload = msg.payload.profile;\n}\nelse if (msg.topic == \"chamber_light\") {\n msg.payload=msg.payload.toUpperCase();\n msg.topic = \"iobroker/light/\" + msg.machine_name + \"/\" + msg.topic + \"/state\";\n node.send(msg);\n return;\n}\nelse if (msg.topic == \"reset_filter\") {\n return;\n}\nmsg.topic = \"iobroker/sensor/\" + msg.machine_name + \"/\" + msg.topic + \"/state\";\n\nnode.send(msg);", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1690, "y": 660, "wires": [ [ "50e11989454e7893" ] ] }, { "id": "6e4e7051841b05d2", "type": "change", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Reorder Print Info", "rules": [ { "t": "move", "p": "payload.gcode_file", "pt": "msg", "to": "payload.gcode.file", "tot": "msg" }, { "t": "move", "p": "payload.gcode_file_prepare_percent", "pt": "msg", "to": "payload.gcode.file_prepare_percent", "tot": "msg" }, { "t": "move", "p": "payload.gcode_start_time", "pt": "msg", "to": "payload.print_start_time", "tot": "msg" }, { "t": "move", "p": "payload.gcode_end_time", "pt": "msg", "to": "payload.print_end_time", "tot": "msg" }, { "t": "move", "p": "payload.gcode_state", "pt": "msg", "to": "payload.print_status", "tot": "msg" }, { "t": "move", "p": "payload.mc_percent", "pt": "msg", "to": "payload.print_progress", "tot": "msg" }, { "t": "move", "p": "payload.mc_print_error_code", "pt": "msg", "to": "payload.print.error_code", "tot": "msg" }, { "t": "move", "p": "payload.mc_print_stage", "pt": "msg", "to": "payload.print.stage", "tot": "msg" }, { "t": "move", "p": "payload.mc_print_sub_stage", "pt": "msg", "to": "payload.print.substage", "tot": "msg" }, { "t": "move", "p": "payload.print_error", "pt": "msg", "to": "payload.print.error", "tot": "msg" }, { "t": "move", "p": "payload.print_gcode_action", "pt": "msg", "to": "payload.print.gcode_action", "tot": "msg" }, { "t": "move", "p": "payload.print_real_action", "pt": "msg", "to": "payload.print.real_action", "tot": "msg" }, { "t": "move", "p": "payload.print_type", "pt": "msg", "to": "payload.print.type", "tot": "msg" }, { "t": "move", "p": "payload.profile_id", "pt": "msg", "to": "payload.print.profile_id", "tot": "msg" }, { "t": "move", "p": "payload.project_id", "pt": "msg", "to": "payload.print.project_id", "tot": "msg" }, { "t": "move", "p": "payload.sequence_id", "pt": "msg", "to": "payload.print.sequence_id", "tot": "msg" }, { "t": "set", "p": "payload.print.task", "pt": "msg", "to": "payload.subtask_name", "tot": "msg" }, { "t": "move", "p": "payload.mc_remaining_time", "pt": "msg", "to": "payload.print_remaining_time", "tot": "msg" }, { "t": "move", "p": "payload.gcode_start_epoch", "pt": "msg", "to": "payload.print_start_epoch", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1310, "y": 440, "wires": [ [ "0af828ce7b9fc6ef" ] ] }, { "id": "0af828ce7b9fc6ef", "type": "change", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Reorder Other", "rules": [ { "t": "move", "p": "payload.stg_cur", "pt": "msg", "to": "payload.stage.current", "tot": "msg" }, { "t": "move", "p": "payload.stg", "pt": "msg", "to": "payload.stage.prev", "tot": "msg" }, { "t": "move", "p": "payload.subtask_id", "pt": "msg", "to": "payload.subtask.id", "tot": "msg" }, { "t": "move", "p": "payload.subtask_name", "pt": "msg", "to": "payload.subtask.name", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1300, "y": 480, "wires": [ [ "d0210d5fb650ba72" ] ] }, { "id": "d0210d5fb650ba72", "type": "change", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Reorder Temps and Fans", "rules": [ { "t": "move", "p": "payload.bed_target_temper", "pt": "msg", "to": "payload.bed_temperature.target_temperature", "tot": "msg" }, { "t": "move", "p": "payload.bed_temper", "pt": "msg", "to": "payload.bed_temperature.temperature", "tot": "msg" }, { "t": "move", "p": "payload.nozzle_temper", "pt": "msg", "to": "payload.nozzle_temperature.temperature", "tot": "msg" }, { "t": "move", "p": "payload.nozzle_target_temper", "pt": "msg", "to": "payload.nozzle_temperature.target_temperature", "tot": "msg" }, { "t": "move", "p": "payload.big_fan1_speed", "pt": "msg", "to": "payload.fans.big_fan1", "tot": "msg" }, { "t": "move", "p": "payload.big_fan2_speed", "pt": "msg", "to": "payload.fans.big_fan2", "tot": "msg" }, { "t": "move", "p": "payload.heatbreak_fan_speed", "pt": "msg", "to": "payload.fans.heatbreak_fan", "tot": "msg" }, { "t": "move", "p": "payload.cooling_fan_speed", "pt": "msg", "to": "payload.fans.cooling_fan", "tot": "msg" }, { "t": "move", "p": "payload.chamber_temper", "pt": "msg", "to": "payload.chamber_temperature.temperature", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1330, "y": 520, "wires": [ [ "48a003b2ef74e4c8" ] ] }, { "id": "4c6205700a4bfb9d", "type": "switch", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "lights", "vt": "str" }, { "t": "eq", "v": "fans", "vt": "str" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 3, "x": 1390, "y": 560, "wires": [ [ "14b042af241de5a3" ], [ "14b042af241de5a3" ], [ "01b54b49661354ed" ] ] }, { "id": "48a003b2ef74e4c8", "type": "split", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "splt": "\\n", "spltType": "str", "arraySplt": 1, "arraySpltType": "len", "stream": false, "addname": "topic", "x": 1270, "y": 560, "wires": [ [ "4c6205700a4bfb9d" ] ] }, { "id": "14b042af241de5a3", "type": "split", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "splt": "\\n", "spltType": "str", "arraySplt": 1, "arraySpltType": "len", "stream": false, "addname": "topic", "x": 1530, "y": 560, "wires": [ [ "01b54b49661354ed" ] ] }, { "id": "6c254b07b897c7b0", "type": "comment", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "X1C", "info": "", "x": 1090, "y": 280, "wires": [] }, { "id": "baeafcd14d273f74", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "x1c", "func": "msg.topic = \"X1C\";//_\" + msg.payload.id;\n\nmsg.machine_name = msg.topic + \"_\" + msg.payload.machine_name;\nmsg.model = \"X1 Carbon\";\nnode.send(msg);", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1090, "y": 160, "wires": [ [ "351620dbc0c937e8" ] ] }, { "id": "02885eaa14bd1bd7", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Fix Start Date", "func": "if ( msg.payload.gcode_state == \"IDLE\" ||\n msg.payload.gcode_start_time == \"0\" || msg.payload.gcode_start_time == \"N/A\") {\n msg.payload.gcode_start_time = \"N/A\";\n msg.payload.gcode_end_time = \"N/A\";\n}\nelse {\n msg.payload.gcode_start_time = msg.payload.gcode_start_time + \"000\";\n}\nnode.send(msg);", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1340, "y": 200, "wires": [ [ "36959b72c70ac04b" ] ] }, { "id": "d7ddd0f8a1dda1f2", "type": "status", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Connected Status", "scope": [ "85a9b62dec56686f" ], "x": 130, "y": 140, "wires": [ [ "7737b523af5be617" ] ] }, { "id": "7737b523af5be617", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Set Connection Global X1C", "func": "\nif (msg.status !== undefined && msg.status.text.includes(\"status.connected\")) {\n global.set(\"X1C_is_connected\", \"true\");\n\n} else {\n global.set(\"X1C_is_connected\", \"false\");\n}", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 210, "y": 180, "wires": [ [] ] }, { "id": "42c658325fab7ba4", "type": "change", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Change Attribute Names", "rules": [ { "t": "move", "p": "payload.tray_type", "pt": "msg", "to": "payload.type", "tot": "msg" }, { "t": "move", "p": "payload.tray_color", "pt": "msg", "to": "payload.color", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 910, "y": 860, "wires": [ [ "633c649e4b780650" ] ] }, { "id": "ee18800da74cdc68", "type": "switch", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "property": "payload.print.command", "propertyType": "msg", "rules": [ { "t": "eq", "v": "push_status", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 750, "y": 260, "wires": [ [ "308c7be0f82f461d" ] ] }, { "id": "bfae5ba327c7de3d", "type": "comment", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Filters", "info": "These switch statements act as filters.\n\nFirst one acts to split mc_print and print\nand others\n\nSecond is to only accept \"push_status\" commands.\nOtherwise \"gcode_line\" and others are sent.\n\n(Gcode line is, for example,\nchanging speed profile)", "x": 870, "y": 260, "wires": [] }, { "id": "13046cc6bb2536a2", "type": "comment", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Change Name/Serial Details", "info": "Change the printer name and serial\nin the following nodes\n\n\"Connected Status\" -> select proper MQTT in\n& Modify the function node after\n\n\"Inject Machine Details\" Function\n\n\"Inject OFFLINE\" Inject Node ->\n& the Switch immediately after\nfor the global-connected Status\n\nMQTT In and Out topics for printer\nand home-assistant's mqtt in(s)\n\n\"Set Speed Profile\" Function ->\nFor the global-connected Status\nsince for some reason \"Select\" type\ndoesn't like to be set unavailable\n\n", "x": 160, "y": 60, "wires": [] }, { "id": "350cde4dd40f370a", "type": "comment", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Change Timezone", "info": "Change to a valid timezone here", "x": 1750, "y": 280, "wires": [] }, { "id": "61ee03b8aee13566", "type": "comment", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "MC_Print", "info": "", "x": 540, "y": 40, "wires": [] }, { "id": "8244c1008745f8df", "type": "function", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Get AMS Humidity", "func": "if (msg.payload.mc_print != undefined && msg.payload.mc_print.command == \"push_info\") {\n if (msg.payload.mc_print.param != undefined && msg.payload.mc_print.param.startsWith(\"[AMS][TASK]\")) {\n if(msg.payload.mc_print.param.includes(\"humidity\")) {\n let param = msg.payload.mc_print.param;\n let amsId = param.match(/ams(\\d+) /)[1];\n let humidity = param.match(/humidity:(\\d+)%/)[1];\n\n msg.topic = \"AMS\";\n\n msg.machine_name = msg.topic + \"_\" + amsId + \"_\" + msg.payload.mc_print.machine_name;\n \n msg.payload = {\n \"humidity\": humidity\n }\n node.send(msg);\n }\n }\n}\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 870, "y": 60, "wires": [ [ "e4fd22daebe2148c" ] ] }, { "id": "e4fd22daebe2148c", "type": "split", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "splt": "\\n", "spltType": "str", "arraySplt": 1, "arraySpltType": "len", "stream": false, "addname": "topic", "x": 870, "y": 180, "wires": [ [ "4e0ebad5eb247125" ] ] }, { "id": "d7fd1c370524b77c", "type": "switch", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "property": "payload.mc_print.param", "propertyType": "msg", "rules": [ { "t": "cont", "v": "humidity", "vt": "str" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 690, "y": 60, "wires": [ [ "8244c1008745f8df" ], [] ] }, { "id": "c119f821e0acfd65", "type": "change", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Timezone Configuration", "rules": [ { "t": "set", "p": "timezone", "pt": "msg", "to": "America/Halifax", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1730, "y": 320, "wires": [ [ "e9a0d71f1da0b460" ] ] }, { "id": "d5ca9d9e44ae0bc4", "type": "rbe", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "func": "rbe", "gap": "", "start": "", "inout": "out", "septopics": true, "property": "payload", "topi": "topic", "x": 1950, "y": 800, "wires": [ [ "5e3181a46a9545b5" ] ] }, { "id": "5e3181a46a9545b5", "type": "switch", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "property": "topic", "propertyType": "msg", "rules": [ { "t": "neq", "v": "", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 2070, "y": 840, "wires": [ [ "09b4a36ef01b1e79", "2f2e0d476582dc0e" ] ] }, { "id": "e9a0d71f1da0b460", "type": "change", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "Convert Timestamps", "rules": [ { "t": "set", "p": "payload.gcode_start_time", "pt": "msg", "to": "$moment(msg.payload.gcode_start_time).tz(\"msg.timezone\").format(\"MMMM D, yyyy [at] h:mm A\")", "tot": "jsonata" }, { "t": "set", "p": "payload.gcode_end_time", "pt": "msg", "to": "$moment(msg.payload.gcode_end_time).tz(\"msg.timezone\").format(\"MMMM D, yyyy [at] h:mm A\")", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1320, "y": 360, "wires": [ [ "8d1d3c87020d67e3" ] ] }, { "id": "09b4a36ef01b1e79", "type": "debug", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "debug 3", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 2140, "y": 580, "wires": [] }, { "id": "2f2e0d476582dc0e", "type": "ioBroker out", "z": "fbda6ab16491b918", "g": "b63936933d6718a9", "name": "", "topic": "", "ack": "true", "autoCreate": "true", "stateName": "", "role": "", "payloadType": "string", "readonly": "true", "stateUnit": "", "stateMin": "", "stateMax": "", "x": 2160, "y": 620, "wires": [] }, { "id": "84f61d394ba2ab34", "type": "mqtt-broker", "name": "Bambu X1C MQTT", "broker": "hier ip eintragen", "port": "1883", "clientid": "", "autoConnect": true, "usetls": false, "protocolVersion": "4", "keepalive": "60", "cleansession": true, "birthTopic": "", "birthQos": "0", "birthPayload": "", "birthMsg": {}, "closeTopic": "", "closeQos": "0", "closePayload": "", "closeMsg": {}, "willTopic": "", "willQos": "0", "willPayload": "", "willMsg": {}, "userProps": "", "sessionExpiry": "" } ]
im notepad bitte ip und seriennummer ändern! ip 1x (Zeile 1979) und sn 2x (Zeile 328 und 350)
dann sollte zumindest im iobroker schon mal alles ankommen.
-
theoretisch müsste man dann im vis eine neue seite erstellen.
wie das geht das man per node an den mqtt server was senden kann weiß ich leider nicht. man kann da wohl auch was hinsenden. das sind die teile die ich aus der node im vergleich zu dem cryd rausgenommen habejetzt legt er mir in den objekten zwar einmal das richtige an und einmal das selber unter nodered/nodered ka warum.
wie man im nodered eine config datei anlegt weiß ich auch nicht dann könnte man die seriennummer und name und topic im nodered direkt changen.
-
@kmxak Das brauchst alles nicht, wenn bei dir was rauskommt und Du nicht den ganzen flow brauchst, kannst Du das entweder in einen eigenen Datenpunkt schreiben oder Du bereitest die Infos halt selbst auf.
-
@kmxak sagte in Bambu lab 3d Drucker MQTT Integration:
theoretisch müsste man dann im vis eine neue seite erstellen.
wie das geht das man per node an den mqtt server was senden kann weiß ich leider nicht. man kann da wohl auch was hinsenden. das sind die teile die ich aus der node im vergleich zu dem cryd rausgenommen habejetzt legt er mir in den objekten zwar einmal das richtige an und einmal das selber unter nodered/nodered ka warum.
Oje - wird immer schlimmer ihr macht Eurer ganzes System kaputt - in den NodeRed Adapter dürft ihr nichts schreiben.
Die einzigen Kommandos die an den Drucker gesendet werden, werden über dieses topic geschrieben:
-
@mickym das ist der output von dem debug am Json:
schaut sehr vielversprechend aus
EDIT: unter den Datenpunkten im NodeRed habe ich keine Einträge, nun einen:
flows
-
@darkdevil Na da hast Du doch schon alles. Also entweder schreibst Du das einfach in einen Datenpunkt, dann kannst Du das mit deinem Blockly weiterverarbeiten oder Du arbeitest Dich tiefer in den Flow.
Ich hab Dir ja unten schon gepostet, was was bedeutet.
Wie möchtest Du denn weiter machen - mit Node Red oder willst Du diese Daten einfach in einen Datenpunkt schreiben und dann willst das mit Deiner Logikmaschine weiter machen. Dann langt es nämlich einfach diese Daten in einen Datenpunkt zu schreiben. Dann machen wir das halt erst mal ohne mqtt-Adapter.
Wie gesagt unter node-red darf nichts stehen.
Wie gesagt ich hab auch einen Flow, der Dir einfach alle Daten in einzelne Datenpunkte schreibt, wenn Du das alles nicht interpretiert haben willst.
Es wird nichts gesteuert - nur die Infos dir in einzelnen Datenpunkten zur Verfügung gestellt.
-
@mickym mir wäre es am liebsten wenn ich die Daten ein einen jeweiligen Dantenpunk(e) bekommen würde.
also zB userdata.0.Drucker.Datenpunkt_temp, noozle, bett etc.wir würde so etwas aussehen?
-
@mickym Alles was vom Drucker kommt einfach in einzelne Datenpunkte. Bisschen aufbereiten wäre natürlich nicht schlecht. Danach kann man ja in Telegram oder VIS weiter machen... wie man mag.
-
@darkdevil Gut dann mach mal folgendes:
Kopiere Dir mal die mqtt-In Node, die Dir diese Daten gerade liefert in einen neuen Flow. Den jetzigen würde ich dann deaktivieren.
Wenn Du das hast, dann schau, dass Du Deine NodeRed Adapter Einstellungen richtig hast:
Wichtig ist, dass die Konvertierung ausgeschaltet ist und die Fremdobjekte zugelassen sind.
Wenn Du den neuen Flow hast, dann mach mal einen Screenshot - wie gesagt ausser dem mqtt-IN Node, die Dir im Moment die Daten liefert sollte nichts enthalten sein.
am besten noch eine DebugNode hintendran.
-
@mickym Wahnsinn, ich habe nun alle Werte sauber in Ordnern Schonmal riesen Dank dafür.
Klar eine Frage kommt noch: im NR debug sehe ich, dass die Werte sich verändern (zB habe ich das Druckbett mal auf 60C eingeschaltet.) Der Datenpunkt im ioBroker ändert sich jedoch nicht.
Letzte Idee?
-
@darkdevil Was hast Du denn gemacht ? - Hast Du meinen Flow importiert? Ich war eigentlich noch gar nicht fertig.
Leider weiss ich nicht was Du gemacht hast. Wie gesagt Du kannst meine Node importieren, die schreibt Dir das dann in Datenpunkte,
https://forum.iobroker.net/topic/43856/json-oder-javascript-objekt-in-iobroker-datenpunkte-zerlegen
-
@mickym Ups, das las sich schon so final
ich habe einen neuen Flow angelegt (Verbindung kann nicht hergestellt werden, da Drucker z. Zt. aus ist):
und den IN Node aus dem ersten Flow gelöscht:
Nach dem starten tauchten unter dem MQTT.0 (vorhandene Instanz) folgende Datenpunkte:
Nur halt einmal und wurden nicht aktualisiert.
-
@darkdevil Na dann hat das mit dem mqtt Adapter doch geklappt. - Das hat mit NodeRed nichts zu tun. Dann brauchst Du ggf. Node Red gar nicht. Was meinst Du erst wird nicht aktualisiert.
Ich blicke langsam nicht mehr durch - war das der mqtt Adapter, den Du heute nachmittag konfiguriert hattest?
Wie machen wir nun weiter mit dem mqtt-Adapter oder mit NodeRed?
Ich würde von dem mqtt- Adapter so erst mal abraten - da kommt dieser HomeAssistant Mist noch mit.
Bei Node-Red hättest Du die mqtt-IN Node nur kopieren sollen. Jedenfalls musst Du die nochmal konfigurieren und den Broker eintragen. Schau dass dort die Daten wieder in der Debug Node ankommen.
-
@mickym also die Werte wurden erst in der alten MQTT Instanz angelegt, als ich im NoteRed den neuen Flow gestartet habe und diesen ausgeführt habe. Also die neue MQTT Instanz, in der ich die IP Adresse eingetragen habe, hat damit nichts zu tun.
Daher denke ich, dass Node Red (vorerst) doch wichtig ist. In dem NodeRed JSON Template habe ich ja neben der IP Adresse auch die Seriennummer angeben müssen, vielleicht läuft hier rüber auch eine Authentifizierung.
Der Debug Note liefert mir auch kontinuierlich Daten.
-
@darkdevil ok - ich denke, dass dir die homeassistant mqtt Node ggf. In dein lokalen mqtt Broker geschrieben hat. Wenn du kontrolliert hast, dass in deinem neuen Flow die mqtt-in Node kontinuierlich Daten liefert, dann importierst du meine Node bzw. Den Subflow aus dem thread den ich dir verlinkt habe. Diese Node klemmst du dann hinter deine mqtt-in Node und vor die debug-node - also dazwischen. In der neuen Node vergibst Du einen Namen unter dem die Datenpunkte angelegt werden sollen. Die Datenpunkte werden immer unter 0_userdata.0 angelegt. Vorgelegt ist das mit objRoot. Da kannst dann einen anderen Namen am besten ohne Leerzeichen verwenden. Wenn das fertig ist, dann solltest du lauter Einzelnacheichten in dem debug Fenster bekommen. Das topic der Einzelnachrichten enthält dann den Pfad in dem später die einzelnen Datenpunkte geschrieben werden. Ich hab das auch alles in den Hilfetext der Node geschrieben.
Den Baum unter mqtt.0 würde ich aber löschen, da der erst mal keine Bedeutung hat.