Overview

Skill Level: Any Skill Level

Ingredients

  1. BM Maximo instance (7.5.0.6 or higher) with TPAE OSLC Object Structure;
  2. An MQTT – REST API for Maximo running;
  3. A Bluemix account

 

 

 

Step-by-step

  1. Example of Architecture using Maximo API

    Maximo can be combined to other Bluemix services in order to create work orders based on device’s behavior. Following the architecture illustrated below, it is possible to monitor a device registered at WatsonIoT Platform, check the device parameters through Real Time Insights and trigger actions (create a work order at Maximo, for example) through Node-RED application. The following steps explains how to configure each component of this architecture.

    e.

  2. 1. Register your device at Watson IoT Platform

    1.1. Follow the steps described in the link below.

    How to Register Devices in IBM Watson IoT Platform

    1.2. Take note of the device credentials. They will be used when configuring the RTI datasource on step 4.

  3. 2. Download Maximo API (MQTT -> REST) from GitHub

    Maximo API is able to receive an MQTT from Watson IoT Platform(configured at Bluemix) and converts the received payload into a REST call to Maximo.

    2.1. This API is available on GitHub (link below). Follow the steps described on GitHub to have the API running locally or at Bluemix. There are instructions on GitHub on how to deploy the application, how to connect to your Maximo instance and where to configure the MQTT topic (take note of this topic).

    https://github.com/nerygustavo/iot-maximo-sample

    2.2. Check if your API instance is running by doing the following test:

    http://<YOUR API ADDRESS>.mybluemix.net/maxtest/querywo/<WONUM>/<SITE>

    For example:

    http://iot-maximo-sample.mybluemix.net/maxtest/querywo/1000/BEDFORD

    The response in your browser should be something like:

    [{“wpmaterial_collectionref”:”https://<host>:<port>/<schema>/oslc/os/mxwodetail/xxxxxxxxxxx/wpmaterial”,”wplabor_collectionref”:”https://<host>:<port>/<schema>/oslc/os/mxwodetail/wplabor”,”assetnum”:”11300″,”_rowstamp”:”10656772″,”wptool_collectionref”:”https://<host>:<port>/<schema>oslc/os/mxwodetail/xxxxxxxxxxx/wptool”,”status”:”APPR”,”location”:”BR300″,”description”:”Relocate Guard Rails Around Compressor”,”invreserve_collectionref”:”https://<host>:<port>/<schema>oslc/os/mxwodetail/xxxxxxxxx/mxintinvres”,”wonum”:”1000″,”wpservice_collectionref”:”https://<host>:<port>/<schema>/oslc/os/mxwodetail/xxxxxxxxx/wpservice”,”href”:”https://<host>:<port>/<schema>/oslc/os/mxwodetail/xxxxxxxxxxxxx”}]

    2.3. If you deploy Maximo API at Bluemix following GitHub tutorial (there is a button Deploy to Bluemix), an Watson IoT Platform service will be automatically created and associated to your Maximo API application. Go to Bluemix dashboad and take note of the credentials of this Watson IoT Platform service. They will be used when configuring node-RED app on item 3.

    2.4. You can check MQTT connection of the API using MQTT-Helper.

    http://mqtt-helper.mybluemix.net/#collapsePublish

    • Fill Mqtt-Helper page with the credentials you’ve taken from item 2.3:

    Server: <ORG>.messaging.internetofthings.ibmcloud.com

    Client ID: a:<ORG>:test

    User Name: a-<ORG>-<KEY>

    Password: <TOKEN>

    • Fill the topic according you have configured at Maximo API (item 2.1):

    Topic: iot-2/type/<TYPE>/id/<DEVICE>/evt/<EVENT>/fmt/json

    • Fill the payload to test the API. Here are some examples of payloads to handle with Work Order object:

    – Create: add a new workorder record with data information.

    {“action”:”create”,”object”:”wo”,”data”:{“desc”:”<YOUR_DESC>”,”assetnum”:”<YOUR_ASSET_NUMBER>”}}

    – Update: update the description of an existing wo record that matches the attributes (replace <wonum> and <siteid> by your own values):

    {“action”:”update”,”object”:”wo”,”attr”:{“wonum”:”<wonum>”,”siteid”:”<siteid>”},”data”:{“desc”:”<DESC_TO_BE_UPDATED>”}}

    • After filling all mqtt-helper information, press Publish. Check if the actions are reflected on your Maximo instance.

    2.5. These are just some examples of the API capability. You can create your own payloads and routers to Maximo objects.

  4. 3. Create a Node-RED application

    The link below shows the basic steps to create a nodeRED app:

    https://console.ng.bluemix.net/docs/starters/Node-RED/nodered.html#nodered

    Create a Node-RED app and take note of the URL where it will be launched (it will be used on item 4). The app URL should be something like:

    http://YOUR_NODE_RED_APP_ADDRESS.mybluemix.net

    Considering the use case to Create Work Orders, the picture shows the basic flow to be implemented at NodeRED. The next items explains each node.

    3.1. The first step is to configure the HTTP POST url (it will be concatenated with the node-RED app URL and will be used by RTI on item 4).

    For this example, the URL will be defined as /createwo.

    3.2. Connect a simple HTTP response node to “HTTP in” node to avoid a Node-RED flow exception..

    3.3. Create a simple function node to write the message payload in the format expected by the API.

    The Java Script code triggered inside this Node could be something like:

    var finalmsg = ‘{“action”:”create”,”object”:”wo”,”data”:{“desc”:”description”,”assetnum”:”SENSOR”}}’;

    msg.payload = finalmsg;

    return msg;

    3.4. Connect an MQTT out node to the function node.

    Configure the MQTT node connection (*) according the Watson IoT Platform service credentials (item 2.3). You will need also to configure the topic with the same string as defined at Maximo API (item 2.1).

    Once this flow is triggered by an external system (RTI to be configured in the next item will do that), the payload defined at the funcion will be sent to Maximo API through MQTT.

    (*) Item 3.4 uses the same configuration from item 2.3, where MQTT Helper has been used to test Maximo API.

  5. 4. Set up actions in Real Time Insights

    After logging into Bluemix, go to Internet of Things Services catalog and create an IoT Real Time Insights (RTI) Service.

    See the steps at https://console.ng.bluemix.net/docs/services/iotrtinsights/index.html.

    Create a new Datasource (step 5d at the link above) using the credentials of the device created at step 1.2 of this recipe.

    4.1. Create the rules that will be applied to your device. The link below explains how to create new rules associated to a datasource:

    https://console.ng.bluemix.net/docs/services/iotrtinsights/rules.html#rules

    4.2. Create a Node-RED action:

    https://console.ng.bluemix.net/docs/services/iotrtinsights/actions.html

    Set the URL as the addres of your Node-RED app plus /createwo.

    http://YOUR_NODE_RED_APP_ADDRESS.mybluemix.net/creatwo

    This way, when the rule criteria is met an action is triggered to be executed by your node-RED flow.

    See more details about “Actions” in the link below (Node-RED section) :

    https://developer.ibm.com/recipes/tutorials/perform-actions-in-ibm-watson-iot-platform-analytics-real-time-insights/

    Now, every time your device reaches a pre-defined condition in RTI, a Work Order is created at your IBM Maximo instance!

Join The Discussion