(Dashboard 2 comes later, first i need to fix the current iteration so it is back to working)
I have an issue where some of my webpage data will delete on page refresh.
Below are the pictures of what happens. I can't seem to figure out why.
Below the pictures is the code applicable.
Whenever i reinitialise they come back, but a page refresh or opening the dashboard elsewhere will show the bottom image.
A seperate system runs a seperate instance of this, and there, only Zone Voorwals is missing, the second column works just fine.
[
{
"id": "5408424ef8ae249d",
"type": "subflow",
"name": "HMI guard logic (1)",
"info": "",
"category": "",
"in": [
{
"x": 80,
"y": 80,
"wires": [
{
"id": "b757ea0ec0e8b2c3"
}
]
}
],
"out": [
{
"x": 1260,
"y": 200,
"wires": [
{
"id": "fdfe9ad7f18ca826",
"port": 0
}
]
},
{
"x": 1260,
"y": 320,
"wires": [
{
"id": "69c4118a241141b1",
"port": 0
}
]
}
],
"env": [],
"meta": {},
"color": "#DDAA99"
},
{
"id": "6c25754d13b0aa2b",
"type": "function",
"z": "5408424ef8ae249d",
"name": "Change msg",
"func": "var newMsg = {};\nnewMsg.addressSpaceItems = [];\nvar nodeObj = {};\n\nnewMsg.topic = \"\";\nnewMsg.nodetype = \"inject\";\nnewMsg.injectType = \"inject\";\nnewMsg.payload = \"\";\nnodeObj.name = \"Test_Read\";\nnodeObj.nodeId = msg.payload.nodeId;\nnodeObj.datatypeName = \"Boolean\";\nnewMsg.addressSpaceItems[0]= nodeObj;\nreturn newMsg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 450,
"y": 80,
"wires": [
[
"ca5cf2d30e774910"
]
]
},
{
"id": "b757ea0ec0e8b2c3",
"type": "OPCUA-IIoT-Response",
"z": "5408424ef8ae249d",
"name": "",
"compressStructure": true,
"showStatusActivities": false,
"showErrors": false,
"activateUnsetFilter": false,
"activateFilters": false,
"negateFilter": false,
"filters": [],
"x": 250,
"y": 80,
"wires": [
[
"6c25754d13b0aa2b"
]
]
},
{
"id": "ca5cf2d30e774910",
"type": "OPCUA-IIoT-Read",
"z": "5408424ef8ae249d",
"attributeId": "0",
"maxAge": 1,
"depth": 1,
"connector": "",
"name": "",
"justValue": true,
"showStatusActivities": false,
"showErrors": true,
"parseStrings": false,
"historyDays": 1,
"x": 650,
"y": 80,
"wires": [
[
"4f76c26ec623f542"
]
]
},
{
"id": "3bd9ae9e66ed9f3b",
"type": "template",
"z": "5408424ef8ae249d",
"name": "html table",
"field": "payload",
"fieldType": "msg",
"format": "html",
"syntax": "mustache",
"template": "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n\n <tr>\n <th>Name</th>\n <th>Status</th>\n <th>Date & Time</th>\n\n </tr>\n {{#payload}}\n <tr class=\"\">\n <td style=\"min-width:100px\">{{name}}</td> \n <td><font color=\"red\">{{stat}}</font></td>\n <td>{{localTime}}</td>\n </tr>\n {{/payload}}\n</table>\n",
"output": "str",
"x": 920,
"y": 500,
"wires": [
[]
]
},
{
"id": "3bd2b69926d9904b",
"type": "function",
"z": "5408424ef8ae249d",
"name": "topic & 10",
"func": "var arr = msg.payload ;\n\nvar i = 10;\nif(typeof arr === undefined) {\n return ;\n} else {\n msg.payload = arr.slice(0, 10); \n msg.topic = 'HMI recording messages :';\n return msg;\n}",
"outputs": 1,
"noerr": 0,
"x": 700,
"y": 500,
"wires": [
[
"3bd9ae9e66ed9f3b"
]
]
},
{
"id": "85fd0dd3261fb150",
"type": "change",
"z": "5408424ef8ae249d",
"name": "sort",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "($sort(payload,function($l , $r){$l.timestamp < $r.timestamp }) )",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 490,
"y": 500,
"wires": [
[
"3bd2b69926d9904b"
]
]
},
{
"id": "694866c801015862",
"type": "function",
"z": "5408424ef8ae249d",
"name": "Create/Update msg_events",
"func": "var msg_obj = msg.payload ;\nvar arr_msgs = flow.get(\"msg_events\", 'memoryOnly')\nvar debug = [];\nvar arrayObj = {};\nvar obj = {};\nvar temp = {};\nvar text=\"\";\nvar foundInArray = false;\nvar index = -1;\n\nif (arr_msgs===undefined ) {\n arr_msgs = [];\n}\n\n//Start script\ntext+=\"Start - \";\nfor(i=0;i<arr_msgs.length;i++){\n arrayObj = arr_msgs[i];\n \n if(arrayObj.name == msg_obj.name){\n foundInArray = true;\n index = i;\n }\n\n}\n\nif(foundInArray){\n if(msg.payload.value){\n //remove from array\n text+=\"Splice \" + i + \" - \";\n arr_msgs.splice(index,1);\n }\n text+=\"Already present - \";\n}\nelse{\n if(!msg.payload.value){\n //add to array\n text+=\"Push \" + i + \" - \";\n arr_msgs.push(msg_obj);\n }\n text+=\"Not yet present - \";\n text+=msg.payload.value + \" - \";\n}\n\ntext+=\"Klaar\";\n\nflow.set(\"msg_events\",arr_msgs, 'memoryOnly');\n\ntemp.payload = arr_msgs;\ntemp.debug = text;\nreturn temp;\n",
"outputs": 1,
"noerr": 0,
"x": 180,
"y": 500,
"wires": [
[
"85fd0dd3261fb150"
]
]
},
{
"id": "c870a92011056c63",
"type": "function",
"z": "5408424ef8ae249d",
"name": "Add timestamp",
"func": "msg_obj = msg.payload;\n\nvar d = new Date();\nvar jstime = d.getTime();\nmsg_obj.utc = jstime;\n\nmsg.payload = msg_obj ;\n\nreturn msg;\n\n",
"outputs": 1,
"noerr": 0,
"x": 540,
"y": 200,
"wires": [
[
"8c97ab603b20ada6"
]
]
},
{
"id": "8c97ab603b20ada6",
"type": "moment",
"z": "5408424ef8ae249d",
"name": "DST",
"topic": "",
"input": "payload.utc",
"inputType": "msg",
"inTz": "Europe/Brussels",
"adjAmount": 0,
"adjType": "days",
"adjDir": "add",
"format": "DD/MM/YYYY - HH:mm:ss",
"locale": "BE_nl",
"output": "payload.localTime",
"outputType": "msg",
"outTz": "Europe/Brussels",
"x": 710,
"y": 200,
"wires": [
[
"f51459d5d46627b7",
"42f6e8ecd2c89c59"
]
]
},
{
"id": "f51459d5d46627b7",
"type": "function",
"z": "5408424ef8ae249d",
"name": "Msg logic",
"func": "new_msg={};\n\nnew_msg.topic=msg.payload.name;\nif(!msg.payload.value){\n new_msg.payload=msg.payload;\n}\nelse{\n new_msg.reset=true;\n}\nreturn new_msg;\n\n\n\n\n\n\n",
"outputs": 1,
"noerr": 0,
"x": 660,
"y": 320,
"wires": [
[
"cdd0ddbec7d03cb4",
"c4e0aa58deeb5945"
]
]
},
{
"id": "cdd0ddbec7d03cb4",
"type": "trigger",
"z": "5408424ef8ae249d",
"name": "",
"op1": "",
"op2": "",
"op1type": "nul",
"op2type": "payl",
"duration": "1",
"extend": true,
"overrideDelay": false,
"units": "min",
"reset": "",
"bytopic": "topic",
"topic": "topic",
"outputs": 1,
"x": 850,
"y": 320,
"wires": [
[
"69c4118a241141b1"
]
]
},
{
"id": "69c4118a241141b1",
"type": "trigger",
"z": "5408424ef8ae249d",
"name": "",
"op1": "",
"op2": "",
"op1type": "pay",
"op2type": "pay",
"duration": "-1",
"extend": false,
"overrideDelay": false,
"units": "hr",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 1090,
"y": 320,
"wires": [
[]
]
},
{
"id": "c4e0aa58deeb5945",
"type": "function",
"z": "5408424ef8ae249d",
"name": "ResetResend",
"func": "msg.reset = true;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 860,
"y": 380,
"wires": [
[
"69c4118a241141b1"
]
]
},
{
"id": "42f6e8ecd2c89c59",
"type": "function",
"z": "5408424ef8ae249d",
"name": "Logic",
"func": "var msg_obj = msg.payload ;\nvar arr_msgs = flow.get(\"msg_events\")\nvar debug = [];\nvar arrayObj = {};\nvar temp = {};\nvar foundInArray = false;\n\nif (arr_msgs===undefined ) {\n arr_msgs = [];\n}\n\n//Start script\nfor(i=0;i<arr_msgs.length;i++){\n arrayObj = arr_msgs[i];\n \n if(arrayObj.node == msg_obj.node){\n arr_msgs[i] = msg_obj;\n foundInArray = true;\n index = i;\n }\n}\n\nif(!foundInArray){\n arr_msgs.push(msg_obj);\n}\n\nflow.set(\"msg_events\",arr_msgs);\n\ntemp.payload = arr_msgs;\nreturn temp;",
"outputs": 1,
"noerr": 0,
"x": 870,
"y": 200,
"wires": [
[
"3e5fa6d7ac5bd7e1"
]
]
},
{
"id": "3e5fa6d7ac5bd7e1",
"type": "change",
"z": "5408424ef8ae249d",
"name": "sort",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "($sort(payload,function($l , $r){$l.stat > $r.stat }) )",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1010,
"y": 200,
"wires": [
[
"fdfe9ad7f18ca826"
]
]
},
{
"id": "4f76c26ec623f542",
"type": "function",
"z": "5408424ef8ae249d",
"name": "New simple message",
"func": "var new_msg = {};\nvar new_obj = {};\nnew_obj.node = msg.payload[0].node;\nnew_obj.name = msg.payload[0].displayName.text;\nnew_obj.value = msg.payload[0].value;\nif(msg.payload[0].value){\n new_obj.stat = \"Recording\"\n new_obj.icon = \"fa-thumbs-up fa-1x\"\n new_obj.color = \"green\"\n}\nelse{\n new_obj.stat = \"Stopped\"\n new_obj.icon = \"fa-ambulance fa-1x fa-spin\"\n new_obj.color = \"red\"\n}\n\nnew_msg.payload = new_obj ;\n\nreturn new_msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 320,
"y": 200,
"wires": [
[
"c870a92011056c63"
]
]
},
{
"id": "fdfe9ad7f18ca826",
"type": "template",
"z": "5408424ef8ae249d",
"name": "html table",
"field": "payload",
"fieldType": "msg",
"format": "html",
"syntax": "mustache",
"template": "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n\n <tr>\n <th>Name</th>\n <th></th>\n <th>Status</th>\n <th>Date & Time</th>\n\n </tr>\n {{#payload}}\n <tr class=\"\">\n <td style=\"min-width:100px\">{{name}}</td> \n <td><i class=\"fa {{icon}}\"></i></td>\n <td>{{stat}}</td>\n <td>{{localTime}}</td>\n </tr>\n {{/payload}}\n</table>\n",
"output": "str",
"x": 1160,
"y": 200,
"wires": [
[]
]
},
{
"id": "cea74239b60a06a4",
"type": "comment",
"z": "5408424ef8ae249d",
"name": "Hier server instellen",
"info": "",
"x": 690,
"y": 40,
"wires": []
},
{
"id": "046d3339d0c1c1a9",
"type": "OPCUA-IIoT-Inject",
"z": "07159a452267ca75",
"injectType": "listen",
"payload": "{\"interval\":1000,\"queueSize\":10,\"options\":{\"requestedPublishingInterval\":500,\"requestedLifetimeCount\":2400,\"requestedMaxKeepAliveCount\":10,\"maxNotificationsPerPublish\":10,\"publishingEnabled\":true,\"priority\":2}}",
"payloadType": "json",
"topic": "",
"repeat": "",
"crontab": "",
"once": true,
"startDelay": "3",
"name": "Zone EW",
"addressSpaceItems": [
{
"name": "Wawi_L",
"nodeId": "ns=3;s=V:0.3.505.1.0",
"datatypeName": "Boolean"
},
{
"name": "Wawi_R",
"nodeId": "ns=3;s=V:0.3.505.1.1",
"datatypeName": "Boolean"
},
{
"name": "STK_1",
"nodeId": "ns=3;s=V:0.3.505.1.2",
"datatypeName": "Boolean"
},
{
"name": "STK_2",
"nodeId": "ns=3;s=V:0.3.505.1.3",
"datatypeName": "Boolean"
},
{
"name": "Kelk",
"nodeId": "ns=3;s=V:0.3.505.1.4",
"datatypeName": "Boolean"
},
{
"name": "IMS_Camera",
"nodeId": "ns=3;s=V:0.3.505.1.22",
"datatypeName": "Boolean"
},
{
"name": "Wawi_A",
"nodeId": "ns=3;s=V:0.3.505.1.17",
"datatypeName": "Boolean"
},
{
"name": "Test_Org",
"nodeId": "ns=3;s=V:0.3.505.1.24",
"datatypeName": "Boolean"
}
],
"x": 740,
"y": 480,
"wires": [
[
"13bb9b6e8520acd9"
]
]
},
{
"id": "a59f0b3be0b333fd",
"type": "ui_template",
"z": "07159a452267ca75",
"group": "bf790338.61cc2",
"name": "Webpagina EW",
"order": 0,
"width": 0,
"height": 0,
"format": "<div ng-bind-html=\"msg.payload\" height=\"500\" style=\"height: 350px;\"></div>",
"storeOutMessages": false,
"fwdInMessages": true,
"resendOnRefresh": false,
"templateScope": "local",
"x": 1480,
"y": 480,
"wires": [
[]
]
},
{
"id": "7211c248c851fb68",
"type": "subflow:5408424ef8ae249d",
"z": "07159a452267ca75",
"name": "",
"env": [],
"x": 1200,
"y": 480,
"wires": [
[
"a59f0b3be0b333fd"
],
[]
]
},
{
"id": "13bb9b6e8520acd9",
"type": "OPCUA-IIoT-Listener",
"z": "07159a452267ca75",
"connector": "",
"action": "subscribe",
"queueSize": "10",
"name": "",
"topic": "",
"justValue": true,
"useGroupItems": false,
"showStatusActivities": true,
"showErrors": true,
"x": 957,
"y": 480,
"wires": [
[
"7211c248c851fb68"
]
]
},
{
"id": "bf790338.61cc2",
"type": "ui_group",
"name": "Zone Eindwals",
"tab": "e1314aed.555798",
"order": 2,
"disp": true,
"width": "10",
"collapse": false
},
{
"id": "e1314aed.555798",
"type": "ui_tab",
"name": "IBA Capture HMI",
"icon": "dashboard",
"order": 2,
"disabled": false,
"hidden": false
}
]