Dear All
Hello. I am working on a flow in NODE RED. The aim is to establish a reliable SparkplugB based MQTT communication. The initial flow is (@kcollins1 thank you for your help with this)
It does show all the metrics in ignition web interface and ignition designer
However I am working on a test case where my hardware interface does not support the sparkplug module and there is no way to install this through any other means.
This module is not supported
But Sparkplug plus module is supported
So making use of this module I made further modifications to my initial flow in the following ways
[
{
"id": "e4168b47ecf2d348",
"type": "tab",
"label": "Flow 9",
"disabled": false,
"info": "",
"env": []
},
{
"id": "08c39838fbb9d8f6",
"type": "function",
"z": "e4168b47ecf2d348",
"name": "Sparkplug",
"func": "// Capture device name\n[\n {\n \"id\": \"21cb23aca25f8ff0\",\n \"type\": \"sparkplug\",\n \"z\": \"ec7476ef0136b446\",\n \"name\": \"\",\n \"broker\": \"tcp://localhost\",\n \"port\": \"1883\",\n \"clientid\": \"InductiveAutomation111\",\n \"groupid\": \"Sparkplug Devices\",\n \"edgenode\": \"Test6\",\n \"version\": \"spBv1.0\",\n \"enablecache\": \"false\",\n \"publishdeath\": \"true\",\n \"user\": \"admin\",\n \"password\": \"__PWRD__\",\n \"x\": 720,\n \"y\": 440,\n \"wires\": [\n [\n \"ef55783b857bf953\"\n ]\n ]\n }\n]\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 740,
"y": 240,
"wires": [
[
"575e65b7ee152614",
"00911b8f2c513204",
"ed4cfc1da8abe1f8",
"15a23746c423d4cb"
]
]
},
{
"id": "575e65b7ee152614",
"type": "mqtt sparkplug out",
"z": "e4168b47ecf2d348",
"name": "",
"topic": "spBv1.0/Sparkplug Devices/DBIRTH/Test6/Device4",
"qos": "2",
"retain": "true",
"broker": "0d831bd9ba588536",
"x": 950,
"y": 300,
"wires": []
},
{
"id": "ed4cfc1da8abe1f8",
"type": "mqtt sparkplug out",
"z": "e4168b47ecf2d348",
"name": "",
"topic": "spBv1.0/Sparkplug Devices/DDATA/Test6/Device4",
"qos": "2",
"retain": "true",
"broker": "0d831bd9ba588536",
"x": 950,
"y": 360,
"wires": []
},
{
"id": "15a23746c423d4cb",
"type": "mqtt sparkplug out",
"z": "e4168b47ecf2d348",
"name": "",
"topic": "spBv1.0/Sparkplug Devices/DDEATH/Test6/Device4",
"qos": "2",
"retain": "true",
"broker": "0d831bd9ba588536",
"x": 950,
"y": 420,
"wires": []
},
{
"id": "0fc0476f4d01bc1a",
"type": "function",
"z": "e4168b47ecf2d348",
"name": "DBIRTH",
"func": "// Capture device name\nglobal.set(\"deviceId\", \"PLC9\")\n\nvar payload = {\n \"timestamp\": msg.payload,\n}\nvar metrics = []\nmetrics.push({\n \"name\": \"CurrentSeconds\",\n \"value\": new Date().getSeconds(),\n \"type\": \"int32\"\n},\n{\n \"name\": \"Inputs/0\",\n \"value\": true,\n \"type\": \"boolean\"\n}\n)\npayload[\"metrics\"] = metrics\nmsg.payload = payload\nmsg.topic = `${global.get(\"deviceId\")}/DBIRTH`\nflow.set(\"running\", true)\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 600,
"y": 300,
"wires": [
[
"08c39838fbb9d8f6"
]
]
},
{
"id": "b0e03cda4217715d",
"type": "link in",
"z": "e4168b47ecf2d348",
"name": "Rebirth",
"links": [
"0f808b57f9f93aa6"
],
"x": 425,
"y": 240,
"wires": [
[
"0fc0476f4d01bc1a"
]
]
},
{
"id": "03be983f6938c2cf",
"type": "inject",
"z": "e4168b47ecf2d348",
"name": "Update",
"props": [
{
"p": "payload"
},
{
"p": "running",
"v": "running",
"vt": "flow"
}
],
"repeat": "1",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 400,
"y": 360,
"wires": [
[
"0b8522cb6c7a0fba"
]
]
},
{
"id": "0b8522cb6c7a0fba",
"type": "function",
"z": "e4168b47ecf2d348",
"name": "DDATA",
"func": "if (!msg.running) {\n return null;\n}\nvar payload = {\n \"timestamp\": msg.payload\n}\nvar metrics = []\nmetrics.push({\n \"name\": \"CurrentSeconds\",\n \"value\": new Date().getSeconds(),\n \"type\": \"int32\"\n },\n {\n \"name\": \"Inputs/0\",\n \"value\": true,\n \"type\": \"boolean\"\n}\n)\npayload[\"metrics\"] = metrics\nmsg.payload = payload\nmsg.topic = `${global.get(\"deviceId\")}/DDATA`\nreturn msg;\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 610,
"y": 360,
"wires": [
[
"08c39838fbb9d8f6"
]
]
},
{
"id": "5a73da41d3fc779e",
"type": "function",
"z": "e4168b47ecf2d348",
"name": "DDEATH",
"func": "var payload = {\n \"timestamp\": msg.payload,\n}\nmsg.payload = payload\nmsg.topic = `${global.get(\"deviceId\")}/DDEATH`\nflow.set(\"running\", false)\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 600,
"y": 420,
"wires": [
[
"08c39838fbb9d8f6"
]
]
},
{
"id": "ed3cc764add1f66f",
"type": "inject",
"z": "e4168b47ecf2d348",
"name": "Stop",
"props": [
{
"p": "payload"
},
{
"p": "reset",
"v": "true",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 390,
"y": 420,
"wires": [
[
"5a73da41d3fc779e"
]
]
},
{
"id": "e790dd384ea25177",
"type": "inject",
"z": "e4168b47ecf2d348",
"name": "Start",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 390,
"y": 300,
"wires": [
[
"0fc0476f4d01bc1a"
]
]
},
{
"id": "f69198aa5bfad8e4",
"type": "debug",
"z": "e4168b47ecf2d348",
"name": "sparkplug debug",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 970,
"y": 540,
"wires": []
},
{
"id": "0f808b57f9f93aa6",
"type": "link out",
"z": "e4168b47ecf2d348",
"name": "Rebirth",
"mode": "link",
"links": [
"b0e03cda4217715d"
],
"x": 1125,
"y": 180,
"wires": []
},
{
"id": "00911b8f2c513204",
"type": "switch",
"z": "e4168b47ecf2d348",
"name": "Route Outputs",
"property": "topic",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "rebirth",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 940,
"y": 180,
"wires": [
[
"0f808b57f9f93aa6"
]
]
},
{
"id": "e0a15ddcc9f60832",
"type": "mqtt sparkplug in",
"z": "e4168b47ecf2d348",
"name": "",
"topic": "spBv1.0/Sparkplug Devices/DDATA/Test6/Device4",
"qos": "2",
"broker": "0d831bd9ba588536",
"x": 490,
"y": 600,
"wires": [
[
"85d8379ae0adeb7f"
]
]
},
{
"id": "85d8379ae0adeb7f",
"type": "debug",
"z": "e4168b47ecf2d348",
"name": "sparkplug debug",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 970,
"y": 600,
"wires": []
},
{
"id": "7027f258c5c317e6",
"type": "mqtt sparkplug in",
"z": "e4168b47ecf2d348",
"name": "",
"topic": "spBv1.0/Sparkplug Devices/DBIRTH/Test6/Device4",
"qos": "2",
"broker": "0d831bd9ba588536",
"x": 490,
"y": 660,
"wires": [
[
"4256bfcdab90af27"
]
]
},
{
"id": "4256bfcdab90af27",
"type": "debug",
"z": "e4168b47ecf2d348",
"name": "sparkplug debug",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 970,
"y": 660,
"wires": []
},
{
"id": "2afbb4af8fad30d7",
"type": "mqtt sparkplug in",
"z": "e4168b47ecf2d348",
"name": "",
"topic": "spBv1.0/Sparkplug Devices/DDEATH/Test6/Device4",
"qos": "2",
"broker": "0d831bd9ba588536",
"x": 490,
"y": 720,
"wires": [
[
"db8fe382d45b495a"
]
]
},
{
"id": "db8fe382d45b495a",
"type": "debug",
"z": "e4168b47ecf2d348",
"name": "sparkplug debug",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 970,
"y": 720,
"wires": []
},
{
"id": "0d831bd9ba588536",
"type": "mqtt-sparkplug-broker",
"name": "Local Host",
"deviceGroup": "Sparkplug Devices",
"eonName": "Test6",
"broker": "localhost",
"port": "1883",
"clientid": "",
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"enableStoreForward": false,
"primaryScada": ""
}
]
and
this way
[
{
"id": "f35f22ba8892e611",
"type": "tab",
"label": "Flow 8",
"disabled": false,
"info": "",
"env": []
},
{
"id": "9fcc8012c1be937e",
"type": "mqtt sparkplug out",
"z": "f35f22ba8892e611",
"name": "",
"topic": "spBv1.0/Sparkplug Devices/DBIRTH/Test5/Device3",
"qos": "2",
"retain": "true",
"broker": "0d831bd9ba588536",
"x": 910,
"y": 360,
"wires": []
},
{
"id": "4890f7bd3bb383a5",
"type": "mqtt sparkplug out",
"z": "f35f22ba8892e611",
"name": "",
"topic": "spBv1.0/Sparkplug Devices/DDATA/Test5/Device3",
"qos": "2",
"retain": "true",
"broker": "0d831bd9ba588536",
"x": 910,
"y": 420,
"wires": []
},
{
"id": "ddd2f668a7c4f2f2",
"type": "mqtt sparkplug out",
"z": "f35f22ba8892e611",
"name": "",
"topic": "spBv1.0/Sparkplug Devices/DDEATH/Test5/Device3",
"qos": "2",
"retain": "true",
"broker": "0d831bd9ba588536",
"x": 910,
"y": 480,
"wires": []
},
{
"id": "f330bbb07630dac7",
"type": "function",
"z": "f35f22ba8892e611",
"name": "DBIRTH",
"func": "// Capture device name\nglobal.set(\"deviceId\", \"PLC8\")\n\nvar payload = {\n \"timestamp\": msg.payload,\n}\nvar metrics = []\nmetrics.push({\n \"name\": \"CurrentSeconds\",\n \"value\": new Date().getSeconds(),\n \"type\": \"int32\"\n},\n{\n \"name\": \"Inputs/0\",\n \"value\": true,\n \"type\": \"boolean\"\n}\n)\npayload[\"metrics\"] = metrics\nmsg.payload = payload\nmsg.topic = `${global.get(\"deviceId\")}/DBIRTH`\nflow.set(\"running\", true)\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 560,
"y": 360,
"wires": [
[
"9fcc8012c1be937e",
"5cac959b09503939",
"1d17a2f386fd0479"
]
]
},
{
"id": "2c00a2d5d54e004e",
"type": "link in",
"z": "f35f22ba8892e611",
"name": "Rebirth",
"links": [
"efeaa1159390bc88"
],
"x": 385,
"y": 300,
"wires": [
[
"f330bbb07630dac7"
]
]
},
{
"id": "24764db11096a601",
"type": "inject",
"z": "f35f22ba8892e611",
"name": "Update",
"props": [
{
"p": "payload"
},
{
"p": "running",
"v": "running",
"vt": "flow"
}
],
"repeat": "1",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 360,
"y": 420,
"wires": [
[
"cdab6a55c9c1aa86"
]
]
},
{
"id": "cdab6a55c9c1aa86",
"type": "function",
"z": "f35f22ba8892e611",
"name": "DDATA",
"func": "if (!msg.running) {\n return null;\n}\nvar payload = {\n \"timestamp\": msg.payload\n}\nvar metrics = []\nmetrics.push({\n \"name\": \"CurrentSeconds\",\n \"value\": new Date().getSeconds(),\n \"type\": \"int32\"\n },\n {\n \"name\": \"Inputs/0\",\n \"value\": true,\n \"type\": \"boolean\"\n}\n)\npayload[\"metrics\"] = metrics\nmsg.payload = payload\nmsg.topic = `${global.get(\"deviceId\")}/DDATA`\nreturn msg;\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 570,
"y": 420,
"wires": [
[
"4890f7bd3bb383a5",
"5cac959b09503939"
]
]
},
{
"id": "ce5339b610f15f4a",
"type": "function",
"z": "f35f22ba8892e611",
"name": "DDEATH",
"func": "var payload = {\n \"timestamp\": msg.payload,\n}\nmsg.payload = payload\nmsg.topic = `${global.get(\"deviceId\")}/DDEATH`\nflow.set(\"running\", false)\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 560,
"y": 480,
"wires": [
[
"ddd2f668a7c4f2f2",
"5cac959b09503939"
]
]
},
{
"id": "502478a4d21792c2",
"type": "inject",
"z": "f35f22ba8892e611",
"name": "Stop",
"props": [
{
"p": "payload"
},
{
"p": "reset",
"v": "true",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 350,
"y": 480,
"wires": [
[
"ce5339b610f15f4a"
]
]
},
{
"id": "485d12074928bcfa",
"type": "inject",
"z": "f35f22ba8892e611",
"name": "Start",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 350,
"y": 360,
"wires": [
[
"f330bbb07630dac7"
]
]
},
{
"id": "5cac959b09503939",
"type": "debug",
"z": "f35f22ba8892e611",
"name": "sparkplug debug",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 930,
"y": 600,
"wires": []
},
{
"id": "efeaa1159390bc88",
"type": "link out",
"z": "f35f22ba8892e611",
"name": "Rebirth",
"mode": "link",
"links": [
"2c00a2d5d54e004e"
],
"x": 1085,
"y": 240,
"wires": []
},
{
"id": "1d17a2f386fd0479",
"type": "switch",
"z": "f35f22ba8892e611",
"name": "Route Outputs",
"property": "topic",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "rebirth",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 900,
"y": 240,
"wires": [
[
"efeaa1159390bc88"
]
]
},
{
"id": "5786fdc09e3ca0e4",
"type": "mqtt sparkplug in",
"z": "f35f22ba8892e611",
"name": "",
"topic": "spBv1.0/Sparkplug Devices/DDATA/Test5/Device3",
"qos": "2",
"broker": "0d831bd9ba588536",
"x": 450,
"y": 660,
"wires": [
[
"b861e09d17229556"
]
]
},
{
"id": "b861e09d17229556",
"type": "debug",
"z": "f35f22ba8892e611",
"name": "sparkplug debug",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 930,
"y": 660,
"wires": []
},
{
"id": "2981a45ca47ef085",
"type": "mqtt sparkplug in",
"z": "f35f22ba8892e611",
"name": "",
"topic": "spBv1.0/Sparkplug Devices/DBIRTH/Test5/Device3",
"qos": "2",
"broker": "0d831bd9ba588536",
"x": 450,
"y": 720,
"wires": [
[
"f5c4857d1ddb539f"
]
]
},
{
"id": "f5c4857d1ddb539f",
"type": "debug",
"z": "f35f22ba8892e611",
"name": "sparkplug debug",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 930,
"y": 720,
"wires": []
},
{
"id": "cb790570b5f4bab3",
"type": "mqtt sparkplug in",
"z": "f35f22ba8892e611",
"name": "",
"topic": "spBv1.0/Sparkplug Devices/DDEATH/Test5/Device3",
"qos": "2",
"broker": "0d831bd9ba588536",
"x": 450,
"y": 780,
"wires": [
[
"34858db4fc610cb9"
]
]
},
{
"id": "34858db4fc610cb9",
"type": "debug",
"z": "f35f22ba8892e611",
"name": "sparkplug debug",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 930,
"y": 780,
"wires": []
},
{
"id": "0d831bd9ba588536",
"type": "mqtt-sparkplug-broker",
"name": "Local Host",
"deviceGroup": "Sparkplug Devices",
"eonName": "Test6",
"broker": "localhost",
"port": "1883",
"clientid": "",
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"enableStoreForward": false,
"primaryScada": ""
}
]
The problem however is that the input metrics no longer show up in the ignition designer or ignition web interface
Edge Nodes - Sparkplug Devices - Test 5 and Test 6
They only show two folders : Node Control and Node Info but none of the input metrics. I would like to request for help in this regard. Thank you.