IBM Support

Using sensor data to create tickets in Maximo with Node-Red on Bluemix

Technical Blog Post


Using sensor data to create tickets in Maximo with Node-Red on Bluemix


Back in December I posted a blog on how I was turning lights on with Maximo. This was using a mixture of MQ, MessageSight, Node-Red and Maximo to route messages and turn on a light using GPIO commands. If you haven't read this article it can be found here. Today I want to go over some more Node-Red and IoT related functions and integrating it with Maximo. There are lots of different scenarios here, but we will be creating a Ticket in Maximo based on the intensity of light. 


To get started we need the following


IBM Bluemix 

  • Internet of Things Platform Starter boilerplate -  This includes Node.js,  Cloudant NoSQL DB and Node-Red.
  • Secure Gateway service - If your Maximo server is not open to the internet a gateway needs to be configured to allow Bluemix to connect to the Maximo server.  I won't go over the configuration of this service in this blog.


  • Maximo environment utilizing the Rest API


  • For this I'm using a Texas Instruments Sensor Tag and the TI Sensor Tag Mobile app. If you don't have a device you could replace the ibmiot node with an inject node to trigger the work order creation.


Now lets get started on the actual process of configuring Node-Red. To read the sensor data we need to associate the device id of our SensorTag to the the IBM IoT node  On your Node-Red flow drag over the 'ibmiot' input node. The node properties should be configured as follows. 


The Device ID can be found using the TI Sensor Tags application on your phone, which is being used to broadcast the sensor data being sent to it via bluetooth and push that data to the cloud.  With this option we are using Quickstart for authentication as the device is not registered to bluemix.






The next thing we want to do is add a switch node, which says if the value of light drops below 1.00 we create a work order, if the value of light is 1.01 or higher we just output the value of light.  This information comes across in JSON format, so we need to check just the value of light rather the the entire message payload which looks like you see below in JSON format.


{ "d": { "gyro_x": "0.00", "compass_y": "0.00", "humidity": "37.47", "acc_y": "0.00", "object_temp": "20.78", "acc_x": "-0.00", "light": "83.60", "gyro_z": "0.00", "compass_x": "0.00", "ambient_temp": "27.16", "gyro_y": "0.00", "air_pressure": "843.26", "compass_z": "0.00", "acc_z": "-0.00" } }


To separate out the value of light, we would append the d from the above JSON string and then attribute of light, so we would be only displaying the value of msg.payload.d.light and route the request based off this value.




The next step in this process that we need is a HTTP Request function node and this function will create our ticket in Maximo using the rest API.  If you're not familiar with this API there are many good blogs on this developer works outlining how it works.


In the above screenshot we have our HTTP Request Node,  the method for this request is POST as we are posting data to Maximo. The return for the insert is a UTF-8 string which can be output to a DEBUG node to show a successful insert and the URL which is inserting the data in to your environment via the REST API.…


The above URL is utilizing a custom object structure called L2DESK and is and creating a ticket with the client name. For every attribute you want to insert data for you would add it on to the URL above.


For example &DESCRIPTION=Work Order to Replace Bulb would insert in to the description attribute.


As soon as the flow reaches this node as insert of the record will be created in the instance of Maximo defined for the URL.


After this, we can add some debug nodes to output some information, the final flow would like similar to what you see below.




The debug node attached to the HTTP Request function will display the response to the rest call as you see below, stating the current light levels.





The debug node attached to the switch node will display the light values until it drops below 1.0.0 where it is then routed to the http request node instead.  The debug node outputs msg.payload.d.light to console and the debug window as seen below





If you don't have a sensor device, you could always use an inject node to trigger the HTTP Request Function to test creating records from Node-Red on Bluemix manually or simulate the functionality.  In a future blog I will discuss setting up the secure gateway in detail and how it works.  If anyone has any questions or comments please feel free to post below.

[{"Business Unit":{"code":"BU005","label":"IoT"}, "Product":{"code":"SSLKT6","label":"Maximo Asset Management"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":""}]