Can't we create a custom node with more than one inputs

#1

Hi,

I tried to create a custom node with 2 inputs. Following is the part of my HTML file where I have given 2 inputs to this node.

<script type="text/javascript">
    RED.nodes.registerType('myNode',{
    category: 'myCategory',
    color: '#a6bbcf',
    defaults: {
    
    abc: {value:""},
    bcd: {value:""},  
    xyz: {value:""},
    pqr: {value:""}
    },
    inputs:2,
    outputs:2,
    icon: "file.png",
    label: function() {
        return this.name||"myNode";
    }
});

The installed node on Node-Red shows me zero inputs in this case. If I give change it to inputs:1, the installed node shows that input in the UI. What is the reason for this behavior? Is there any problem in my code?

Thank you

0 Likes

#2

Short answer - no.
We don’t support multiple inputs, so the valid values are 0 or 1 only.

0 Likes

#3

Maybe I'm missing something, or abusing node-red, but I use multiple inputs quite often in function nodes. Sure there is only a single wiring endpoint, but I can feed in as many inputs as I need and sort them out to take action based on message topic or message payload values. Combined with context set and get it works wonders for what I'm doing with node-red. The future persistent across restarts storage being talked about would add another level of versatility.

It seems natural to me to do the logic in a function node or in another task (like Python) with node-red doing the "plumbing" for the data flow and MQTT to tie the different processes together.

0 Likes

#4

Correct. That is the model we support. You can wire many sources to the one input and use some property (like topic for example) to distinguish between incoming messages.

0 Likes