-
Notifications
You must be signed in to change notification settings - Fork 22
Trigger a Complete node via a Done block
bartbutenaers edited this page Jul 21, 2021
·
1 revision
The Node-RED category contains a "Done" block, to let the Node-RED runtime know when the Blockly node has completed processing an input message.
In this example workspace, the input message is considered 'done' when the payload contains "activate_done":
This workspace is being used in the following example flow, to trigger the Complete-node when the Done-block is triggered:
[{"id":"bb6162cc.e1704","type":"Blockly","z":"c2a7925b.6e143","language":"en","func":"node.send([msg]);\nif ((msg['payload']) == 'activate_done') {\n node.done();\n}\n","workspaceXml":"<xml xmlns=\"https://developers.google.com/blockly/xml\">\n <block type=\"node_send\" id=\"Yoqo0*^[cs89^n:s:mB:\" x=\"-587\" y=\"-537\">\n <field name=\"OUTPUT_NR\">1</field>\n <value name=\"MESSAGE_INPUT\">\n <shadow type=\"node_msg\" id=\"54X^[E^pMXOTtqY3prub\"></shadow>\n <block type=\"node_msg\" id=\"2pz7$WcP#?EYH`4,t}rO\"></block>\n </value>\n <next>\n <block type=\"controls_if\" id=\"f4)[rrPR|B;uWPhziE]T\">\n <value name=\"IF0\">\n <block type=\"logic_compare\" id=\"UM.)|z.!+]O^@#z+qaD]\">\n <field name=\"OP\">EQ</field>\n <value name=\"A\">\n <block type=\"node_object_get\" id=\"FCAkJxW%BN$,0],!tE=*\">\n <mutation xmlns=\"http://www.w3.org/1999/xhtml\" action=\"GET\"></mutation>\n <field name=\"action\">GET</field>\n <value name=\"object\">\n <shadow type=\"node_msg\" id=\"L.1CSMob$,3W[o0)]1B8\"></shadow>\n <block type=\"node_msg\" id=\"g@IOruwt,yUL,zy[|jA3\"></block>\n </value>\n <value name=\"field_name\">\n <shadow type=\"text\" id=\"eHgGVFgeUM:q^-r!FFP`\">\n <field name=\"TEXT\">payload</field>\n </shadow>\n </value>\n </block>\n </value>\n <value name=\"B\">\n <block type=\"text\" id=\"%a|;]8Jx=84[U#9ooWD!\">\n <field name=\"TEXT\">activate_done</field>\n </block>\n </value>\n </block>\n </value>\n <statement name=\"DO0\">\n <block type=\"node_done\" id=\"BE:%8^@,:?;!$W1~^w_o\"></block>\n </statement>\n </block>\n </next>\n </block>\n</xml>","outputs":1,"name":"","x":380,"y":100,"wires":[["38459650.ac32da"]]},{"id":"88a2a218.f1f35","type":"inject","z":"c2a7925b.6e143","name":"Don't activate \"done\"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"dont_activate_done","payloadType":"str","x":170,"y":100,"wires":[["bb6162cc.e1704"]]},{"id":"38459650.ac32da","type":"debug","z":"c2a7925b.6e143","name":"Blockly output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":600,"y":100,"wires":[]},{"id":"e48085d7.32f838","type":"complete","z":"c2a7925b.6e143","name":"","scope":["bb6162cc.e1704"],"uncaught":false,"x":390,"y":220,"wires":[["c8ab2289.02c92"]]},{"id":"c8ab2289.02c92","type":"debug","z":"c2a7925b.6e143","name":"Msg completed","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":600,"y":220,"wires":[]},{"id":"bf4e9e59.f7a49","type":"inject","z":"c2a7925b.6e143","name":"Activate \"done\"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"activate_done","payloadType":"str","x":160,"y":140,"wires":[["bb6162cc.e1704"]]}]