If you are only clawing your way through node-red and are open to trying different ways to get something done, this maybe handy for you.
Here you can see how I have one incoming message and you are not sure which code (connected where the debug
nodes are) will work best for you.
(Given you have all 4 versions of the code in the flow. And 4
is nominal only to show it is flexible with how many can be done/used.)
The 4
inject` nodes at the top select where the message goes.
Only 1 output is active at any time.
So you can have the different ways of doing what you are testing and switch which bit of the code is used.
Real handy if you are trying more than 1 way of getting something done.
I would suggest you use link
nodes on the input and multiple outputs to go to the various parts of the code. As having all the alternatives there may become a bit cluttered and confusing.
Maybe even on separate tabs during the initial testing.
EXTERNAL NODE NEEDED!
node-red-contrib-simple-gate
Of course when all is done, you will delete the other nodes and this part of it too.
But it is handy and makes it easier to switch between different ways without needing to deploy.
I know that you are editing things and so it is a given that you will deploy
.
But I have been caught a few times when I haven't re-wired to the bit of code on which I am working and so have to re-deploy again.
It isn't rocket science and could be made into a subflow easily enough.
(Which could be done but it is a bit more mucking about because of the inject
nodes)
Here it is simple and you can easily control where messages are going during testing.
Hope it helps someone.
[{"id":"0920c79d3c937bfd","type":"inject","z":"e089622.6a906a","name":"ON","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"open","payloadType":"str","x":320,"y":1120,"wires":[["eddec65d7bd49d3d","b83361418671bdea"]]},{"id":"eddec65d7bd49d3d","type":"change","z":"e089622.6a906a","name":"OFF","rules":[{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":1120,"wires":[["aac3da4f81ed1491","1c815229de707473","e5045037e386432a"]]},{"id":"3655c402f0cac406","type":"inject","z":"e089622.6a906a","name":"ON","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"open","payloadType":"str","x":320,"y":1160,"wires":[["bf5803d5a37bbf7a","aac3da4f81ed1491"]]},{"id":"bf5803d5a37bbf7a","type":"change","z":"e089622.6a906a","name":"OFF","rules":[{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":1160,"wires":[["b83361418671bdea","1c815229de707473","e5045037e386432a"]]},{"id":"0ccb89b56be09826","type":"inject","z":"e089622.6a906a","name":"ON","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"open","payloadType":"str","x":320,"y":1200,"wires":[["b4dfb7dc5d7ff7ad","1c815229de707473"]]},{"id":"b4dfb7dc5d7ff7ad","type":"change","z":"e089622.6a906a","name":"OFF","rules":[{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":1200,"wires":[["b83361418671bdea","aac3da4f81ed1491","e5045037e386432a"]]},{"id":"d88f30cdbb2d6d48","type":"inject","z":"e089622.6a906a","name":"ON","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"open","payloadType":"str","x":320,"y":1240,"wires":[["2e83c7b57742c990","e5045037e386432a"]]},{"id":"2e83c7b57742c990","type":"change","z":"e089622.6a906a","name":"OFF","rules":[{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":1240,"wires":[["1c815229de707473","aac3da4f81ed1491","b83361418671bdea"]]},{"id":"b83361418671bdea","type":"gate","z":"e089622.6a906a","name":"","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":500,"y":1290,"wires":[["d7041a4fc93d304b"]]},{"id":"aac3da4f81ed1491","type":"gate","z":"e089622.6a906a","name":"","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":500,"y":1330,"wires":[["d4cc5ef8d7767e3a"]]},{"id":"1c815229de707473","type":"gate","z":"e089622.6a906a","name":"","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":500,"y":1370,"wires":[["42b2069c39229406"]]},{"id":"e5045037e386432a","type":"gate","z":"e089622.6a906a","name":"","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":500,"y":1410,"wires":[["ef485e68644a06f9"]]},{"id":"59e0f09f57b01661","type":"inject","z":"e089622.6a906a","name":"Incoming message","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":280,"y":1360,"wires":[["b83361418671bdea","aac3da4f81ed1491","1c815229de707473","e5045037e386432a"]]},{"id":"d7041a4fc93d304b","type":"debug","z":"e089622.6a906a","name":"To option 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":1290,"wires":[]},{"id":"d4cc5ef8d7767e3a","type":"debug","z":"e089622.6a906a","name":"To option 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":1330,"wires":[]},{"id":"42b2069c39229406","type":"debug","z":"e089622.6a906a","name":"To option 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":1370,"wires":[]},{"id":"ef485e68644a06f9","type":"debug","z":"e089622.6a906a","name":"To option 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":1410,"wires":[]}]