Hi again folks.
I’ve had a bit of a break, but now am back.
I am “stuck” with the request to show a list of “events” (messages) on a screen and have them shown something like this: (see code)
[{"id":"65665c0d.74b864","type":"mqtt in","z":"c3ec93b2.f3154","name":"Return Codes from remote commands","topic":"COMMAND_REPLY/#","qos":"2","broker":"b2b92c0f.4429d8","x":170,"y":150,"wires":[["8d44eb6c.8731c","28f89fc4.70c178"]]},{"id":"8d44eb6c.8731c","type":"function","z":"c3ec93b2.f3154","name":"Command spliter","func":"var result_ = msg.payload;\nif (result_.indexOf('code\":1') !== -1)\n{\n //\n node.status({fill:\"yellow\",shape:\"dot\",text:\"Oops\"});\n msg.payload = \"Oops\";\n // more code here for the second output.\n var msg2 = {payload: \"yellow\"};\n}\n\nif (result_.indexOf('code\":127') !== -1)\n{\n node.status({fill:\"red\",shape:\"dot\",text:\"Fail\"});\n msg.payload = \"Command fail.\";\n // more code here for the second output.\n var msg2 = {payload: \"red\"};\n}\nreturn [msg,msg2];\n","outputs":2,"noerr":0,"x":450,"y":150,"wires":[["fc371fef.41de88"],["77c9af2e.1f992","aedf9c70.5088c8"]]},{"id":"77c9af2e.1f992","type":"ui_text","z":"c3ec93b2.f3154","group":"b6cd7085.bd4458","order":4,"width":"1","height":"1","name":"Command reply status LED","label":"","format":"<font color={{msg.payload}} ><i class=\"fa fa-circle\" style=\"font-size:24px;\"></i></font>","layout":"row-center","x":710,"y":210,"wires":[]},{"id":"42b86d41.5aec0c","type":"ui_text","z":"c3ec93b2.f3154","group":"b6cd7085.bd4458","order":5,"width":"6","height":"1","name":"","label":"","format":"{{msg.payload}}","layout":"row-center","x":780,"y":150,"wires":[]},{"id":"7462dce0.63a6e4","type":"ui_template","z":"c3ec93b2.f3154","group":"b6cd7085.bd4458","name":"stuff","order":2,"width":"0","height":"0","format":"<style>\n .filled { \n height: 100% !important;\n\n padding: 0 !important;\n margin: 0 !important;\n }\n .nr-dashboard-template {\n padding: 0;\n margin: 0;\n }\n \n .rounded {\n border-radius: 12px 12px 12px 12px;\n}\n \n .bigfont {\n font-size: 18px;\n}\n\n .smallfont {\n font-size: 12px;\n}\n \n</style>\n\n<script>\n$('.vibrate').on('click', function() {\n navigator.vibrate(100);\n});\n\nfunction restore_bg(x) {\n $(this).css(\"background-color\", x);\n };\n\n$('.touched').on('mousedown', function() {\n \n var x= $(this).css(\"background-color\");\n $(this).css(\"background-color\", \"yellow\");\n \n setTimeout(restore_bg.bind(this,x),100);\n navigator.vibrate(80);\n });\n \n</script>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":280,"y":110,"wires":[[]]},{"id":"28f89fc4.70c178","type":"debug","z":"c3ec93b2.f3154","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":120,"y":200,"wires":[]},{"id":"aedf9c70.5088c8","type":"debug","z":"c3ec93b2.f3154","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":660,"y":240,"wires":[]},{"id":"fc371fef.41de88","type":"switch","z":"c3ec93b2.f3154","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Command successful.","vt":"str"},{"t":"eq","v":"Oops","vt":"str"},{"t":"eq","v":"Command fail.","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":630,"y":150,"wires":[[],["42b86d41.5aec0c","36d66939.45039e"],["42b86d41.5aec0c","36d66939.45039e"]]},{"id":"9cd2d6aa.ba8328","type":"ui_template","z":"c3ec93b2.f3154","group":"b6cd7085.bd4458","name":"ARA","order":3,"width":"2","height":"1","format":"\n<md-button class=\"vibrate filled touched smallfont rounded\" style=\"background-color:#166085\" ng-click=\"send({payload: 'ARA'})\"> \n ARA<br/>\n</md-button> \n\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":930,"y":150,"wires":[["22e5ebfa.dd5d44","36d66939.45039e"]]},{"id":"935699b6.cf8ae8","type":"ui_template","z":"c3ec93b2.f3154","group":"b6cd7085.bd4458","name":"Text formatting","order":1,"width":0,"height":0,"format":" <style>\n .nr-dashboard-cardtitle {\n text-align:center;\n }\n</style>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"global","x":130,"y":110,"wires":[[]]},{"id":"ff74f86c.5fe678","type":"ui_template","z":"c3ec93b2.f3154","group":"b6cd7085.bd4458","name":"CLEAR","order":6,"width":"2","height":"1","format":"\n<md-button class=\"vibrate filled touched smallfont rounded\" style=\"background-color:#ff0000\" ng-click=\"send({payload: 'CLEAR'})\"> \n CLEAR<br/>\n</md-button> \n\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":1180,"y":150,"wires":[["677cfa8c.e86da4","a979308d.54b0c8"]]},{"id":"4dd41893.5cbb98","type":"comment","z":"c3ec93b2.f3154","name":"Display","info":"","x":550,"y":110,"wires":[]},{"id":"e92b45fa.c911e8","type":"comment","z":"c3ec93b2.f3154","name":"Buttons","info":"","x":1080,"y":70,"wires":[]},{"id":"677cfa8c.e86da4","type":"debug","z":"c3ec93b2.f3154","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1290,"y":110,"wires":[]},{"id":"a979308d.54b0c8","type":"function","z":"c3ec93b2.f3154","name":"Clear alarms","func":"\n// Wipe message\nvar msg1 = {payload: \" no alarms active \"};\n// LED colour\nvar msg2 = {payload: \"black\"};\n\nreturn [msg1,msg2];\n","outputs":2,"noerr":0,"x":1190,"y":210,"wires":[["2f16a4f6.13ee6c"],["9d8021f6.416418"]]},{"id":"6c238aef.c81874","type":"link in","z":"c3ec93b2.f3154","name":"Alarm LED RX","links":["9d8021f6.416418","edc0482b.469028"],"x":515,"y":210,"wires":[["77c9af2e.1f992"]]},{"id":"f3cb9dbc.4db6f","type":"link in","z":"c3ec93b2.f3154","name":"ALARM TEXT RX","links":["2f16a4f6.13ee6c","c13ae9e6.631a28"],"x":665,"y":110,"wires":[["42b86d41.5aec0c","401b2fa9.4bc168"]]},{"id":"9d8021f6.416418","type":"link out","z":"c3ec93b2.f3154","name":"","links":["6c238aef.c81874"],"x":1305,"y":230,"wires":[]},{"id":"2f16a4f6.13ee6c","type":"link out","z":"c3ec93b2.f3154","name":"","links":["f3cb9dbc.4db6f"],"x":1305,"y":190,"wires":[]},{"id":"401b2fa9.4bc168","type":"debug","z":"c3ec93b2.f3154","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":800,"y":110,"wires":[]},{"id":"36d66939.45039e","type":"function","z":"c3ec93b2.f3154","name":"Ack' alarms","func":"\nif (msg.payload != 'ARA')\n{\n context.set('alarm',msg.payload);\n}\n\nif (msg.payload == 'ARA')\n{\n // message\n var alarm = context.get('alarm');\n var msg1 = {payload: alarm};\n // LED colour\n var msg2 = {payload: \"cyan\"};\n}\nreturn [msg1,msg2];\n","outputs":2,"noerr":0,"x":950,"y":210,"wires":[["c13ae9e6.631a28"],["edc0482b.469028"]]},{"id":"c13ae9e6.631a28","type":"link out","z":"c3ec93b2.f3154","name":"","links":["f3cb9dbc.4db6f"],"x":1065,"y":190,"wires":[]},{"id":"edc0482b.469028","type":"link out","z":"c3ec93b2.f3154","name":"","links":["6c238aef.c81874"],"x":1065,"y":230,"wires":[]},{"id":"22e5ebfa.dd5d44","type":"debug","z":"c3ec93b2.f3154","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1030,"y":110,"wires":[]},{"id":"b2b92c0f.4429d8","type":"mqtt-broker","z":"","name":"192.168.0.99:1883","broker":"TimePi","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""},{"id":"b6cd7085.bd4458","type":"ui_group","z":"","name":"Alarm display","tab":"48f5e285.67a4c4","order":1,"disp":true,"width":"14","collapse":false},{"id":"48f5e285.67a4c4","type":"ui_tab","z":"","name":"ALARMS","icon":"dashboard","order":12}]
The idea is that an event happens and it is logged (to call it something) and the user is notified.
The “alarm” can be acknowledge or cleared.
Acknowledge keeps it in the list. Cleared wipes it from the list.
But there is a possibility (truth?) that there will be more than one.
Can NR do this? My thoughts are that it will need file I/O for the events.
But at this stage, I am not good enough to know where to look and/or how to do it.
It isn’t that I want someone to solve it for me, but to help me with where to look and help me get my head around what to do.
Appreciated.