I've got a little gate function that I think you could use
It blocks messages from going through it depending on control gate messages
[{"id":"5ce2b4e6.98e44c","type":"function","z":"ed0f5786.2ba6d8","name":"Gate","func":"var gateMsg;\n\n/**\n * Describe this function...\n */\nfunction setStatus() {\n if (!(context.get('gate'))) {\n node.status({fill:\"red\", shape:\"dot\", text:'closed'});\n } else {\n node.status({fill:\"green\", shape:\"dot\", text:'open'});\n }\n}\n\n\nif ((context.get('gate')) != false) {\n context.set('gate', true);\n}\nif ((msg['topic']) == 'gate') {\n gateMsg = (msg['payload']);\n if (gateMsg == true) {\n context.set('gate', true);\n } else if (gateMsg == false) {\n context.set('gate', false);\n } else if (gateMsg == 'toggle') {\n context.set('gate', (!(context.get('gate'))));\n }\n setStatus();\n} else {\n if (context.get('gate')) {\n return msg;\n } else {\n setStatus();\n }\n}\n","outputs":1,"noerr":0,"x":630,"y":560,"wires":[["ecc9c75e.785df8"]]},{"id":"84b7c0e6.c4e97","type":"inject","z":"ed0f5786.2ba6d8","name":"","topic":"gate","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":400,"y":680,"wires":[["5ce2b4e6.98e44c"]]},{"id":"b9b53393.dfaab","type":"inject","z":"ed0f5786.2ba6d8","name":"","topic":"gate","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":400,"y":720,"wires":[["5ce2b4e6.98e44c"]]},{"id":"565d47c1.94ddd8","type":"inject","z":"ed0f5786.2ba6d8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":400,"y":500,"wires":[["5ce2b4e6.98e44c"]]},{"id":"ecc9c75e.785df8","type":"debug","z":"ed0f5786.2ba6d8","name":"BLOCKLY","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","x":830,"y":560,"wires":[]},{"id":"79bf3dc7.8274a4","type":"inject","z":"ed0f5786.2ba6d8","name":"","topic":"gate","payload":"toggle","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":400,"y":640,"wires":[["5ce2b4e6.98e44c"]]},{"id":"97dd4829.84ea78","type":"inject","z":"ed0f5786.2ba6d8","name":"","topic":"gate","payload":"init","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":400,"y":600,"wires":[["5ce2b4e6.98e44c"]]}]