Simple Gate Function Node

The function node will pass all msgs by default but if it receives a msg with topic gate with payload false, then it will block any other msgs received until it receives another msg with topic gate with a payload of true

It doesn't pass the gate topic messages at all

[{"id":"50e9060d.36c2b8","type":"function","z":"ed0f5786.2ba6d8","name":"Gate","func":"if (context.get('gate') !== false ) {\n    context.set('gate', true);\n}\n\nif (msg.topic == \"gate\") {\n    context.set('gate',msg.payload);\n    return;\n}\n\nif (context.get('gate') === true ) {\n    return msg;\n}\nreturn;","outputs":1,"noerr":0,"x":430,"y":180,"wires":[["e0ef21b1.28f81"]]}]

Flow Info

Created 7 years, 5 months ago
Rating: 5 1

Owner

Actions

Rate:

Node Types

Core
  • function (x1)

Tags

  • gate
  • switch
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option