In fact, my application is located on a PLC. The link beetween my PLC and node-Red is made via OPC-UA. OPC-UA and Node-red are on the same device.
Node-Red scans the OPC-UA variables each 10 seconds.
In my PLC, I request to send a mail by a bit : xSend.
when this bit is set by the PLC, it is maintained until I get a good or bad reply from the mail node (xFail or xSent).
So, as i scan the variables only each 10 seconds, I can not send an other mail while one is already 'on the run'.
My flow is here
[{"id":"2d053491.5339ec","type":"tab","label":"Send Mail with status","disabled":false,"info":""},{"id":"82f5b33.72aac5","type":"OPCUA-IIoT-Inject","z":"2d053491.5339ec","injectType":"read","payload":"","payloadType":"date","topic":"","repeat":"5","crontab":"","once":true,"startDelay":"","name":"Scan xSend ...","addressSpaceItems":[{"name":"xSend","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xSend","datatypeName":""},{"name":"","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.strText","datatypeName":""},{"name":"","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xSent","datatypeName":""},{"name":"","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.strMailTo","datatypeName":""},{"name":"","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.strMailCC","datatypeName":""},{"name":"","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.strMailBCC","datatypeName":""},{"name":"","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xFail","datatypeName":""},{"name":"","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xSending","datatypeName":""}],"x":246.00001907348633,"y":248.00000286102295,"wires":[["c612c1a.190544"]]},{"id":"d540f50c.5e4cd8","type":"comment","z":"2d053491.5339ec","name":"Cyclically read OPC UA varibales to send a mail","info":"","x":282.0000190734863,"y":70.00000381469727,"wires":[]},{"id":"b0cc5adb.966868","type":"change","z":"2d053491.5339ec","name":"copy mail adresses, and strText in Mail","rules":[{"t":"set","p":"to","pt":"msg","to":"payload[3].value","tot":"msg"},{"t":"set","p":"cc","pt":"msg","to":"payload[4].value","tot":"msg"},{"t":"set","p":"bcc","pt":"msg","to":"payload[5].value","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"payload[1].value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1856.0003356933594,"y":247.00004768371582,"wires":[["b03fc5ab.b67158"]]},{"id":"b03fc5ab.b67158","type":"e-mail","z":"2d053491.5339ec","server":"smtp.gmail.com","port":"465","secure":true,"name":"","dname":"Sending mail","x":2153.00048828125,"y":248.00006294250488,"wires":[]},{"id":"c612c1a.190544","type":"OPCUA-IIoT-Read","z":"2d053491.5339ec","attributeId":"13","maxAge":1,"depth":1,"connector":"5b764178.d2fd1","name":"... In the local server","justValue":true,"showStatusActivities":true,"showErrors":true,"parseStrings":false,"historyDays":"","x":442.0000190734863,"y":247.00000286102295,"wires":[["a7931e37.f3c03"]]},{"id":"a7931e37.f3c03","type":"OPCUA-IIoT-Response","z":"2d053491.5339ec","name":"Wait for answer","compressStructure":true,"showStatusActivities":true,"showErrors":true,"activateUnsetFilter":false,"activateFilters":false,"negateFilter":false,"filters":[],"x":672.0000152587891,"y":246.00000190734863,"wires":[["30312138.565c6e","8f8ad7eb.2b70b8"]]},{"id":"30312138.565c6e","type":"switch","z":"2d053491.5339ec","name":"Test xSend = true","property":"payload[0].value","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":881.0000190734863,"y":248.00000190734863,"wires":[["96989050.e8adc"]]},{"id":"ff0a88d1.52ed88","type":"OPCUA-IIoT-Write","z":"2d053491.5339ec","connector":"5b764178.d2fd1","name":"... to local server","justValue":true,"showStatusActivities":true,"showErrors":true,"x":1954.01997756958,"y":433.00394344329834,"wires":[["9cc3f4a8.53b1c8"]]},{"id":"9cc3f4a8.53b1c8","type":"OPCUA-IIoT-Response","z":"2d053491.5339ec","name":"Wait for answer","compressStructure":false,"showStatusActivities":false,"showErrors":false,"activateUnsetFilter":false,"activateFilters":false,"negateFilter":false,"filters":[],"x":2193.0200691223145,"y":433.00399684906006,"wires":[["22649884.3945c8"]]},{"id":"22649884.3945c8","type":"debug","z":"2d053491.5339ec","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":2380.0200958251953,"y":433.00395011901855,"wires":[]},{"id":"96989050.e8adc","type":"switch","z":"2d053491.5339ec","name":"Test xSent = false","property":"payload[2].value","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":1095.0197639465332,"y":249.00395393371582,"wires":[["6ba9753d.d3b13c"]]},{"id":"ec03d4b2.130898","type":"OPCUA-IIoT-Node","z":"2d053491.5339ec","injectType":"write","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xSent","datatype":"Boolean","value":"","name":"Send xSent = false ...","topic":"ns=5;s=Arp.Plc.Eclr/MainInstance.xSent","showErrors":false,"x":1726.5197410583496,"y":431.00401973724365,"wires":[["ff0a88d1.52ed88"]]},{"id":"8f8ad7eb.2b70b8","type":"switch","z":"2d053491.5339ec","name":"Test xSend = false","property":"payload[0].value","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":870.5196533203125,"y":383.0039186477661,"wires":[["b0bc252c.139928"]]},{"id":"10665e38.a17e82","type":"status","z":"2d053491.5339ec","name":"'Sending mail' status","scope":["b03fc5ab.b67158"],"x":1026.999984741211,"y":800.000020980835,"wires":[["203506a5.d556aa"]]},{"id":"203506a5.d556aa","type":"switch","z":"2d053491.5339ec","name":"Extract msg.status.text","property":"status.text","propertyType":"msg","rules":[{"t":"eq","v":"","vt":"str"},{"t":"cont","v":"fail","vt":"str"},{"t":"cont","v":"sending","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":1360,"y":800,"wires":[["9d878a9e.a3ccd8","8c00f21c.f197"],["90743ff6.b1ef5","8c00f21c.f197"],["c21f9492.370598"]],"outputLabels":["OK","NOK","SENDING"]},{"id":"9d878a9e.a3ccd8","type":"OPCUA-IIoT-Node","z":"2d053491.5339ec","injectType":"write","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xSent","datatype":"Boolean","value":"true","name":"Send xSent = true ...","topic":"","showErrors":false,"x":1681.0000076293945,"y":751.0000219345093,"wires":[["ff0a88d1.52ed88"]]},{"id":"90743ff6.b1ef5","type":"OPCUA-IIoT-Node","z":"2d053491.5339ec","injectType":"write","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xFail","datatype":"Boolean","value":"true","name":"Send xFail = true ...","topic":"","showErrors":false,"x":1671.0000076293945,"y":801.0000233650208,"wires":[["ff0a88d1.52ed88"]]},{"id":"47992443.379abc","type":"OPCUA-IIoT-Node","z":"2d053491.5339ec","injectType":"write","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xFail","datatype":"Boolean","value":"","name":"Send xFail - false ...","topic":"ns=5;s=Arp.Plc.Eclr/MainInstance.xFail","showErrors":false,"x":1720,"y":480,"wires":[["ff0a88d1.52ed88"]]},{"id":"ac54e4a5.3f7758","type":"switch","z":"2d053491.5339ec","name":"Test xFail = false","property":"payload[6].value","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":1529.3333282470703,"y":250.00005054473877,"wires":[["b0cc5adb.966868"]]},{"id":"c21f9492.370598","type":"OPCUA-IIoT-Node","z":"2d053491.5339ec","injectType":"write","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xSending","datatype":"Boolean","value":"true","name":"Send xSending = true ...","topic":"","showErrors":false,"x":1687.3333435058594,"y":850.0001068115234,"wires":[["ff0a88d1.52ed88"]]},{"id":"8c00f21c.f197","type":"OPCUA-IIoT-Node","z":"2d053491.5339ec","injectType":"write","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xSending","datatype":"Boolean","value":"false","name":"Send xSending = false ...","topic":"","showErrors":false,"x":1683.000015258789,"y":619.0000190734863,"wires":[["ff0a88d1.52ed88"]]},{"id":"6ba9753d.d3b13c","type":"switch","z":"2d053491.5339ec","name":"Test xSending= false","property":"payload[7].value","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":1312.666660308838,"y":249.00004768371582,"wires":[["ac54e4a5.3f7758"]]},{"id":"b0bc252c.139928","type":"change","z":"2d053491.5339ec","name":"set x... = false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1265.6666564941406,"y":424.00001525878906,"wires":[["ec03d4b2.130898","47992443.379abc"]]},{"id":"d901af3a.3519","type":"comment","z":"2d053491.5339ec","name":"Scan for the 'Sending mail' node status","info":"","x":966.8333740234375,"y":745.3333549499512,"wires":[]},{"id":"4ca7fce6.074294","type":"comment","z":"2d053491.5339ec","name":"Sending mail successfull","info":"","x":1995.6666564941406,"y":749.0000305175781,"wires":[]},{"id":"90e00fd3.23699","type":"comment","z":"2d053491.5339ec","name":"Sending mail unsuccessfull","info":"","x":1995.6666870117188,"y":797.0000247955322,"wires":[]},{"id":"71e45fa6.43733","type":"comment","z":"2d053491.5339ec","name":"Sending mail running","info":"","x":1984.6666259765625,"y":849,"wires":[]},{"id":"e3a90782.61ebe8","type":"comment","z":"2d053491.5339ec","name":"The mail will be sent if xSend = true and xSent = false and xSending = false and xFail = false","info":"","x":1376.6666259765625,"y":164,"wires":[]},{"id":"5b764178.d2fd1","type":"OPCUA-IIoT-Connector","z":"","discoveryUrl":"","endpoint":"opc.tcp://127.0.0.1:4840","keepSessionAlive":true,"loginEnabled":false,"securityPolicy":"Basic128Rsa15","securityMode":"SIGNANDENCRYPT","name":"LOCAL SERVER","showErrors":true,"individualCerts":false,"publicCertificateFile":"","privateKeyFile":"","defaultSecureTokenLifetime":"","endpointMustExist":false,"autoSelectRightEndpoint":false,"strategyMaxRetry":"","strategyInitialDelay":"","strategyMaxDelay":"","strategyRandomisationFactor":"","requestedSessionTimeout":"","connectionStartDelay":"","reconnectDelay":"","maxBadSessionRequests":"10"}]