Skip to content

Instantly share code, notes, and snippets.

@WolfwithSword
Created May 6, 2023 17:45
Show Gist options
  • Save WolfwithSword/45dd17ba5250cee94136759e9923e2bb to your computer and use it in GitHub Desktop.
Save WolfwithSword/45dd17ba5250cee94136759e9923e2bb to your computer and use it in GitHub Desktop.
Bambu Advanced Mesh Visualize Setup
[
{
"id": "791d26fa232ad922",
"type": "group",
"z": "fbda6ab16491b918",
"name": "Bed Mesh Parser Advanced",
"style": {
"stroke": "#92d04f",
"fill": "#001f60",
"fill-opacity": "0.76",
"label": true,
"color": "#92d04f"
},
"nodes": [
"2a0ba80bf37d170c",
"8b88223358dd69df",
"8e185cdb9a8932af",
"4451d030e6418f49",
"8978c1243f654011",
"c4d7905e3406300d",
"fd4369e8c6dd7280",
"060fe49fc21270c4",
"5db05dca795db972",
"c0b73094bf3797c7",
"71b429a70f0549b8",
"d4d9c0c56451621b",
"ef37102da33be23c",
"8eb3dcb17a44e25b",
"47a0f2d5e094174c",
"32821e386ab7692c",
"0843c63919f7f6c1",
"3dfcb98c18f19d78",
"005f9d4dc018dbcf",
"3ab2585a83ed5e83",
"ba7c30e3c166b7b0",
"91b4cf7e3ba9798d",
"6796f76272d2b69b"
],
"x": 1694,
"y": 2339,
"w": 1072,
"h": 342
},
{
"id": "2a0ba80bf37d170c",
"type": "mqtt in",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Bambu X1C {PRINTER_NAME}",
"topic": "device/{PRINTER_SERIAL}/report",
"qos": "2",
"datatype": "json",
"broker": "{GENERATED_PRINTER_MQTT_ID}",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 1850,
"y": 2560,
"wires": [
[
"8b88223358dd69df"
]
]
},
{
"id": "8b88223358dd69df",
"type": "json",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"property": "payload.print",
"action": "obj",
"pretty": false,
"x": 2030,
"y": 2560,
"wires": [
[
"8e185cdb9a8932af"
]
]
},
{
"id": "8e185cdb9a8932af",
"type": "function",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Inject Machine Details",
"func": "let machine_name = \"{PRINTER_NAME}\";\nlet machine_serial = \"{PRINTER_SERIAL}\";\nlet manufacturer = \"Bambu Labs\";\nlet model = \"X1 Carbon\"\n\n\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 node.send(msg);\n }\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1840,
"y": 2600,
"wires": [
[
"4451d030e6418f49"
]
]
},
{
"id": "4451d030e6418f49",
"type": "function",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Cull Fail Msg",
"func": "if(msg.payload != undefined && Object.keys(msg.payload).length > 0){\n node.send(msg);\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 2030,
"y": 2600,
"wires": [
[
"8978c1243f654011"
]
]
},
{
"id": "8978c1243f654011",
"type": "switch",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"property": "payload.mc_print.param",
"propertyType": "msg",
"rules": [
{
"t": "regex",
"v": "\\[BMC\\] X\\d+\\.\\d+ Y\\d+\\.\\d+,z_c=",
"vt": "str",
"case": false
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 1790,
"y": 2640,
"wires": [
[
"c4d7905e3406300d"
]
]
},
{
"id": "c4d7905e3406300d",
"type": "function",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Parse coord",
"func": "let param = msg.payload.mc_print.param;\nlet x = param.match(/X(\\d+\\.\\d+)/)[1];\nlet y = param.match(/Y(\\d+\\.\\d+)/)[1];\nlet z = param.match(/z_c=\\s+(-?\\d+\\.\\d+)/)[1];\nlet coords = [x, y, z];\nmsg.payload = {\"coord\": {\"x\": parseFloat(x), \"y\":parseFloat(y), \"z\":parseFloat(z)}};\n\nlet abl = flow.get('abl2');\nabl.push(msg.payload);\nnode.send(msg);\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1930,
"y": 2640,
"wires": [
[]
]
},
{
"id": "fd4369e8c6dd7280",
"type": "mqtt in",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "HomeAssistant In",
"topic": "homeassistant/sensor/X1C_{PRINTER_NAME}/stage/state",
"qos": "2",
"datatype": "utf8",
"broker": "489094618c340eef",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 1820,
"y": 2520,
"wires": [
[
"5db05dca795db972"
]
]
},
{
"id": "060fe49fc21270c4",
"type": "switch",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "Auto bed leveling",
"vt": "str"
},
{
"t": "eq",
"v": "Offline",
"vt": "str"
},
{
"t": "eq",
"v": "Idle",
"vt": "str"
},
{
"t": "eq",
"v": "Printing",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 4,
"x": 2090,
"y": 2500,
"wires": [
[
"c0b73094bf3797c7"
],
[
"c0b73094bf3797c7"
],
[
"91b4cf7e3ba9798d"
],
[
"0843c63919f7f6c1"
]
]
},
{
"id": "5db05dca795db972",
"type": "rbe",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"septopics": true,
"property": "payload",
"topi": "topic",
"x": 1970,
"y": 2520,
"wires": [
[
"060fe49fc21270c4"
]
]
},
{
"id": "c0b73094bf3797c7",
"type": "change",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"rules": [
{
"t": "set",
"p": "abl2",
"pt": "flow",
"to": "[]",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2370,
"y": 2460,
"wires": [
[]
]
},
{
"id": "71b429a70f0549b8",
"type": "delay",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 2320,
"y": 2580,
"wires": [
[
"ef37102da33be23c"
]
]
},
{
"id": "d4d9c0c56451621b",
"type": "inject",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Init",
"props": [
{
"p": "topic",
"vt": "str"
},
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "bed_mesh_data",
"payload": "None",
"payloadType": "str",
"x": 2090,
"y": 2440,
"wires": [
[
"c0b73094bf3797c7",
"005f9d4dc018dbcf"
]
]
},
{
"id": "ef37102da33be23c",
"type": "function",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Create Matrix",
"func": "let abl = flow.get('abl2');\nif (abl.length > 0) {\n let setX = new Set();\n let setY = new Set();\n for (let c of abl) {\n setX.add(c.coord.x);\n setY.add(c.coord.y);\n }\n let xs = Array.from(setX).sort(function (a, b) {\n return a - b;\n });\n let ys = Array.from(setY).sort(function (a, b) {\n return a - b;\n });\n\n\n let data = new Array(ys.length).fill(0).map(() => new Array(xs.length).fill(0));\n for (var c of abl) {\n let coord = c.coord;\n let x = xs.indexOf(coord.x);\n let y = ys.indexOf(coord.y);\n data[y][x] = coord.z;\n }\n let strdata = JSON.stringify(data).replaceAll(\"[\", \"{\");\n strdata = strdata.replaceAll(\"]\", \"}\");\n msg.values = {\n \"data\": strdata,\n \"printer\": \"{PRINTER_NAME}\",\n \"printer_serial\": \"{PRINTER_SERIAL}\"\n }\n node.send(msg);\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 2320,
"y": 2620,
"wires": [
[
"ba7c30e3c166b7b0"
]
]
},
{
"id": "8eb3dcb17a44e25b",
"type": "junction",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"x": 2500,
"y": 2420,
"wires": [
[]
]
},
{
"id": "47a0f2d5e094174c",
"type": "junction",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"x": 2740,
"y": 2460,
"wires": [
[]
]
},
{
"id": "32821e386ab7692c",
"type": "comment",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Bed Mesh Flow Advanced: REV A-1",
"info": "Rev A-1: 2023-05-06\n- Initial Creation for Advanced version",
"x": 1860,
"y": 2380,
"wires": []
},
{
"id": "0843c63919f7f6c1",
"type": "switch",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"property": "abl2",
"propertyType": "flow",
"rules": [
{
"t": "nempty"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 2390,
"y": 2540,
"wires": [
[
"71b429a70f0549b8"
]
]
},
{
"id": "3dfcb98c18f19d78",
"type": "junction",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"x": 2480,
"y": 2440,
"wires": [
[]
]
},
{
"id": "005f9d4dc018dbcf",
"type": "postgrestor",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Initialize",
"query": "CREATE TABLE IF NOT EXISTS bed_mesh (\n id SERIAL,\n printer varchar(25) NOT NULL,\n printer_serial varchar(20) NOT NULL,\n scan_timestamp timestamp DEFAULT (now() at time zone 'utc'),\n data float[][]\n);",
"postgresDB": "79ce3199b8eeaa1c",
"output": true,
"outputs": 1,
"x": 2380,
"y": 2420,
"wires": [
[]
]
},
{
"id": "3ab2585a83ed5e83",
"type": "postgrestor",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Insert Bed Mesh Data",
"query": "INSERT INTO bed_mesh (\n printer,\n printer_serial,\n data\n) VALUES (\n '{{msg.values.printer}}',\n '{{msg.values.printer_serial}}',\n '{{msg.values.data}}'\n);",
"postgresDB": "79ce3199b8eeaa1c",
"output": true,
"outputs": 1,
"x": 2600,
"y": 2620,
"wires": [
[
"6796f76272d2b69b"
]
]
},
{
"id": "ba7c30e3c166b7b0",
"type": "switch",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"property": "values.data",
"propertyType": "msg",
"rules": [
{
"t": "nempty"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 2550,
"y": 2580,
"wires": [
[
"3ab2585a83ed5e83"
]
]
},
{
"id": "91b4cf7e3ba9798d",
"type": "delay",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"pauseType": "delay",
"timeout": "2",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 2280,
"y": 2500,
"wires": [
[
"0843c63919f7f6c1"
]
]
},
{
"id": "6796f76272d2b69b",
"type": "delay",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"pauseType": "delay",
"timeout": "100",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 2630,
"y": 2520,
"wires": [
[
"c0b73094bf3797c7"
]
]
}
]
[
{
"id": "791d26fa232ad922",
"type": "group",
"z": "fbda6ab16491b918",
"name": "Bed Mesh Parser Advanced",
"style": {
"stroke": "#92d04f",
"fill": "#001f60",
"fill-opacity": "0.76",
"label": true,
"color": "#92d04f"
},
"nodes": [
"2a0ba80bf37d170c",
"8b88223358dd69df",
"8e185cdb9a8932af",
"4451d030e6418f49",
"8978c1243f654011",
"c4d7905e3406300d",
"fd4369e8c6dd7280",
"060fe49fc21270c4",
"5db05dca795db972",
"c0b73094bf3797c7",
"71b429a70f0549b8",
"d4d9c0c56451621b",
"ef37102da33be23c",
"8eb3dcb17a44e25b",
"47a0f2d5e094174c",
"32821e386ab7692c",
"0843c63919f7f6c1",
"3dfcb98c18f19d78",
"005f9d4dc018dbcf",
"3ab2585a83ed5e83",
"ba7c30e3c166b7b0",
"91b4cf7e3ba9798d",
"6796f76272d2b69b"
],
"x": 1694,
"y": 2339,
"w": 1072,
"h": 342
},
{
"id": "2a0ba80bf37d170c",
"type": "mqtt in",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Bambu X1C {PRINTER_NAME}",
"topic": "device/{PRINTER_SERIAL}/report",
"qos": "2",
"datatype": "json",
"broker": "{GENERATED_PRINTER_MQTT_ID}",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 1850,
"y": 2560,
"wires": [
[
"8b88223358dd69df"
]
]
},
{
"id": "8b88223358dd69df",
"type": "json",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"property": "payload.print",
"action": "obj",
"pretty": false,
"x": 2030,
"y": 2560,
"wires": [
[
"8e185cdb9a8932af"
]
]
},
{
"id": "8e185cdb9a8932af",
"type": "function",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Inject Machine Details",
"func": "let machine_name = \"{PRINTER_NAME}\";\nlet machine_serial = \"{PRINTER_SERIAL}\";\nlet manufacturer = \"Bambu Labs\";\nlet model = \"X1 Carbon\"\n\n\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 node.send(msg);\n }\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1840,
"y": 2600,
"wires": [
[
"4451d030e6418f49"
]
]
},
{
"id": "4451d030e6418f49",
"type": "function",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Cull Fail Msg",
"func": "if(msg.payload != undefined && Object.keys(msg.payload).length > 0){\n node.send(msg);\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 2030,
"y": 2600,
"wires": [
[
"8978c1243f654011"
]
]
},
{
"id": "8978c1243f654011",
"type": "switch",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"property": "payload.mc_print.param",
"propertyType": "msg",
"rules": [
{
"t": "regex",
"v": "\\[BMC\\] X\\d+\\.\\d+ Y\\d+\\.\\d+,z_c=",
"vt": "str",
"case": false
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 1790,
"y": 2640,
"wires": [
[
"c4d7905e3406300d"
]
]
},
{
"id": "c4d7905e3406300d",
"type": "function",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Parse coord",
"func": "let param = msg.payload.mc_print.param;\nlet x = param.match(/X(\\d+\\.\\d+)/)[1];\nlet y = param.match(/Y(\\d+\\.\\d+)/)[1];\nlet z = param.match(/z_c=\\s+(-?\\d+\\.\\d+)/)[1];\nlet coords = [x, y, z];\nmsg.payload = {\"coord\": {\"x\": parseFloat(x), \"y\":parseFloat(y), \"z\":parseFloat(z)}};\n\nlet abl = flow.get('abl2');\nabl.push(msg.payload);\nnode.send(msg);\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1930,
"y": 2640,
"wires": [
[]
]
},
{
"id": "fd4369e8c6dd7280",
"type": "mqtt in",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "HomeAssistant In",
"topic": "homeassistant/sensor/X1C_{PRINTER_NAME}/stage/state",
"qos": "2",
"datatype": "utf8",
"broker": "489094618c340eef",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 1820,
"y": 2520,
"wires": [
[
"5db05dca795db972"
]
]
},
{
"id": "060fe49fc21270c4",
"type": "switch",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "Auto bed leveling",
"vt": "str"
},
{
"t": "eq",
"v": "Offline",
"vt": "str"
},
{
"t": "eq",
"v": "Idle",
"vt": "str"
},
{
"t": "eq",
"v": "Printing",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 4,
"x": 2090,
"y": 2500,
"wires": [
[
"c0b73094bf3797c7"
],
[
"c0b73094bf3797c7"
],
[
"91b4cf7e3ba9798d"
],
[
"0843c63919f7f6c1"
]
]
},
{
"id": "5db05dca795db972",
"type": "rbe",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"septopics": true,
"property": "payload",
"topi": "topic",
"x": 1970,
"y": 2520,
"wires": [
[
"060fe49fc21270c4"
]
]
},
{
"id": "c0b73094bf3797c7",
"type": "change",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"rules": [
{
"t": "set",
"p": "abl2",
"pt": "flow",
"to": "[]",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2370,
"y": 2460,
"wires": [
[]
]
},
{
"id": "71b429a70f0549b8",
"type": "delay",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 2320,
"y": 2580,
"wires": [
[
"ef37102da33be23c"
]
]
},
{
"id": "d4d9c0c56451621b",
"type": "inject",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Init",
"props": [
{
"p": "topic",
"vt": "str"
},
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "bed_mesh_data",
"payload": "None",
"payloadType": "str",
"x": 2090,
"y": 2440,
"wires": [
[
"c0b73094bf3797c7",
"005f9d4dc018dbcf"
]
]
},
{
"id": "ef37102da33be23c",
"type": "function",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Create Matrix",
"func": "let abl = flow.get('abl2');\nif (abl.length > 0) {\n let setX = new Set();\n let setY = new Set();\n for (let c of abl) {\n setX.add(c.coord.x);\n setY.add(c.coord.y);\n }\n let xs = Array.from(setX).sort(function (a, b) {\n return a - b;\n });\n let ys = Array.from(setY).sort(function (a, b) {\n return a - b;\n });\n\n\n let data = new Array(ys.length).fill(0).map(() => new Array(xs.length).fill(0));\n for (var c of abl) {\n let coord = c.coord;\n let x = xs.indexOf(coord.x);\n let y = ys.indexOf(coord.y);\n data[y][x] = coord.z;\n }\n let strdata = JSON.stringify(data).replaceAll(\"[\", \"{\");\n strdata = strdata.replaceAll(\"]\", \"}\");\n msg.values = {\n \"data\": strdata,\n \"printer\": \"{PRINTER_NAME}\",\n \"printer_serial\": \"{PRINTER_SERIAL}\"\n }\n node.send(msg);\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 2320,
"y": 2620,
"wires": [
[
"ba7c30e3c166b7b0"
]
]
},
{
"id": "8eb3dcb17a44e25b",
"type": "junction",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"x": 2500,
"y": 2420,
"wires": [
[]
]
},
{
"id": "47a0f2d5e094174c",
"type": "junction",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"x": 2740,
"y": 2460,
"wires": [
[]
]
},
{
"id": "32821e386ab7692c",
"type": "comment",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Bed Mesh Flow Advanced: REV A-1",
"info": "Rev A-1: 2023-05-06\n- Initial Creation for Advanced version",
"x": 1860,
"y": 2380,
"wires": []
},
{
"id": "0843c63919f7f6c1",
"type": "switch",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"property": "abl2",
"propertyType": "flow",
"rules": [
{
"t": "nempty"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 2390,
"y": 2540,
"wires": [
[
"71b429a70f0549b8"
]
]
},
{
"id": "3dfcb98c18f19d78",
"type": "junction",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"x": 2480,
"y": 2440,
"wires": [
[]
]
},
{
"id": "005f9d4dc018dbcf",
"type": "postgrestor",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Initialize",
"query": "CREATE TABLE IF NOT EXISTS bed_mesh (\n id SERIAL,\n printer varchar(25) NOT NULL,\n printer_serial varchar(20) NOT NULL,\n scan_timestamp timestamp DEFAULT (now() at time zone 'utc'),\n data float[][]\n);",
"postgresDB": "79ce3199b8eeaa1c",
"output": true,
"outputs": 1,
"x": 2380,
"y": 2420,
"wires": [
[]
]
},
{
"id": "3ab2585a83ed5e83",
"type": "postgrestor",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "Insert Bed Mesh Data",
"query": "INSERT INTO bed_mesh (\n printer,\n printer_serial,\n data\n) VALUES (\n '{{msg.values.printer}}',\n '{{msg.values.printer_serial}}',\n '{{msg.values.data}}'\n);",
"postgresDB": "79ce3199b8eeaa1c",
"output": true,
"outputs": 1,
"x": 2600,
"y": 2620,
"wires": [
[
"6796f76272d2b69b"
]
]
},
{
"id": "ba7c30e3c166b7b0",
"type": "switch",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"property": "values.data",
"propertyType": "msg",
"rules": [
{
"t": "nempty"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 2550,
"y": 2580,
"wires": [
[
"3ab2585a83ed5e83"
]
]
},
{
"id": "91b4cf7e3ba9798d",
"type": "delay",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"pauseType": "delay",
"timeout": "2",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 2280,
"y": 2500,
"wires": [
[
"0843c63919f7f6c1"
]
]
},
{
"id": "6796f76272d2b69b",
"type": "delay",
"z": "fbda6ab16491b918",
"g": "791d26fa232ad922",
"name": "",
"pauseType": "delay",
"timeout": "100",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 2630,
"y": 2520,
"wires": [
[
"c0b73094bf3797c7"
]
]
},
{
"id": "79ce3199b8eeaa1c",
"type": "postgresDB",
"name": "3DPrint DB (PG13)",
"host": "{POSTGRES_DB_HOST}",
"hostFieldType": "str",
"port": "{POSTGRES_DB_PORT}",
"portFieldType": "num",
"database": "{POSTGRES_DB_DBNAME}",
"databaseFieldType": "str",
"ssl": "false",
"sslFieldType": "bool",
"max": "10",
"maxFieldType": "num",
"min": "1",
"minFieldType": "num",
"idle": "1000",
"idleFieldType": "num",
"connectionTimeout": "10000",
"connectionTimeoutFieldType": "num",
"user": "{POSTGRES_DB_USER}",
"userFieldType": "str",
"password":"{POSTGRES_DB_PASSWORD}",
"passwordFieldType": "str"
}
]
@cweed710
Copy link

I am having issues creating a postgres database and was wondering if you could help me with this to get this up and running

@WolfwithSword
Copy link
Author

I am having issues creating a postgres database and was wondering if you could help me with this to get this up and running

What's your setup like for setting up postgres?

Also note - these gists are severely out of date. If you could instead follow the guide on my website instead which is always up to date, and pulls from the proper repository, it might help a few things out.

@cweed710
Copy link

cweed710 commented Nov 29, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment