In the following article we explain how to install Node-RED on the IBM i. We will show you how to use Node-RED to query an IBM i database and then display the results. But first, let’s take a quick look at the terminology and the technology.
Node-RED is a visual programming tool that enables flow-based development. Initially created by IBM, it is now maintained under the OpenJS Foundation. The platform includes both a runtime and a browser-based editor. Users can drag nodes from a palette into the workspace within the editor and link them together.
Node-RED supports numerous add-ons, allowing it to interact with various data sources and connectors. This makes it especially versatile in the Internet of Things (IoT) sector, where its extensive range of add-ons facilitates easy integration and management of different IoT devices and services. For further information, visit the official Node-RED website at nodered.org.
IBM i is the operating system designed for the IBM i platform. This integrated system, combining both hardware and software, was developed by IBM. For decades, it has successfully served a diverse global clientele, recognized for its scalability, reliability, and adaptability. IBM i stands as a premier platform for managing and operating business-centric workloads, seamlessly blending legacy applications with contemporary open-source technologies.
IBM i and Node-RED are the perfect combination for modern business solutions. IBMi offers a robust, secure platform, while Node-RED impresses with its visual programming and simple integration. Together, they enable efficient automation and rapid development, which is ideal for modern business requirements and digital transformation. So they are the perfect combination of proven hardware with new technologies!
We can install Node-RED on the IBM i and show you how to use Node-RED to query an IBM i database to finally display the results.
- OpenSSH
- ServerNode.js
To install Node-Red we are not using yum or the AccessClientSolution package management.Go via SSH to your IBMi and logon as the installation user you want to install NODE-Red. Check prerequisites on the IBMi:
Install Node-RED:
After the installation is finished you can start Node-RED:
If you are not running nodejs at version 20 change it accordingly to the version you are running.To start NODE-Red automatically at system startup, you can add this command to your startup job. In this example we are using the User nodered:
The URL to your working Node-RED instance on the IBMi is:
http://youribmi:1880
If everything works as expected you are seeing this page:
On the left side of the page you have the nodes, which are grouped into sections.In center you place these nodes to create a flow.On the right you will see the information the Flow produces.On the top right you have the deploy button to save created flows. There is right next to it a drop down button we will need later.
As prerequisites for our example, we have to install the DB2 adapter. To do this select the 3 bars at the top right and click on manage palette:
Then select the install tab and search for IBMi:
Select node-red-contrib-db2-for-i and click on the install-button:
Now we are configuring node red to use the db2 adapter. Drop a timestamp node, a debug node and the db2 adapter node on the flow:
As you can see, the DB2 node has a red triangle above it. This means we have to configure the node accordingly. To do that, double click on the node and the property windows opens. Click on the single Array Result mode. This will provide the response in a single array. Click on the pencil to add a new configuration:
Fill the details accordingly to your needs:
Clicking on the help icon will now show the available options for the db2 adapter:
Here, it is evident that the SQL statement must be provided in the msg.payload property. To achieve this, close all current dialogs appropriately and open the properties of the timestamp node. Double-click on the node to proceed:
Delete the msg.topic Value and change msg.payload from timestamp to string. Enter the SQL query in the msg.payload tab. We are querying a customer table supplied by IBM.
Close the window and don't forget to click on deploy. As we are now finished with the configuration lets test it. Click on the inject button:
As you can see we got an array ack with 12 results. If we expand this array we can see the values of each entry.
The example shows that it is not difficult to configure tasks in Node-RED on the IBMi. You can also use Node-RED for much more complex operations on the IBM i, such as executing commands, complex SQL queries, writing files and more.
Contact us for more information
End of Messages