Creating your own nodes for Node-RED

Hi, I am new to using Node-red. I need to create my own node in node-red. could you please help me to do this?
Regards

There is a documentation available here: Creating your first node : Node-RED

Do you need to know something specific?

Once you have node-red-contrib-example-lower-case running, the Node-RED source code on GitHub and the contributed nodes in the Flow Library offer lots of examples, some more advanced than others.

THe first question to be asked is - why?

Have you thought through the issue and looked through the existing nodes?

You are launching straight into the deep end and often a new node isn't actually needed. Maybe share a bit more about what you are trying to achieve and people might be able to find an easier route.

If you do need to go down that route, how are your JavaScript, HTML and Node.js skills because you will need some of each to write a node well.

1 Like

Thanks for the replies.
Actually, I need to make a node to control my device which a smart plug.

I have done the steps in this link Creating your first node : Node-RED

But could you please help me in the last step which is "Publishing to npm"

You need to open the console in your nodes root folder and run npm publish. It will probably complain that you haven't set up npm on your computer and will give you more details on what you have to do. You definitely need a npmjs.com account and an access token that you can generate in your profile.

Thanks, it did not give me more details on what I have to do. could you please tell me those steps to set up npm?

What sort of smart plug is it?

I do not have it yet. What I need to do is to turn on/off the device when its node got input on/off.

If you have not got it yet how do know whether there is already a node that accesses it? Almost every such device that can be used in this way already had a node available. Also, how have you written a node if you don't know how to access it?

1 Like