Display active alarms (Booleans) on dashboard

Hello everyone

I have a list of 50 possible alarms. These come in via a boolean (1 per alarm). I am trying to display the active alarms on the dashboard via the UI-Template-Node.

Is there an easy way to accomplish this?
If I have to realize this with an if else structure, there are many possibilities.
Incidentally, I would like a new line on the dashboard for each alarm.

Someone who can get me started?
Is there a way to show / hide a message based on the status, through the UI template node?

Example for only 2 alarms:

Flow:

[{"id":"826158f6.ce9268","type":"ui_template","z":"24d31ef4.bdf632","group":"80eb9d72.5ab94","name":"Actieve Alarmen","order":0,"width":0,"height":0,"format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":2720,"y":1740,"wires":[[]]},{"id":"a0804e38.7309b","type":"inject","z":"24d31ef4.bdf632","name":"Alarm 1: True","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":1910,"y":1660,"wires":[["59d14592.82cb7c"]]},{"id":"3ff0ea44.b6f6c6","type":"inject","z":"24d31ef4.bdf632","name":"Alarm 1: False","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":1910,"y":1700,"wires":[["59d14592.82cb7c"]]},{"id":"7cfffd23.6a68f4","type":"inject","z":"24d31ef4.bdf632","name":"Alarm 2: True","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":1910,"y":1800,"wires":[["7c7b0b1c.ee8984"]]},{"id":"a332bfbd.4d056","type":"inject","z":"24d31ef4.bdf632","name":"Alarm 2: False","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":1910,"y":1840,"wires":[["7c7b0b1c.ee8984"]]},{"id":"1c839cbd.9baa53","type":"join","z":"24d31ef4.bdf632","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"1","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":2310,"y":1740,"wires":[["a5482915.8f1428","10ff4d3b.d5bc93"]]},{"id":"a5482915.8f1428","type":"function","z":"24d31ef4.bdf632","name":"Actieve alarmen","func":"if (msg.payload.Alarm_1 === false  &&  msg.payload.Alarm_2 === false ) {\n    msg.payload = \"Geen alarmen actief.\";\n    \n} else if (msg.payload.Alarm_1 === true  &&  msg.payload.Alarm_2 === false ) {\n    msg.payload = \"Alarm 1 actief.\";\n    \n} else if (msg.payload.Alarm_1 === false  &&  msg.payload.Alarm_2 === true ) {\n    msg.payload = \"Alarm 2 actief.\";\n       \n} else {\n    msg.payload = \"Alarm 1 en Alarm 2 actief!\";\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2500,"y":1740,"wires":[["826158f6.ce9268","5e713385.8f009c"]]},{"id":"10ff4d3b.d5bc93","type":"debug","z":"24d31ef4.bdf632","name":"Merged message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2470,"y":1820,"wires":[]},{"id":"d424066f.144bc8","type":"comment","z":"24d31ef4.bdf632","name":"Simulating Boolean Alarm 1","info":"","x":1960,"y":1620,"wires":[]},{"id":"a26be142.ad4db","type":"comment","z":"24d31ef4.bdf632","name":"Simulating Boolean Alarm 2","info":"","x":1960,"y":1760,"wires":[]},{"id":"5e713385.8f009c","type":"debug","z":"24d31ef4.bdf632","name":"Active Alarms","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2720,"y":1820,"wires":[]},{"id":"59d14592.82cb7c","type":"change","z":"24d31ef4.bdf632","name":"Set Topic: Alarm_1","rules":[{"t":"set","p":"topic","pt":"msg","to":"Alarm_1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2110,"y":1680,"wires":[["1c839cbd.9baa53"]]},{"id":"7c7b0b1c.ee8984","type":"change","z":"24d31ef4.bdf632","name":"Set Topic: Alarm_2","rules":[{"t":"set","p":"topic","pt":"msg","to":"Alarm_2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2110,"y":1820,"wires":[["1c839cbd.9baa53"]]},{"id":"80eb9d72.5ab94","type":"ui_group","z":"","name":"Actieve Alarmen","tab":"175b80b4.690fbf","order":2,"disp":true,"width":"6","collapse":false},{"id":"175b80b4.690fbf","type":"ui_tab","z":"","name":"Alarmen","icon":"announcement","order":7,"disabled":false,"hidden":false}]

Thank you for your time!
Arne

Hello Arne,

I must admit that this needed a lot of research ..
basically we needed to put the alarms in an array of objects .. with alarm.title and alarm.value (true false) ... then with the use of angular, loop through the data to display it dynamically.

.. with some magic in the preceding function :

[{"id":"c7a9d042.af62b","type":"ui_template","z":"879ba9f3.6ab73","group":"d8c473c2.474058","name":"Actieve Alarmen","order":0,"width":"0","height":"0","format":"<style scoped>\n    table {margin-bottom:180px;}\n    td {font-weight:800; padding-right:100px;}\n</style>\n\n<table>\n<tr>\n<td>Title</td>\n<td>Status</td>\n</tr>\n<tr ng-repeat=\"alarm in msg.payload\">\n    <td>{{alarm.title}}</td>\n    <td>{{alarm.value}}</td>\n</tr>\n</table>\n\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":1020,"y":280,"wires":[[]]},{"id":"393588f8.b8d528","type":"inject","z":"879ba9f3.6ab73","name":"Alarm 1: True","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":210,"y":240,"wires":[["54f33483.8c3f2c"]]},{"id":"5147053c.75da44","type":"inject","z":"879ba9f3.6ab73","name":"Alarm 1: False","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":210,"y":280,"wires":[["54f33483.8c3f2c"]]},{"id":"9e76d000.710eb","type":"inject","z":"879ba9f3.6ab73","name":"Alarm 2: True","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":210,"y":380,"wires":[["c148de05.b3036"]]},{"id":"adfa0e2d.70681","type":"inject","z":"879ba9f3.6ab73","name":"Alarm 2: False","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":210,"y":420,"wires":[["c148de05.b3036"]]},{"id":"12b4aed5.642589","type":"join","z":"879ba9f3.6ab73","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"1","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":610,"y":320,"wires":[["f499866b.dc43f","b2b27f11.74dbe"]]},{"id":"90950d87.bb074","type":"function","z":"879ba9f3.6ab73","name":"Actieve alarmen","func":"if (msg.payload.Alarm_1 === false  &&  msg.payload.Alarm_2 === false ) {\n    msg.payload = \"Geen alarmen actief.\";\n    \n} else if (msg.payload.Alarm_1 === true  &&  msg.payload.Alarm_2 === false ) {\n    msg.payload = \"Alarm 1 actief.\";\n    \n} else if (msg.payload.Alarm_1 === false  &&  msg.payload.Alarm_2 === true ) {\n    msg.payload = \"Alarm 2 actief.\";\n       \n} else {\n    msg.payload = \"Alarm 1 en Alarm 2 actief!\";\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":200,"wires":[[]]},{"id":"f499866b.dc43f","type":"debug","z":"879ba9f3.6ab73","name":"Merged message","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":400,"wires":[]},{"id":"a148176e.2e095","type":"comment","z":"879ba9f3.6ab73","name":"Simulating Boolean Alarm 1","info":"","x":260,"y":200,"wires":[]},{"id":"c20f04be.9a18a8","type":"comment","z":"879ba9f3.6ab73","name":"Simulating Boolean Alarm 2","info":"","x":260,"y":340,"wires":[]},{"id":"769be2a4.d1befc","type":"debug","z":"879ba9f3.6ab73","name":"Active Alarms","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1020,"y":400,"wires":[]},{"id":"54f33483.8c3f2c","type":"change","z":"879ba9f3.6ab73","name":"Set Topic: Alarm_1","rules":[{"t":"set","p":"topic","pt":"msg","to":"Alarm_1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":260,"wires":[["12b4aed5.642589"]]},{"id":"c148de05.b3036","type":"change","z":"879ba9f3.6ab73","name":"Set Topic: Alarm_2","rules":[{"t":"set","p":"topic","pt":"msg","to":"Alarm_2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":400,"wires":[["12b4aed5.642589"]]},{"id":"b2b27f11.74dbe","type":"function","z":"879ba9f3.6ab73","name":"","func":"let keys = Object.keys(msg.payload);\nlet values = Object.values(msg.payload);\nlet arr = [];\n\nkeys.forEach((el, index) => {\n \n  arr.push({\n      title: keys[index],\n      value: values[index]\n      \n  })  \n    \n})\n\n// sorting alphabetically // needs testing\narr.sort(function(a, b) {\n  var titleA = a.title.toUpperCase(); // ignore upper and lowercase\n  var titleB = b.title.toUpperCase(); // ignore upper and lowercase\n  if (titleA < titleB) {\n    return -1;\n  }\n  if (titleA > titleB) {\n    return 1;\n  }\n\n  // title must be equal\n  return 0;\n});\n\n\nmsg.payload = arr;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":810,"y":320,"wires":[["769be2a4.d1befc","c7a9d042.af62b"]]},{"id":"d8c473c2.474058","type":"ui_group","z":"","name":"Actieve Alarmen","tab":"9e4049a7.18d0c8","order":2,"disp":true,"width":"8","collapse":false},{"id":"9e4049a7.18d0c8","type":"ui_tab","z":"","name":"Alarmen","icon":"announcement","order":7,"disabled":false,"hidden":false}]

[edit] after reading your post again i modified the flow to filter out only the Alarms that are true.

[{"id":"c7a9d042.af62b","type":"ui_template","z":"879ba9f3.6ab73","group":"d8c473c2.474058","name":"Actieve Alarmen","order":0,"width":"0","height":"0","format":"<style scoped>\n    table {margin-bottom:180px;}\n    td {font-weight:800; padding-right:100px;}\n</style>\n\n<table>\n<tr>\n<td>Title</td>\n<td>Status</td>\n</tr>\n<tr ng-repeat=\"alarm in msg.payload\">\n    <td ng-if=\"alarm.value='true'\">{{alarm.title}}</td>\n    <td ng-if=\"alarm.value='true'\">{{alarm.value}}</td>\n</tr>\n</table>\n\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":1020,"y":280,"wires":[[]]},{"id":"393588f8.b8d528","type":"inject","z":"879ba9f3.6ab73","name":"Alarm 1: True","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":210,"y":240,"wires":[["54f33483.8c3f2c"]]},{"id":"5147053c.75da44","type":"inject","z":"879ba9f3.6ab73","name":"Alarm 1: False","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":210,"y":280,"wires":[["54f33483.8c3f2c"]]},{"id":"9e76d000.710eb","type":"inject","z":"879ba9f3.6ab73","name":"Alarm 2: True","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":210,"y":380,"wires":[["c148de05.b3036"]]},{"id":"adfa0e2d.70681","type":"inject","z":"879ba9f3.6ab73","name":"Alarm 2: False","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":210,"y":420,"wires":[["c148de05.b3036"]]},{"id":"12b4aed5.642589","type":"join","z":"879ba9f3.6ab73","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"1","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":610,"y":320,"wires":[["f499866b.dc43f","b2b27f11.74dbe"]]},{"id":"90950d87.bb074","type":"function","z":"879ba9f3.6ab73","name":"Actieve alarmen","func":"if (msg.payload.Alarm_1 === false  &&  msg.payload.Alarm_2 === false ) {\n    msg.payload = \"Geen alarmen actief.\";\n    \n} else if (msg.payload.Alarm_1 === true  &&  msg.payload.Alarm_2 === false ) {\n    msg.payload = \"Alarm 1 actief.\";\n    \n} else if (msg.payload.Alarm_1 === false  &&  msg.payload.Alarm_2 === true ) {\n    msg.payload = \"Alarm 2 actief.\";\n       \n} else {\n    msg.payload = \"Alarm 1 en Alarm 2 actief!\";\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":200,"wires":[[]]},{"id":"f499866b.dc43f","type":"debug","z":"879ba9f3.6ab73","name":"Merged message","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":400,"wires":[]},{"id":"a148176e.2e095","type":"comment","z":"879ba9f3.6ab73","name":"Simulating Boolean Alarm 1","info":"","x":260,"y":200,"wires":[]},{"id":"c20f04be.9a18a8","type":"comment","z":"879ba9f3.6ab73","name":"Simulating Boolean Alarm 2","info":"","x":260,"y":340,"wires":[]},{"id":"769be2a4.d1befc","type":"debug","z":"879ba9f3.6ab73","name":"Active Alarms","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1020,"y":400,"wires":[]},{"id":"54f33483.8c3f2c","type":"change","z":"879ba9f3.6ab73","name":"Set Topic: Alarm_1","rules":[{"t":"set","p":"topic","pt":"msg","to":"Alarm_1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":260,"wires":[["12b4aed5.642589"]]},{"id":"c148de05.b3036","type":"change","z":"879ba9f3.6ab73","name":"Set Topic: Alarm_2","rules":[{"t":"set","p":"topic","pt":"msg","to":"Alarm_2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":400,"wires":[["12b4aed5.642589"]]},{"id":"b2b27f11.74dbe","type":"function","z":"879ba9f3.6ab73","name":"","func":"let keys = Object.keys(msg.payload);\nlet values = Object.values(msg.payload);\nlet arr = [];\n\nkeys.forEach((el, index) => {\n \n if (values[index]) {  // if alarm true\n  arr.push({\n      title: keys[index],\n      value: values[index]\n      \n  })  \n } // end of if\n    \n})\n\n// sorting alphabetically // needs testing\narr.sort(function(a, b) {\n  var titleA = a.title.toUpperCase(); // ignore upper and lowercase\n  var titleB = b.title.toUpperCase(); // ignore upper and lowercase\n  if (titleA < titleB) {\n    return -1;\n  }\n  if (titleA > titleB) {\n    return 1;\n  }\n\n  // title must be equal\n  return 0;\n});\n\n\nmsg.payload = arr;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":810,"y":320,"wires":[["769be2a4.d1befc","c7a9d042.af62b"]]},{"id":"d8c473c2.474058","type":"ui_group","z":"","name":"Actieve Alarmen","tab":"9e4049a7.18d0c8","order":2,"disp":true,"width":"8","collapse":false},{"id":"9e4049a7.18d0c8","type":"ui_tab","z":"","name":"Alarmen","icon":"announcement","order":7,"disabled":false,"hidden":false}]
2 Likes

@ArneR looking at your code, it you had 15 alarms at once, you are going to have a very long message displaying, right?

Not knowing what you are building as a dashboard, I would have one 'Alarm" box that would flash off and on the word 'Alarm' with a buttin below it that when pressed would take you to a different dashboard tab (read up on ui_control) which would list all the alarms and flash the ones that are active.

Here is an example of what I suggest

[{"id":"34871cd1.61904c","type":"tab","label":"Alarm master","disabled":false,"info":""},{"id":"bd98324d.e492f","type":"tab","label":"Alarm tab","disabled":false,"info":""},{"id":"3584e894.e0b5e8","type":"subflow","name":"Subflow 1","info":"","in":[{"x":40,"y":60,"wires":[{"id":"c87f6adf.4005f"}]}],"out":[]},{"id":"f1b4d536.e8bf78","type":"ui_group","z":"","name":"Actieve Alarmen","tab":"bcc196f4.9c2e78","order":2,"disp":true,"width":"6","collapse":false},{"id":"7c41c8ea.d16a48","type":"ui_group","z":"","name":"Alarms","tab":"385a4e70.e53d42","order":1,"disp":true,"width":"6","collapse":false},{"id":"bcc196f4.9c2e78","type":"ui_tab","z":"","name":"Alarmen","icon":"announcement","order":1,"disabled":false,"hidden":false},{"id":"385a4e70.e53d42","type":"ui_tab","z":"","name":"Alarm List","icon":"dashboard","disabled":false,"hidden":false},{"id":"7e1bddce.9c9e6c","type":"ui_template","z":"34871cd1.61904c","group":"f1b4d536.e8bf78","name":"Actieve Alarmen","order":0,"width":0,"height":0,"format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":1080,"y":280,"wires":[[]]},{"id":"d720061.f5fc178","type":"inject","z":"34871cd1.61904c","name":"Alarm 1: True","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Alarm_1","payload":"true","payloadType":"bool","x":110,"y":140,"wires":[["115e0d05.17189b","36f38593.eec352"]]},{"id":"671f92a0.e295d4","type":"inject","z":"34871cd1.61904c","name":"Alarm 1: False","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":110,"y":320,"wires":[["f70b3ef7.2a6c2","dc1ee0aa.d9a48"]]},{"id":"c2576e52.1ff0b8","type":"inject","z":"34871cd1.61904c","name":"Alarm 2: True","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Alarm_2","payload":"true","payloadType":"bool","x":110,"y":180,"wires":[["115e0d05.17189b","a1bd0f57.72a2e"]]},{"id":"df0bc87.63e1938","type":"inject","z":"34871cd1.61904c","name":"Alarm 2: False","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":110,"y":360,"wires":[["f70b3ef7.2a6c2","e5ebc6cd.2ddb5"]]},{"id":"23e549d7.b9e8de","type":"comment","z":"34871cd1.61904c","name":"Simulating Alarm on","info":"","x":130,"y":100,"wires":[]},{"id":"115e0d05.17189b","type":"change","z":"34871cd1.61904c","name":"Increase Alarm count","rules":[{"t":"set","p":"alarm_count","pt":"global","to":"$globalContext('alarm_count')+1","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":260,"wires":[[]]},{"id":"437a2dc8.963a24","type":"inject","z":"34871cd1.61904c","name":"Alarm 3: True","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Alarm_3","payload":"true","payloadType":"bool","x":110,"y":220,"wires":[["115e0d05.17189b","8d71edd0.60add"]]},{"id":"a72d8f7f.d3edf","type":"inject","z":"34871cd1.61904c","name":"Alarm 3: False","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":110,"y":400,"wires":[["f70b3ef7.2a6c2","6830ac3d.59a5d4"]]},{"id":"122fbff9.eb4f4","type":"comment","z":"34871cd1.61904c","name":"Simulating Alarm off","info":"","x":130,"y":280,"wires":[]},{"id":"f70b3ef7.2a6c2","type":"change","z":"34871cd1.61904c","name":"Decrease Alarm count","rules":[{"t":"set","p":"alarm_count","pt":"global","to":"$globalContext('alarm_count')-1","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":440,"wires":[[]]},{"id":"f58ecc34.79d4b","type":"inject","z":"34871cd1.61904c","name":"","props":[{"p":"payload"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":650,"y":40,"wires":[["4e30c586.8a2634"]]},{"id":"8bd9d36c.5120d","type":"inject","z":"34871cd1.61904c","name":"runs at startup only","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":130,"y":40,"wires":[["86d55e7b.1e3848"]]},{"id":"86d55e7b.1e3848","type":"change","z":"34871cd1.61904c","name":"Zero Alarm count","rules":[{"t":"set","p":"alarm_count","pt":"global","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":40,"wires":[[]]},{"id":"4e30c586.8a2634","type":"switch","z":"34871cd1.61904c","name":"Check alarm_count","property":"alarm_count","propertyType":"global","rules":[{"t":"gt","v":"0","vt":"num"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":670,"y":100,"wires":[["86a6d8c7.2ca9c8"],["70d23327.4ce214"]]},{"id":"86a6d8c7.2ca9c8","type":"change","z":"34871cd1.61904c","name":"ALERT","rules":[{"t":"set","p":"payload","pt":"msg","to":"ALERT!!!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":100,"wires":[["8ed3f0dd.f563c"]]},{"id":"8ed3f0dd.f563c","type":"trigger","z":"34871cd1.61904c","name":"","op1":"ALERT!!","op2":"","op1type":"str","op2type":"str","duration":"-1","extend":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":900,"y":160,"wires":[["8c09b469.1c2b8","7e1bddce.9c9e6c"]]},{"id":"ab790922.6c3628","type":"change","z":"34871cd1.61904c","name":"blank to cause flashing","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":280,"wires":[["7e1bddce.9c9e6c"]]},{"id":"8c09b469.1c2b8","type":"delay","z":"34871cd1.61904c","name":"","pauseType":"delay","timeout":".5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":880,"y":220,"wires":[["ab790922.6c3628"]]},{"id":"70d23327.4ce214","type":"change","z":"34871cd1.61904c","name":"Reset alarm","rules":[{"t":"set","p":"reset","pt":"msg","to":"reset","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":160,"wires":[["8ed3f0dd.f563c","ab790922.6c3628"]]},{"id":"36f38593.eec352","type":"link out","z":"34871cd1.61904c","name":"to Alarm 1 ON","links":["c676b71b.fd1aa8"],"x":340,"y":140,"wires":[],"l":true},{"id":"8d71edd0.60add","type":"link out","z":"34871cd1.61904c","name":"to Alarm 3 ON","links":["2139aebc.b5986a"],"x":340,"y":220,"wires":[],"l":true},{"id":"a1bd0f57.72a2e","type":"link out","z":"34871cd1.61904c","name":"to Alarm 2 ON","links":["bb4f893a.70fab"],"x":340,"y":180,"wires":[],"l":true},{"id":"e5ebc6cd.2ddb5","type":"link out","z":"34871cd1.61904c","name":"to Alarm 2 OFF","links":["c09eb706.79b6a"],"x":340,"y":360,"wires":[],"l":true},{"id":"6830ac3d.59a5d4","type":"link out","z":"34871cd1.61904c","name":"to Alarm 3 OFF","links":["e02044d8.c7058"],"x":340,"y":400,"wires":[],"l":true},{"id":"dc1ee0aa.d9a48","type":"link out","z":"34871cd1.61904c","name":"to Alarm 1 OFF","links":["7496f030.aebc9"],"x":340,"y":320,"wires":[],"l":true},{"id":"83a0ec71.25a478","type":"ui_ui_control","z":"34871cd1.61904c","name":"","events":"connect","x":1060,"y":400,"wires":[[]]},{"id":"8f4d8775.3d80f","type":"ui_button","z":"34871cd1.61904c","name":"","group":"f1b4d536.e8bf78","order":1,"width":0,"height":0,"passthru":false,"label":"Go to alarms tab","tooltip":"","color":"","bgcolor":"","icon":"","payload":"{\"tab\":\"Alarm List\"}","payloadType":"json","topic":"","x":1090,"y":340,"wires":[["83a0ec71.25a478"]]},{"id":"c676b71b.fd1aa8","type":"link in","z":"bd98324d.e492f","name":"Alarrm 1 ON","links":["36f38593.eec352"],"x":170,"y":60,"wires":[["dd7a4cb2.063138"]],"l":true},{"id":"7496f030.aebc9","type":"link in","z":"bd98324d.e492f","name":"Alarrm 1 OFF","links":["dc1ee0aa.d9a48"],"x":170,"y":120,"wires":[["dd7a4cb2.063138"]],"l":true},{"id":"bb4f893a.70fab","type":"link in","z":"bd98324d.e492f","name":"Alarrm 2 ON","links":["a1bd0f57.72a2e"],"x":170,"y":200,"wires":[["b2128ea.f5304f"]],"l":true},{"id":"c09eb706.79b6a","type":"link in","z":"bd98324d.e492f","name":"Alarrm 2 OFF","links":["e5ebc6cd.2ddb5"],"x":170,"y":260,"wires":[["b2128ea.f5304f"]],"l":true},{"id":"2139aebc.b5986a","type":"link in","z":"bd98324d.e492f","name":"Alarrm 3 ON","links":["8d71edd0.60add"],"x":170,"y":320,"wires":[["e5df9d31.0ee7b8"]],"l":true},{"id":"e02044d8.c7058","type":"link in","z":"bd98324d.e492f","name":"Alarrm 3 OFF","links":["6830ac3d.59a5d4"],"x":170,"y":380,"wires":[["e5df9d31.0ee7b8"]],"l":true},{"id":"dd7a4cb2.063138","type":"subflow:3584e894.e0b5e8","z":"bd98324d.e492f","name":"","x":500,"y":100,"wires":[]},{"id":"b2128ea.f5304f","type":"subflow:3584e894.e0b5e8","z":"bd98324d.e492f","name":"","x":510,"y":220,"wires":[]},{"id":"e5df9d31.0ee7b8","type":"subflow:3584e894.e0b5e8","z":"bd98324d.e492f","name":"","x":500,"y":340,"wires":[]},{"id":"9a9d0d92.7b0b58","type":"ui_ui_control","z":"bd98324d.e492f","name":"","events":"connect","x":680,"y":200,"wires":[[]]},{"id":"16a3af54.10eea9","type":"ui_button","z":"bd98324d.e492f","name":"","group":"7c41c8ea.d16a48","order":1,"width":0,"height":0,"passthru":false,"label":"Go to Alarmen","tooltip":"","color":"","bgcolor":"","icon":"","payload":"{\"tab\":\"Alarmen\"}","payloadType":"json","topic":"","x":700,"y":140,"wires":[["9a9d0d92.7b0b58"]]},{"id":"b81d521.9035c3","type":"ui_template","z":"3584e894.e0b5e8","group":"7c41c8ea.d16a48","name":"Actieve Alarmen","order":0,"width":0,"height":0,"format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":440,"y":60,"wires":[[]]},{"id":"c87f6adf.4005f","type":"change","z":"3584e894.e0b5e8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":60,"wires":[["b81d521.9035c3"]]}]

Note: since this was a quick prototype, you'll need to take into account that it is just looking at the total number of alarms. This means if alarm 1 sends in a ON twice, when the alarm 1 OFF comes in the indicator on the alarms tab will be gone, but th alert will still be flashing. So you will need to make sure an alarm is only sent in once.

1 Like

Good afternoon gentlemen!
Thanks for your suggestions, time and solutions.

@UnborN, thank you very much! This is exactly what I was looking for! :heart_eyes:
I just don't fully understand this piece of code:

keys.forEach ((el, index) => {
  if (values [index]) {// if alarm true
   arr.push ({
       title: keys [index],
       value: values [index] 
   })
  } // end of if   
})

I understand the logic behind the rest of the code. However, I am not a programmer. I never would have come up with the code. :sweat_smile: Thanks again!

@zenofmud, indeed. This is quite a large number of possible alarms. That is also the reason why I want to display it filtered. In theory I can't possibly have 15 different alarms at the same time. I had already tried what you suggested. The big problem was that I always had "white space" when a certain alarm is not active. This because the text was then only hidden, while the space was occupied.
Your suggestion would be ideal if the number of alarms were limited. However, in order to present everything "beautifully", I looked for an alternative.

There is a great resource on looping through object properties
in this video

Once we have our keys as an array we can loop through all its elements (el) with .forEach

Note that this code assumes that are no empty fields 'undefined' coming from your alarm join node.

1 Like

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