Here is my latest version. I put a rbe node in, right after the array is read from the device. This allows a new alarm to be passed through, or if all zeroes then the switch node catches it.
Thanks for pointing out the link. That brings me to another question, I will have about a dozen of these flows from about 12 different devices. Will this be an issue with variables? thanks,
[{"id":"d6e25a11.0fc41","type":"inject","z":"29096dc9.e0971a","name":"","topic":"","payload":"","payloadType":"num","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"x":224,"y":186,"wires":[["42b90340.1c09dc"]]},{"id":"fb1897e6.a9a87","type":"debug","z":"29096dc9.e0971a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":784,"y":354,"wires":[]},{"id":"42b90340.1c09dc","type":"pac-read","z":"29096dc9.e0971a","device":"bc5622e6.56b0c8","dataType":"int32-table","tagName":"PP19Alarm_Array","tableStartIndex":"0","tableLength":"100","value":"","valueType":"msg.payload","topic":"","topicType":"none","name":"","x":274,"y":243,"wires":[["67d7fd7.8b63c84"]]},{"id":"bea1c2d0.f62f5","type":"function","z":"29096dc9.e0971a","name":"evaluate array","func":"//evaluate alarm array: does an email need to be sent?\nfunction isOne(One) {\n return One === 1;\n}\n\nvar Alm = msg.payload; //the I 32 alarm table copied from the Opto controller\nvar Alarm_active; //boolean to hold status of alarm state: if email should be sent\n\nAlarm_active = Alm.some(isOne);\nmsg.active = Alarm_active;\nmsg.payload = Alm;\n\nreturn msg;\n","outputs":1,"noerr":0,"x":257,"y":301,"wires":[["cca2eddb.07cbb8"]]},{"id":"67d7fd7.8b63c84","type":"rbe","z":"29096dc9.e0971a","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":470,"y":243,"wires":[["bea1c2d0.f62f5"]]},{"id":"cca2eddb.07cbb8","type":"switch","z":"29096dc9.e0971a","name":"","property":"active","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":428,"y":301,"wires":[["7cfa37b0.ef27c"],["7cf11937.bb8378"]]},{"id":"7cfa37b0.ef27c","type":"function","z":"29096dc9.e0971a","name":"build email","func":"//Build the email message:\nvar Alm = msg.payload; //the I 32 alarm table copied from the Opto controller\nvar Indextxt = []; //array holding the text for the alarm messages\nvar Indextxt_final = []; //array holding the alarms that are active\nvar Indextxt_finalload = []; //array holding the alarms with the null removed\n\nIndextxt[0] = \"FT5501 low low alarm active\"\nIndextxt[1] = \"T1001 low alarm active\"\nIndextxt[2] = \"T1002 low alarm active\"\nIndextxt[3] = \"T1003 low alarm active\"\nIndextxt[4] = \"T1004 low alarm active and whatever\"\nIndextxt[5] = \"T1005 low alarm active\"\nIndextxt[6] = \"T1015 low alarm active and more text\"\nIndextxt[7] = \"FT5501 low low alarm active\"\nIndextxt[8] = \"T1001 low alarm active\"\nIndextxt[9] = \"T1002 low alarm active\"\nIndextxt[26] = \"T1003 low alarm active\"\nIndextxt[32] = \"T1004 low alarm active and whatever\"\n/*\nIndextxt[5] = \"T1005 low alarm active\"\nIndextxt[10] = \"T1015 low alarm active and more text\"\nIndextxt[0] = \"FT5501 low low alarm active\"\nIndextxt[1] = \"T1001 low alarm active\"\nIndextxt[2] = \"T1002 low alarm active\"\nIndextxt[3] = \"T1003 low alarm active\"\nIndextxt[4] = \"T1004 low alarm active and whatever\"\nIndextxt[5] = \"T1005 low alarm active\"\nIndextxt[10] = \"T1015 low alarm active and more text\"\nIndextxt[0] = \"FT5501 low low alarm active\"\nIndextxt[1] = \"T1001 low alarm active\"\nIndextxt[2] = \"T1002 low alarm active\"\nIndextxt[3] = \"T1003 low alarm active\"\nIndextxt[4] = \"T1004 low alarm active and whatever\"\nIndextxt[5] = \"T1005 low alarm active\"\nIndextxt[10] = \"T1015 low alarm active and more text\"\n//and so on... up to element 100 or whatever is needed\n\n*/\n\n//map the array to match the read in I 32 table alarm condition to the proper text field\n var format_Alm = Alm.map((element, index_number) =>{\n //Check the Value of each index and assign a text alarm if equals one\n if (element === 1) \n {\n Indextxt_final[index_number] = Indextxt[index_number];\n }\n});\n\n//get rid of the null elements \nIndextxt_finalload = Indextxt_final.filter(function(i){return i !== null; });\n\n//msg.payload - the content inside the email\nmsg.payload = \"PP19 Process Alarm ||\" + Indextxt_finalload.join(\" // \");\n//msg.topic - subject line of the email\nmsg.topic = 'PP19 Process Alarm'\n\n//this can be set in the email node\nmsg.to = []\n//msg.includes = Alarm_active;\nmsg.active = msg.payload;\n//msg.active = Alarm_active;\n\nreturn msg;","outputs":1,"noerr":0,"x":609,"y":301,"wires":[["c8bf5976.a241c","fb1897e6.a9a87"]]},{"id":"c8bf5976.a241c","type":"e-mail","z":"29096dc9.e0971a","server":"smtp.gmail.com","port":"465","secure":true,"name":"","dname":"","x":784,"y":302,"wires":[]},{"id":"7cf11937.bb8378","type":"debug","z":"29096dc9.e0971a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":589,"y":372,"wires":[]},{"id":"197d37f1.426ba8","type":"comment","z":"29096dc9.e0971a","name":"PP19 Alarms","info":"","x":232,"y":107,"wires":[]},{"id":"8463362b.0e9918","type":"function","z":"29096dc9.e0971a","name":"simulate I 32 from Opto SNAP S2","func":"\n//mimmic the Opto 22 msg.payload\n//set all events to trigger = of zero\nmsg.payload = \n[\n 0,\n 0,\n 0,\n 1,\n 1,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0\n];\n\nreturn msg;\n","outputs":1,"noerr":0,"x":672,"y":141,"wires":[[]]},{"id":"73b9eddb.b3a2ac","type":"comment","z":"29096dc9.e0971a","name":"use simulate as an alternate","info":"","x":647,"y":99,"wires":[]},{"id":"bc5622e6.56b0c8","type":"pac-device","z":"","address":"10.0.19.10","protocol":"http"}]