Help for history alarm

hello community,
I created an alarm but I want to show all the alarm history,but in my case the new alarm crushes the last
here is my flow, if anyone can help me i will be grateful

[{"id":"e5857942.727778","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"dc128f46.dd51a","type":"function","z":"e5857942.727778","name":"","func":"let alarmssss = flow.get(\"Alarmssss\") || {}\n\n\nif (msg.payload == \"1\") {\n\nlet obj = { \n    Site : msg.Site,\n    Equipement : msg.Equipement,\n    Statut : msg.Statut,\n    Alarm : msg.Alarm,\n    dt: msg.dt\n}\n\nalarmssss[msg.topic] = obj\n\nflow.set(\"Alarmssss\", alarmssss)\n\n}\n\nmsg.payload = Object.values(alarmssss)\n\nreturn msg\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1200,"y":340,"wires":[["99b5b624.2d64c8"]]},{"id":"81c38971.270388","type":"rbe","z":"e5857942.727778","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","x":710,"y":200,"wires":[["48d0cab3.6121f4"]]},{"id":"a09477fa.ea2988","type":"rbe","z":"e5857942.727778","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","x":710,"y":240,"wires":[["62af4d61.ddce34"]]},{"id":"226f5e07.4ef0b2","type":"rbe","z":"e5857942.727778","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","x":710,"y":280,"wires":[["c6d2326f.248c2"]]},{"id":"99008e38.5ecce","type":"rbe","z":"e5857942.727778","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","x":710,"y":320,"wires":[["e4e8ba81.464648"]]},{"id":"d0ca62d7.7b148","type":"inject","z":"e5857942.727778","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":270,"y":160,"wires":[["81c38971.270388"]]},{"id":"a5ad41d9.29669","type":"inject","z":"e5857942.727778","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":270,"y":200,"wires":[["81c38971.270388","a09477fa.ea2988","226f5e07.4ef0b2","99008e38.5ecce"]]},{"id":"4107b269.80503c","type":"inject","z":"e5857942.727778","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":270,"y":240,"wires":[["a09477fa.ea2988"]]},{"id":"9308a8ef.b14988","type":"inject","z":"e5857942.727778","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":270,"y":280,"wires":[["a09477fa.ea2988"]]},{"id":"62af4d61.ddce34","type":"change","z":"e5857942.727778","name":"Set Topic","rules":[{"t":"set","p":"Site","pt":"msg","to":"Site 1","tot":"str"},{"t":"set","p":"Equipement","pt":"msg","to":"eq 1","tot":"str"},{"t":"set","p":"Statut","pt":"msg","to":"<div style='width:100%; color:orange'> NH </div>","tot":"str"},{"t":"set","p":"Alarm","pt":"msg","to":"Niveau haut","tot":"str"},{"t":"set","p":"dt","pt":"msg","to":"$moment().format(\"YYYY-MM-DD HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":240,"wires":[["dc128f46.dd51a"]]},{"id":"c6d2326f.248c2","type":"change","z":"e5857942.727778","name":"Set Topic","rules":[{"t":"set","p":"Site","pt":"msg","to":"Site 1","tot":"str"},{"t":"set","p":"Equipement","pt":"msg","to":"eq 1","tot":"str"},{"t":"set","p":"Statut","pt":"msg","to":"<div style='width:100%; color:red'> NTH </div>","tot":"str"},{"t":"set","p":"Alarm","pt":"msg","to":"Niveau très haut","tot":"str"},{"t":"set","p":"dt","pt":"msg","to":"$moment().format(\"YYYY-MM-DD HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":280,"wires":[["dc128f46.dd51a"]]},{"id":"e4e8ba81.464648","type":"change","z":"e5857942.727778","name":"Set Topic","rules":[{"t":"set","p":"Site","pt":"msg","to":"Site 1","tot":"str"},{"t":"set","p":"Equipement","pt":"msg","to":"eq 1","tot":"str"},{"t":"set","p":"Statut","pt":"msg","to":"<div style='width:100%; color:red'> Défaut </div>","tot":"str"},{"t":"set","p":"Alarm","pt":"msg","to":"Défaut","tot":"str"},{"t":"set","p":"dt","pt":"msg","to":"$moment().format(\"YYYY-MM-DD HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":320,"wires":[["dc128f46.dd51a","64fc3415.438b3c"]]},{"id":"4c3004dc.c90a1c","type":"inject","z":"e5857942.727778","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":270,"y":320,"wires":[["226f5e07.4ef0b2"]]},{"id":"f7da68be.0d2ac8","type":"inject","z":"e5857942.727778","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":270,"y":360,"wires":[["226f5e07.4ef0b2"]]},{"id":"7f4b8989.c424b8","type":"inject","z":"e5857942.727778","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":270,"y":400,"wires":[["99008e38.5ecce","66548491.6a8e6c"]]},{"id":"f71df6ff.218938","type":"inject","z":"e5857942.727778","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":270,"y":460,"wires":[["99008e38.5ecce"]]},{"id":"99b5b624.2d64c8","type":"ui_table","z":"e5857942.727778","group":"d8c473c2.474058","name":"Alarme","order":1,"width":18,"height":7,"columns":[{"field":"Site","title":"<center>Site</>","width":"20%","align":"center","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"Equipement","title":"<center>Equipement</>","width":"20%","align":"center","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"Statut","title":"<center>Statut</>","width":"20%","align":"center","formatter":"html","formatterParams":{"target":"_blank"}},{"field":"Alarm","title":"<center>Alarm</>","width":"20%","align":"center","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"dt","title":"<center>Date</>","width":"20%","align":"center","formatter":"plaintext","formatterParams":{"target":"_blank"}}],"outputs":0,"cts":false,"x":1380,"y":340,"wires":[]},{"id":"64fc3415.438b3c","type":"debug","z":"e5857942.727778","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1270,"y":200,"wires":[]},{"id":"d03d565b.191848","type":"rbe","z":"e5857942.727778","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","x":710,"y":380,"wires":[["3364bd10.17a562"]]},{"id":"3364bd10.17a562","type":"change","z":"e5857942.727778","name":"Set Topic","rules":[{"t":"set","p":"Site","pt":"msg","to":"Site 1","tot":"str"},{"t":"set","p":"Equipement","pt":"msg","to":"eq 2","tot":"str"},{"t":"set","p":"Statut","pt":"msg","to":"<div style='width:100%; color:orange'> NB </div>","tot":"str"},{"t":"set","p":"Alarm","pt":"msg","to":"Niveau bas","tot":"str"},{"t":"set","p":"dt","pt":"msg","to":"$moment().format(\"YYYY-MM-DD HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":380,"wires":[["dc128f46.dd51a"]]},{"id":"1d585ffc.e631b","type":"rbe","z":"e5857942.727778","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","x":710,"y":420,"wires":[["6cf6da3c.d23b24"]]},{"id":"66548491.6a8e6c","type":"rbe","z":"e5857942.727778","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","x":710,"y":460,"wires":[["9fcff5cf.6a0a28"]]},{"id":"14bdfee0.4d7251","type":"rbe","z":"e5857942.727778","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","x":710,"y":500,"wires":[["8e4bcefb.56e59"]]},{"id":"6cf6da3c.d23b24","type":"change","z":"e5857942.727778","name":"Set Topic","rules":[{"t":"set","p":"Site","pt":"msg","to":"Site 1","tot":"str"},{"t":"set","p":"Equipement","pt":"msg","to":"eq2","tot":"str"},{"t":"set","p":"Statut","pt":"msg","to":"<div style='width:100%; color:orange'> NH </div>","tot":"str"},{"t":"set","p":"Alarm","pt":"msg","to":"Niveau haut","tot":"str"},{"t":"set","p":"dt","pt":"msg","to":"$moment().format(\"YYYY-MM-DD HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":420,"wires":[["dc128f46.dd51a"]]},{"id":"9fcff5cf.6a0a28","type":"change","z":"e5857942.727778","name":"Set Topic","rules":[{"t":"set","p":"Site","pt":"msg","to":"Site 1","tot":"str"},{"t":"set","p":"Equipement","pt":"msg","to":"eq2","tot":"str"},{"t":"set","p":"Statut","pt":"msg","to":"<div style='width:100%; color:red'> NTH </div>","tot":"str"},{"t":"set","p":"Alarm","pt":"msg","to":"Niveau très haut","tot":"str"},{"t":"set","p":"dt","pt":"msg","to":"$moment().format(\"YYYY-MM-DD HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":460,"wires":[["dc128f46.dd51a"]]},{"id":"8e4bcefb.56e59","type":"change","z":"e5857942.727778","name":"Set Topic","rules":[{"t":"set","p":"Site","pt":"msg","to":"Site 1","tot":"str"},{"t":"set","p":"Equipement","pt":"msg","to":"eq 2","tot":"str"},{"t":"set","p":"Statut","pt":"msg","to":"<div style='width:100%; color:red'> Défaut </div>","tot":"str"},{"t":"set","p":"Alarm","pt":"msg","to":"Défaut","tot":"str"},{"t":"set","p":"dt","pt":"msg","to":"$moment().format(\"YYYY-MM-DD HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":500,"wires":[["dc128f46.dd51a"]]},{"id":"48d0cab3.6121f4","type":"change","z":"e5857942.727778","name":"Set Topic","rules":[{"t":"set","p":"Site","pt":"msg","to":"Site 1","tot":"str"},{"t":"set","p":"Equipement","pt":"msg","to":"eq 1","tot":"str"},{"t":"set","p":"Statut","pt":"msg","to":"<div style='width:100%; color:orange'> NB </div>","tot":"str"},{"t":"set","p":"Alarm","pt":"msg","to":"Niveau bas","tot":"str"},{"t":"set","p":"dt","pt":"msg","to":"$moment().format(\"YYYY-MM-DD HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":200,"wires":[["dc128f46.dd51a"]]},{"id":"d8c473c2.474058","type":"ui_group","name":"List","tab":"d463fbe2.68b3c8","order":2,"disp":true,"width":18,"collapse":false},{"id":"d463fbe2.68b3c8","type":"ui_tab","name":"Alarmes","icon":"report_problem","order":4,"disabled":false,"hidden":false}]

You reference msg.topic in your function, but it has no value, as you have not set it in the change nodes. So all alarms are written to the same key which is blank as msg.topic = ""

1 Like

ooh yeah it works now
I didn't pay attention to that, thank you very match

No problem glad to help.

What is the incoming meessage from your alarms, as may be able to reduce the repetative nodes. Add a debug to the incoming node and set it to complete message object, then post output here if you want to try and reduce the repeated nodes.

1 Like

okay i got it, I will try it :ok_hand:

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