Cancel inputs for a period of time

You can block / unblock flow in the node-red editor with simple change and switch nodes...

image

[{"id":"cd7521f5.10b9c","type":"inject","z":"4656711a.6b16a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"0.5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":780,"wires":[["f09b3da7.cc7b7"]]},{"id":"f09b3da7.cc7b7","type":"switch","z":"4656711a.6b16a","name":"blockFlow is false?","property":"blockFlow","propertyType":"flow","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":430,"y":780,"wires":[["c7e7a1c1.45b11"]]},{"id":"c7e7a1c1.45b11","type":"debug","z":"4656711a.6b16a","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":450,"y":840,"wires":[]},{"id":"786630c0.b0ed4","type":"inject","z":"4656711a.6b16a","name":"block","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":230,"y":700,"wires":[["484bfc3f.a71ed4"]]},{"id":"f5819368.a7c6f","type":"inject","z":"4656711a.6b16a","name":"unblock","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":230,"y":660,"wires":[["484bfc3f.a71ed4"]]},{"id":"484bfc3f.a71ed4","type":"change","z":"4656711a.6b16a","name":"","rules":[{"t":"set","p":"blockFlow","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":680,"wires":[[]]}]


Or for a more self contained version (with indicator), use a function node...

image

image

[{"id":"cd7521f5.10b9c","type":"inject","z":"4656711a.6b16a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"0.5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":780,"wires":[["c1e35392.abf13"]]},{"id":"c7e7a1c1.45b11","type":"debug","z":"4656711a.6b16a","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":450,"y":840,"wires":[]},{"id":"786630c0.b0ed4","type":"inject","z":"4656711a.6b16a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"_block","payload":"true","payloadType":"bool","x":240,"y":700,"wires":[["c1e35392.abf13"]]},{"id":"f5819368.a7c6f","type":"inject","z":"4656711a.6b16a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"_block","payload":"false","payloadType":"bool","x":250,"y":660,"wires":[["c1e35392.abf13"]]},{"id":"c1e35392.abf13","type":"function","z":"4656711a.6b16a","name":"gate","func":"var block = context.get(\"block\") || false;\nif (msg.topic == \"_block\") {\n    block = msg.payload;\n    context.set(\"block\", block);\n    var stat = {\n        fill: block ? \"red\" : \"green\",\n        shape: block ? \"dot\": \"ring\",\n        text: block ? \"Blocked\" : \"Unblocked\"\n    }\n    node.status(stat)\n}\n\nif(block) return null; //halt flow\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":410,"y":780,"wires":[["c7e7a1c1.45b11"]]}]
3 Likes