This node is similar to one I got help with earlier.
That node is still needed and used.
But working on my flows, it became obvious I needed another node of similar functions, but not exactly the same.
I’m not sure if I am re-inventing the wheel, but here is my effort:
Idea:
A node with 1 input and 1 output.
One set of signals is TOPIC set to ENABLE.
It can be ENABLE or DISABLE.
(I guess I can change that to boolean, but…)
The other input/message is only passed if ENABLE is active.
[{“id”:“a3d66060.812868”,“type”:“function”,“z”:“2d44537.f26082c”,“name”:“EN”,“func”:“context.message;\ncontext.mtopic = msg.topic;\nvar enable_topic = context.get(‘enable_topic’);\nvar mpayload = msg.payload;\nvar enable_topic = ‘ENABLE’;\n\nif (enable_topic === 1)\n{\n node.status({fill:“green”,shape:“dot”,text:“On-line”});\n return msg;\n}\n\nif (context.mtopic == enable_topic)\n{\n //\n if (msg.payload === ‘ENABLE’)\n {\n node.status({fill:“yellow”,shape:“dot”,text:“ENABLED”});\n context.enable = 1;\n context.set(‘enable’,enable_topic);\n }\n if (msg.payload === ‘DISABLE’)\n {\n context.enable = 0;\n context.set(‘enable’,enable_topic);\n node.status({fill:“red”,shape:“dot”,text:“DISABLED”});\n }\n}\n”,“outputs”:1,“noerr”:0,“x”:720,“y”:1870,“wires”:[[“a1219f49.a1eac8”]]}]
I seem to be missing something about how the message is passed through.
I (maybe) should learn how to have multiple inputs to a node.
But for now I am using a function node and it has only 1 input.