How to use functions of external javascript

I have installed (on the same server as node-red) an npm based JavaScript of the setopbox I use:

The files are installed in /home/pi/Ziggo/NextRemoteJs

How can I include this JavaScript (index.js) and library in my node-red system and use the functions inside the javascript file?

Assuming that all of the code in that library runs client side, you can use the static folder option. See your settings.js file.

If it is node.js code, you will need to require it in settings.js in the globals section - then you can incorporate it in a function node using global.get.

I am a newbie, how will I recognize if this is a node.js code?

The readme tells you everything you need to know. In fact it clearly says that it runs BOTH a server (index.js) and a client (index.html). The server servers up the web page but otherwise doesn't seem to interact. The server also provides MQTT integration.

So the easiest thing to do would be to run it according to the instructions - separate to Node-RED. Then use it to do a few things and monitor your MQTT Broker to see what message topics it is using. Then you can send those topics from Node-RED.

After that, pull apart the code and translate it to Node-RED. It isn't doing anything that you couldn't easily do in Node-RED.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.