# How do I make an Alarm Table?

**URL:** <https://discourse.nodered.org/t/how-do-i-make-an-alarm-table/38718>\
**Category:** General\
**Created:** [7 January 2021 14:37 UTC](https://discourse.nodered.org/t/how-do-i-make-an-alarm-table/38718 "2021-01-07T14:37:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![traderjoe](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@traderjoe](https://discourse.nodered.org/u/traderjoe)\
**Post date:** [7 January 2021 14:37 UTC](https://discourse.nodered.org/t/how-do-i-make-an-alarm-table/38718/1 "2021-01-07T14:37:55Z")

</div>

How do I make an alarm table like this?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/f/cf39154e984227bf717ef2fa1ffd3507f48a8f2f.png)

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?

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [7 January 2021 14:46 UTC](https://discourse.nodered.org/t/how-do-i-make-an-alarm-table/38718/2 "2021-01-07T14:46:29Z")

</div>

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

> [@\[Announce\] Scheduler Subflow Node and Dashboard Ui Scheduler Flow (Updated)](https://discourse.nodered.org/t/announce-scheduler-subflow-node-and-dashboard-ui-scheduler-flow-updated/36399/2):
>
> Dashboard Ui Scheduler Flow The simple input format makes it „easy“ to combine with the dashboard see_no_evil but fortunately i have done all the work already (needs node-red-ui-table): [{"id":"dc275690.07356","type":"subflow","name":"scheduler","info":"A scheduler that repeatedly executes\nschedules put in as an array of objects\nas a ```msg.payload``` in the format of:\n```\n[\n {\n \"item\": \"test\",\n \"command\": \"ON\",\n \"time\": \"08:30\"\n },\n {\n \"item\"…

---

<div class="post-metadata">

**Author:** ![traderjoe](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@traderjoe](https://discourse.nodered.org/u/traderjoe)\
**Post date:** [7 January 2021 20:56 UTC](https://discourse.nodered.org/t/how-do-i-make-an-alarm-table/38718/3 "2021-01-07T20:56:02Z")

</div>

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.

```auto
[{"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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/7/67daee46143d3d11176763de68de10f232045bd3.png)

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/9/29f1bc20b82e93c6060525e3b2f27958850da601.png)  
I need to remove all with fault: "alarm 1 fault".

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 March 2021 20:56 UTC](https://discourse.nodered.org/t/how-do-i-make-an-alarm-table/38718/4 "2021-03-08T20:56:04Z")

</div>

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