Allow aliasing of inputs on nodes

Hello everyone,

I am opening this thread to discuss adding functionality to Node-RED that would allow nodes to have multiple 'virtual' inputs that serve as aliases to the single 'real' input that nodes currently have.
I know that this/similar topics have been discussed multiple times on the forum already, e.g. in this thread: Tagging msg and multiple inputs. It would, however, really benefit my usecase to allow aliased inputs, which I will try to illustrate below.

First of all, the idea for the functionality, conceptually is very simple:

  • Allow developerers of nodes to define a node with > 1 input
  • Change the inputLabels property to a list that can be used to define aliases for the input
  • For nodes with > 1 input: on receipt of a message, set a field msg.inputAlias with the alias of the "virtual" input on which the message was received

Now to illustate the my usecase, you should know that I work for an organisation where we try to interest young children in programming and technology in general. Up until now, we have been playing with the idea to use Node-RED as a simple introduction to programming.

To this end, I am trying to create a Node-RED module that would allow the children to interface with a custom Arduino-based board in a simple, visual matter. To simplify and abstract away as much of the hardware as possible, it would be very convenient to have a single node that has an "aliased input" for each of the pins that the kids could use as an output on the board. That way the kids could easily connect their functionality to the relevant input node of the hardware node, to e.g. switch on an LED. It might look like this, for instance:
MOCK

I know that there are already different ways to achieve similar functionality with a single input node, e.g. using change blocks for the message topics, but I believe that having these aliased inputs would allow the children to easily add the "hardware node" to a flow, and then focus solely on creating their desired behaviour, without having to focus on adding additional nodes to properly send messages to the hardware board.

Now, I am not asking the core development team to implement the functionality that I described above, but I am wondering if there are serious objections to having these aliased inputs.
The reason I am asking the question, is that I would like to know if there might be the possibility that the functionality would be added to Node-RED if I were able to create it and opened a pull request for it.

Best regards and thank you in advance,
Olivier

Since the idea of a node is to do one thing and do it well, I assume (bad to do I know) that each input point would really have to go to a seperate flow to do it's work. Coding one node to handle an LED, BUZZER, LCD, and SERVO would be a lot of code and probably a bear to code and maintain. Are you planning to do the coding and maintenance of the "Interface Board" node if this was to come to frutition?

Here is a possible way you could do it within the existing structure - use Link nodes and having the 'look' you describe.

What I did was to create a bunch of change and link-out nodes representing the interface board. The change nodes do nothing and just pass the message to the link-out node that links to a link-in node in a group representing the logic for that interface.

Here is the flow so you can play with it.

[{"id":"c69c049e.5a3cc8","type":"tab","label":"Arduino simulator","disabled":false,"info":""},{"id":"304ba151.c36016","type":"group","z":"c69c049e.5a3cc8","name":"","style":{"stroke":"#ffcf3f","fill":"#ffcf3f","label":true},"nodes":["683cc5ef.8fe58c","b2b6ddb5.7c898"],"x":394,"y":538,"w":412,"h":83},{"id":"78ae2fce.ec413","type":"group","z":"c69c049e.5a3cc8","name":"Arduino Board","style":{"stroke":"#92d04f","fill":"#92d04f","label":false},"nodes":["c2b8f652.745af","93c01ee8.fcda8","ceaad0ea.73d078","ed18b794.7a6dc8","6f0e58ef.2699a","5601c686.8d27c","419c2974.d8d598","41d3512f.78f3c","fea0040f.2c8b5"],"x":254,"y":99,"w":382,"h":262},{"id":"7d0557f7.52a6f","type":"group","z":"c69c049e.5a3cc8","name":"","style":{"stroke":"#ffcf3f","fill":"#ffcf3f","label":true},"nodes":["dfbeeaac.55aa4","efacae76.2c855"],"x":394,"y":419,"w":412,"h":83},{"id":"c2b8f652.745af","type":"comment","z":"c69c049e.5a3cc8","g":"78ae2fce.ec413","name":"Interface Board","info":"","x":530,"y":230,"wires":[]},{"id":"93c01ee8.fcda8","type":"link out","z":"c69c049e.5a3cc8","g":"78ae2fce.ec413","name":"to LED Flow","links":["dfbeeaac.55aa4"],"x":416,"y":140,"wires":[]},{"id":"683cc5ef.8fe58c","type":"link in","z":"c69c049e.5a3cc8","g":"304ba151.c36016","name":"Buzzer Flow","links":[],"x":490,"y":580,"wires":[["b2b6ddb5.7c898"]],"l":true},{"id":"b2b6ddb5.7c898","type":"debug","z":"c69c049e.5a3cc8","g":"304ba151.c36016","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":579,"wires":[]},{"id":"ceaad0ea.73d078","type":"link out","z":"c69c049e.5a3cc8","g":"78ae2fce.ec413","name":"to Buzzer Flow","links":[],"x":416,"y":200,"wires":[]},{"id":"419c2974.d8d598","type":"link out","z":"c69c049e.5a3cc8","g":"78ae2fce.ec413","name":"to LCD Flow","links":[],"x":415,"y":260,"wires":[]},{"id":"ed18b794.7a6dc8","type":"link out","z":"c69c049e.5a3cc8","g":"78ae2fce.ec413","name":"to Servo Flow","links":[],"x":415,"y":320,"wires":[]},{"id":"dfbeeaac.55aa4","type":"link in","z":"c69c049e.5a3cc8","g":"7d0557f7.52a6f","name":"LED Flow","links":["93c01ee8.fcda8"],"x":480,"y":461,"wires":[["efacae76.2c855"]],"l":true},{"id":"efacae76.2c855","type":"debug","z":"c69c049e.5a3cc8","g":"7d0557f7.52a6f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":460,"wires":[]},{"id":"6f0e58ef.2699a","type":"change","z":"c69c049e.5a3cc8","g":"78ae2fce.ec413","name":"Servo","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":320,"wires":[["ed18b794.7a6dc8"]]},{"id":"8e30e095.75e078","type":"inject","z":"c69c049e.5a3cc8","name":"to SERVO","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":320,"wires":[["6f0e58ef.2699a"]]},{"id":"5601c686.8d27c","type":"change","z":"c69c049e.5a3cc8","g":"78ae2fce.ec413","name":"LCD","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":260,"wires":[["419c2974.d8d598"]]},{"id":"41d3512f.78f3c","type":"change","z":"c69c049e.5a3cc8","g":"78ae2fce.ec413","name":"Buzzer","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":200,"wires":[["ceaad0ea.73d078"]]},{"id":"fea0040f.2c8b5","type":"change","z":"c69c049e.5a3cc8","g":"78ae2fce.ec413","name":"LED","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":140,"wires":[["93c01ee8.fcda8"]]},{"id":"627019b4.d907d8","type":"inject","z":"c69c049e.5a3cc8","name":"to LED","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":140,"wires":[["fea0040f.2c8b5"]]},{"id":"b4c066a4.d4c0c","type":"inject","z":"c69c049e.5a3cc8","name":"to BUZZER","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":200,"wires":[["41d3512f.78f3c"]]},{"id":"10f5d60d.21d0da","type":"inject","z":"c69c049e.5a3cc8","name":"to LCD","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":260,"wires":[["5601c686.8d27c"]]}]
3 Likes

You can of course also change the icons on those change nodes - and hide the rest in a subflow inside the green group.

3 Likes

Here is how it would look using Dave's ideas

and here is the flow:

[{"id":"205b8b94.69f7bc","type":"subflow","name":"Servo","info":"","category":"","in":[{"x":140,"y":100,"wires":[{"id":"e9712e42.facd9"}]}],"out":[],"env":[],"color":"#DDAA99"},{"id":"74df2fc1.0864e8","type":"debug","z":"205b8b94.69f7bc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":530,"y":100,"wires":[]},{"id":"e9712e42.facd9","type":"change","z":"205b8b94.69f7bc","name":"dummy for example","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":100,"wires":[["74df2fc1.0864e8"]]},{"id":"8f8737d4.84411","type":"comment","z":"205b8b94.69f7bc","name":"Servo Flow","info":"","x":310,"y":40,"wires":[]},{"id":"abe1f7ba.a98ec","type":"subflow","name":"LCD","info":"","category":"","in":[{"x":160,"y":100,"wires":[{"id":"b200298a.f8b068"}]}],"out":[],"env":[],"color":"#DDAA99"},{"id":"2c5a67d8.8995b8","type":"debug","z":"abe1f7ba.a98ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":100,"wires":[]},{"id":"b200298a.f8b068","type":"change","z":"abe1f7ba.a98ec","name":"dummy for example","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":100,"wires":[["2c5a67d8.8995b8"]]},{"id":"42671770.c25788","type":"comment","z":"abe1f7ba.a98ec","name":"LCD Flow","info":"","x":330,"y":40,"wires":[]},{"id":"242d81d1.b1187e","type":"subflow","name":"Buzzer","info":"","category":"","in":[{"x":160,"y":100,"wires":[{"id":"a99e1d29.8f997"}]}],"out":[],"env":[],"color":"#DDAA99"},{"id":"eda8708.73eb09","type":"debug","z":"242d81d1.b1187e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":570,"y":100,"wires":[]},{"id":"a99e1d29.8f997","type":"change","z":"242d81d1.b1187e","name":"dummy for example","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":100,"wires":[["eda8708.73eb09"]]},{"id":"1683aa2a.b11af6","type":"comment","z":"242d81d1.b1187e","name":"Buzzer Flow","info":"","x":360,"y":40,"wires":[]},{"id":"b135a417.41ca8","type":"subflow","name":"LED","info":"","category":"","in":[{"x":180,"y":120,"wires":[{"id":"4387d91a.2a4558"}]}],"out":[],"env":[],"color":"#DDAA99"},{"id":"bce176f6.8b339","type":"debug","z":"b135a417.41ca8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":120,"wires":[]},{"id":"4387d91a.2a4558","type":"change","z":"b135a417.41ca8","name":"dummy for example","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":120,"wires":[["bce176f6.8b339"]]},{"id":"a6ef8418.b2cf2","type":"comment","z":"b135a417.41ca8","name":"LED Flow","info":"","x":390,"y":60,"wires":[]},{"id":"c69c049e.5a3cc8","type":"tab","label":"Arduino simulator","disabled":false,"info":""},{"id":"72f1386.b4c34c8","type":"group","z":"c69c049e.5a3cc8","name":"","style":{"stroke":"#92d04f","fill":"#92d04f","label":true},"nodes":["c2b8f652.745af","6f0e58ef.2699a","5601c686.8d27c","41d3512f.78f3c","fea0040f.2c8b5","e1224b24.1630e","3d4138b1.cdf8e8","ceed32fa.48f5d8","cb9bfbc3.5ec378"],"x":254,"y":99,"w":532,"h":262},{"id":"c2b8f652.745af","type":"comment","z":"c69c049e.5a3cc8","g":"72f1386.b4c34c8","name":"Interface Board","info":"","x":530,"y":230,"wires":[]},{"id":"6f0e58ef.2699a","type":"change","z":"c69c049e.5a3cc8","g":"72f1386.b4c34c8","name":"Servo","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":320,"wires":[["cb9bfbc3.5ec378"]]},{"id":"8e30e095.75e078","type":"inject","z":"c69c049e.5a3cc8","name":"to SERVO","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":320,"wires":[["6f0e58ef.2699a"]]},{"id":"5601c686.8d27c","type":"change","z":"c69c049e.5a3cc8","g":"72f1386.b4c34c8","name":"LCD","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":260,"wires":[["ceed32fa.48f5d8"]]},{"id":"41d3512f.78f3c","type":"change","z":"c69c049e.5a3cc8","g":"72f1386.b4c34c8","name":"Buzzer","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":200,"wires":[["3d4138b1.cdf8e8"]],"icon":"node-red/bridge.svg"},{"id":"fea0040f.2c8b5","type":"change","z":"c69c049e.5a3cc8","g":"72f1386.b4c34c8","name":"LED","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":140,"wires":[["e1224b24.1630e"]],"icon":"node-red/light.svg"},{"id":"627019b4.d907d8","type":"inject","z":"c69c049e.5a3cc8","name":"to LED","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":140,"wires":[["fea0040f.2c8b5"]]},{"id":"b4c066a4.d4c0c","type":"inject","z":"c69c049e.5a3cc8","name":"to BUZZER","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":200,"wires":[["41d3512f.78f3c"]]},{"id":"10f5d60d.21d0da","type":"inject","z":"c69c049e.5a3cc8","name":"to LCD","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":260,"wires":[["5601c686.8d27c"]]},{"id":"e1224b24.1630e","type":"subflow:b135a417.41ca8","z":"c69c049e.5a3cc8","g":"72f1386.b4c34c8","name":"","x":710,"y":140,"wires":[]},{"id":"3d4138b1.cdf8e8","type":"subflow:242d81d1.b1187e","z":"c69c049e.5a3cc8","g":"72f1386.b4c34c8","name":"","x":710,"y":200,"wires":[]},{"id":"ceed32fa.48f5d8","type":"subflow:abe1f7ba.a98ec","z":"c69c049e.5a3cc8","g":"72f1386.b4c34c8","name":"","x":710,"y":260,"wires":[]},{"id":"cb9bfbc3.5ec378","type":"subflow:205b8b94.69f7bc","z":"c69c049e.5a3cc8","g":"72f1386.b4c34c8","name":"","x":710,"y":320,"wires":[]}]
3 Likes

And that could be saved to the library as a template flow for others to then easily add to their flows.

I wonder if what might be more widely interesting would be a way to be able to add flows or flow snippets directly from GitHub or a gist?

1 Like