How do I make an Alarm Table?

How do I make an alarm table like this?

image

I have a modbus read reading a bunch of coils. Each coil is an alarm. As certain alarms become active/de-active, the messages will appear/disappear in the alarm table.

Is there a node for this?

Probably the one from below link will help you out. It is a quite smart and well designed subflow.

I gave it a try, and it's really close to what I need. I'm trying to learn and adapt its code to what I need and here's what I'm seeing.

[{"id":"be7e9a7b.37f6f8","type":"tab","label":"Alarms","disabled":false,"info":""},{"id":"3ebf1dcd.1bd392","type":"switch","z":"be7e9a7b.37f6f8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":550,"y":240,"wires":[["9bf363e8.96054","384832e9.12747e"]]},{"id":"9bf363e8.96054","type":"change","z":"be7e9a7b.37f6f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.alm_time","pt":"msg","to":"","tot":"date"},{"t":"set","p":"payload.fault","pt":"msg","to":"alarm 1 fault","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":240,"wires":[["e1abd4ec.adfc88","ed140795.e21548","3ebf1dcd.1bd392"]]},{"id":"10acaa9.8545e55","type":"ui_table","z":"be7e9a7b.37f6f8","group":"37b5f1bd.773eae","name":"","order":1,"width":"6","height":"4","columns":[],"outputs":1,"cts":true,"x":1210,"y":620,"wires":[[]]},{"id":"384832e9.12747e","type":"debug","z":"be7e9a7b.37f6f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":380,"wires":[]},{"id":"e1abd4ec.adfc88","type":"debug","z":"be7e9a7b.37f6f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":980,"y":340,"wires":[]},{"id":"ed140795.e21548","type":"function","z":"be7e9a7b.37f6f8","name":"add to schedule","func":"const ogSchedule = flow.get(\"schedule\") || [];\nlet schedule = JSON.parse(JSON.stringify(ogSchedule));\nlet command = msg.payload;\n// command.alm_time = command.alm_time.trim();\ncommand.fault = command.fault.trim();\n//command.time = command.time.trim();\n//command.days = command.days.split(\",\");\n//command.days = command.days.map(item => parseInt(item));\n\n//if (command.command.match(/^[0-9]*\\.*[0-9]*$/g)) { command.command = Number(command.command); }\n//if (command.command === \"true\") { command.command = true; }\n//if (command.command === \"false\") { command.command = false; }\nlet newindex = null;\nif(schedule.length > 0){\n    for(i=0;i<schedule.length-1;i++){\n        if(command.time >= schedule[i].time && command.time < schedule[i+1].time){\n            newindex = i+1;\n        }\n    }\n    if(newindex !== null){\n        schedule.splice(newindex,0,command);\n    } else if (command.time < schedule[0].time){\n        schedule.splice(0,0,command);\n    } else {\n        schedule.push(command);\n    }\n} else {\n    schedule.push(command);\n}\nmsg.payload = schedule;\n\nflow.set(\"schedule\", schedule);\nreturn [msg, null]; ","outputs":2,"noerr":0,"initialize":"","finalize":"","x":950,"y":400,"wires":[["1fcce9a0.be2d56","10acaa9.8545e55"],[]]},{"id":"1fcce9a0.be2d56","type":"debug","z":"be7e9a7b.37f6f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":520,"wires":[]},{"id":"92ad7aa9.d02ff8","type":"rbe","z":"be7e9a7b.37f6f8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":380,"y":240,"wires":[["3ebf1dcd.1bd392","1c3a66bb.a0b789"]]},{"id":"1c3a66bb.a0b789","type":"debug","z":"be7e9a7b.37f6f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":440,"wires":[]},{"id":"4afbb697.a2f678","type":"switch","z":"be7e9a7b.37f6f8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":570,"y":660,"wires":[["cdebc9bc.7cb358","a5055e99.26f94"]]},{"id":"cdebc9bc.7cb358","type":"change","z":"be7e9a7b.37f6f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.alm_time","pt":"msg","to":"","tot":"date"},{"t":"set","p":"payload.fault","pt":"msg","to":"alarm 2 fault","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":660,"wires":[["7b3ce8a0.f31308","cc605224.e6b5e","4afbb697.a2f678","10acaa9.8545e55"]]},{"id":"a5055e99.26f94","type":"debug","z":"be7e9a7b.37f6f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":800,"wires":[]},{"id":"7b3ce8a0.f31308","type":"debug","z":"be7e9a7b.37f6f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1000,"y":760,"wires":[]},{"id":"cc605224.e6b5e","type":"function","z":"be7e9a7b.37f6f8","name":"add to schedule","func":"const ogSchedule = flow.get(\"schedule\") || [];\nlet schedule = JSON.parse(JSON.stringify(ogSchedule));\nlet command = msg.payload;\n// command.alm_time = command.alm_time.trim();\ncommand.fault = command.fault.trim();\n//command.time = command.time.trim();\n//command.days = command.days.split(\",\");\n//command.days = command.days.map(item => parseInt(item));\n\n//if (command.command.match(/^[0-9]*\\.*[0-9]*$/g)) { command.command = Number(command.command); }\n//if (command.command === \"true\") { command.command = true; }\n//if (command.command === \"false\") { command.command = false; }\nlet newindex = null;\nif(schedule.length > 0){\n    for(i=0;i<schedule.length-1;i++){\n        if(command.time >= schedule[i].time && command.time < schedule[i+1].time){\n            newindex = i+1;\n        }\n    }\n    if(newindex !== null){\n        schedule.splice(newindex,0,command);\n    } else if (command.time < schedule[0].time){\n        schedule.splice(0,0,command);\n    } else {\n        schedule.push(command);\n    }\n} else {\n    schedule.push(command);\n}\nmsg.payload = schedule;\n\nflow.set(\"schedule\", schedule);\nreturn [msg, null]; ","outputs":2,"noerr":0,"initialize":"","finalize":"","x":970,"y":820,"wires":[["5e0581d3.54bc1","10acaa9.8545e55"],[]]},{"id":"5e0581d3.54bc1","type":"debug","z":"be7e9a7b.37f6f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1120,"y":980,"wires":[]},{"id":"65cab5ef.f893bc","type":"rbe","z":"be7e9a7b.37f6f8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":400,"y":660,"wires":[["4afbb697.a2f678","a538070e.3bb038"]]},{"id":"3da7e28c.c82e0e","type":"debug","z":"be7e9a7b.37f6f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":400,"y":760,"wires":[]},{"id":"a538070e.3bb038","type":"debug","z":"be7e9a7b.37f6f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":860,"wires":[]},{"id":"de8087c3.b0a208","type":"inject","z":"be7e9a7b.37f6f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"str","x":200,"y":600,"wires":[["65cab5ef.f893bc"]]},{"id":"245a43f7.287acc","type":"inject","z":"be7e9a7b.37f6f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"str","x":210,"y":680,"wires":[["65cab5ef.f893bc"]]},{"id":"dd6abcf4.c2f58","type":"inject","z":"be7e9a7b.37f6f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"str","x":210,"y":200,"wires":[["92ad7aa9.d02ff8"]]},{"id":"4100e88e.f88ff8","type":"inject","z":"be7e9a7b.37f6f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"str","x":220,"y":280,"wires":[["92ad7aa9.d02ff8"]]},{"id":"37b5f1bd.773eae","type":"ui_group","name":"1750+ 1 alarms","tab":"78efbcf6.3781f4","order":2,"disp":true,"width":"6","collapse":false},{"id":"78efbcf6.3781f4","type":"ui_tab","name":"Scheduler","icon":"autorenew","order":2,"disabled":false,"hidden":false}]

I see that the table takes in an array of data, and that array is generated in the function block. In my testing, I generated an array over 1000 elements large. How do I reset this?

image

I also need the table to remove the alarm that is not active automatically. How do I remove just that from the array?

The array looks like this:
image
I need to remove all with fault: "alarm 1 fault".

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.