Hi Paul
No, nodes can only have a single input.
You can use properties of the incoming messages to distinguish different sources.
Nick
Is there a way to create a node with 2 or more inputs?
--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Could you describe a bit more about what you're trying to do?
It isn't just the ui that only allows a single input; the nodes only have a single 'input' event in the runtime.
This was a purposeful design choice from the start. But I'm always keen to hear of use cases for it. All of the ones we have thought of have perfectly viable alternatives using the single input scheme we already have.
Nick
I guess I was hoping to use the UI to connect which sources control which things. Sounds like that's not possible from the UI and I have to edit the javascript code for my node?
I'm still really new and wrapping my head around how much of Node-Red works. Please forgive my ignorance. It looks like a really awesome system and I absolutely love the UI for connecting stuff.
And don't forget node.js is asynchronous in nature so each input would very in their own time. So you have to maintain state of all the other inputs. And then send an output based on the change of which input ? First ? Last? All ? Should initial output not occur until a valid input has been received on all inputs or should they default to some value ? Lots of potential behaviours that may need to be handled or exposed.
You can always have 5 outputs.... 1 for each separate and one for the JSON... Best of both...
Indeed - awesome. +1
--
I'm happy to have the discussion.
A single input was an early design decision based on the simple fact that everything we were doing only needed a single input. We've tried to stick with that approach and we haven't hit a scenario that can't be solved with a single input.
I would be interested to see what specific scenarios you think are better served by multiple inputs. I think it is subjective which approach is more intuitive to users; we have a broad user base. But if we can identify such use cases it gives us something concrete to revolve the discussion around.
Nick
--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi everyone, here's a more practical example. I've performed my desired function using the existing single-input scheme. The result is the necessity of two additional nodes that could preferably not be included:
1. "Add Topic "push""
2. "Add Topic "shift""
What I'm doing here is making a multiple input scheme on top of the existing scheme. It's clunky looking and I'm adding additional nodes to format the input of my Queue node.
Not sure how well that sits with the principle that nodes should not have to know what nodes they are wired to. And, as you say, if you have two function nodes (or Change nodes, which are a much more efficient way to set a property on the message) then it wouldn't help at all.
Nick
--
--
http://nodered.org
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/Q0YLQYCUJ_E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
--
Mind you of course you can pipe several outputs into one input…
--
It's a true reflection of the current state. It had been discussed, and while the semantics of multiple inputs are well known to elec engineers etc, the fact that you can assign extra properties to a message to distinguish between them means that there are other ways to solve this that don't
var inputA = context.get('A')||false;var inputB = context.get('B')||false;
if( msg.topic === 'A') { inputA = msg.payload; context.set('A', inputA);}else if( msg.topic === 'B') { inputB = msg.payload; context.set('B', inputB)}
return {payload:inputA||inputB};
var inputA = inputs.get(0)||false;var inputB = inputs.get(1)||false;
return {payload:inputA||inputB};
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
But.. you can do that with multiple sub objects.... msg.this and msg.that ????
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/Q0YLQYCUJ_E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
msg = { this = {dataA}, that = { dataB } }
If (msg.payload && msg.otherpayload)
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
It does get cumbersome and less visual when trying to code conditional home-automation to have a zillion nodes feed into a single point of a function node that has to act as a traffic cop based on msg.topic. With all of the individual change nodes that have to precede entry into the function to keep track of the source of messages, the spaghetti increases.
Isn't there some value, both aesthetic and practical, to allowing the user to define the number of inputs a function node should have, and then have the node automatically assign a routing number to "msg.input" as messages come in?