Building a workflow
Breakdown of a workflow | |
In BMC Helix Edge, workflows are key to making sense of data collected from IoT devices. Workflows orchestrate and automate various tasks and processes in the IoT ecosystem. It contains analyses and acts upon that collected data, making the system more innovative and responsive. Use the following breakdown to show how a workflow in BMC Helix Edge comes together:
|
Before deploying a workflow in a production environment, you must evaluate and validate its functionality in a controlled setting. BMC Helix Edge provides tools and environments for thorough testing to make sure the workflow performs as expected. After a workflow has been designed, configured, and evaluated, you can deploy the workflow. You continuously deployed workflows, monitored for specified events, and run actions in real time.
Before you begin
- Make sure you have device profiles and metrics.
- Make sure the devices are connected to the network.
- Make sure the MQTT broker is configured and running and complete with the necessary connection details.
- Make sure you know the data generated by devices.
- Familiarize yourself with Node-RED, its flow creation, node usage, and configuration. To learn more about using Node-RED, see the Node RED documentation.
- Determine the workflow requirements, encompassing actions to automate, data transformations, and potential external integrations.
- Set up a testing environment for thoroughly validating and testing the Node-RED workflows before deploying them in a production environment.
Subscribing to a specific event
To subscribe to a specific MQTT topic where BMC Helix Edge publishes the oil level data,
- To initiate your workflow, you must subscribe to a specific event.
- On the BMC Helix Edge page, select Rules and workflows > Workflow Builder.
- In the left pane of the Workflow builder page, select a node to build a workflow.
- In the Streams pane, select a data stream and in the workflow space, expand the Input category in the Node palette.
- From the palette, select mqtt-in.
Click the Properties tab, and input the following details:
Field name
Description
Server
Select the MQTT broker server from the pre-configured options.
Action
Select Subscribe to single topic.
QoS
Determine the quality of service for MQTT. For more information, see the MQTT documentation.
Topic
Enter the name of the topic as {node1}/BMCEvents.
{node1} represents the NodeId, accessible from the Device list UI.
BMC recommends printing the subscribed event to obtain the event field names.Output
Auto-detection is usually sufficient. Select the parsed JSON object because the Event is in JSON format.
Name
Displays the event name from the Events field.
The following is an example of an event subscription:
BMC Helix Edge uses the event fields from the payload. For example, the event name in the Name field is LowOilEvent:
Building and executing remediation commands
Automating remedial actions is a key objective in workflow creation. BMC Helix Edge supports two types of remedial actions: DeviceCommand and NewServiceRequest. Regardless of the type chosen, you must construct the command payload and publish the payload to the {nodeid}/BMCCommands topic.
You must replace nodeid with the actual nodeid where the workflow operates, obtainable from the device UI listing.
The following table describes the signature of the command payload:
Command | Description |
---|---|
id | A unique identifier. |
device_name | The name of the device. |
type | The type of command. For example, NewServiceRequest, CloseServiceRequest, DeviceCommand. |
execution_node_type | The type of execution node. For example, Edge, Core. |
name | The name of the command. |
command_parameters | Parameters required for the command. |
problem | The description of the problem. |
source_node | The original node triggering the event. |
severity | The severity level of the event. |
command_uri | The URI for the command. |
event_id | The ID of the event. |
correlation_id | The correlation ID for tracking. |
created | The time stamp of command creation. |
remediation_id | The ID for remediation. |
status | The execution status of the command. |
The following is an example payload for a work order to replenish oil (assuming BMC Digital Workplace is configured).
{
"id": "msg.payload.id",
"correlation_id": "msg.payload.correlation_id",
"device_name": "msg.payload.device_name",
"name": "msg.payload.name",
"type": "NewServiceRequest",
"problem": "Gearbox failure due to low oil",
"source_node": "msg.payload.source_node",
"severity": "msg.payload.severity",
"event_id": "msg.payload.id",
"status": "msg.payload.status",
"command_parameters": {
"serviceID": "11903",
"Fuel Level": "msg.payload.actual_value.toString()",
"Reason for Request": "Gearbox failure again due to low oil",
"summary": "Order Onsite Fuel Service LowOilOpen",
"ticketType": "Work-Order"
}
}
Make sure that the DeviceCommand payload is similar (type: DeviceCommand) and that command_parameters are specific to commands as defined by device_service.
Refer to the list of device commands in the device UI and its parameters for further details.
Using Workflow Designer
The following tasks provide high-level steps to build a workflow and generate service requests by using Node-Red. BMC recommends referring to Documentation: Node-RED.
Building a workflow
- On the BMC Helix Edge page, select Rules and workflows > Workflow Builder.
BMC Helix Edge displays the following panel: - In the left pane of the Workflow builder page, select a node to build a workflow.
- In the Streams pane, select a data stream for a node, and in the workflow space, perform the following steps:
- To add a node input node:
- Expand the Input category in the Node palette, which contains nodes that can trigger your workflow.
- Drag and drop an appropriate input node to the flow canvas. For example, select Inject.
- To add processing nodes:
- Expand the Function or other relevant categories in the Node palette.
- Drag and drop processing nodes onto the flow canvas to define how you want to process the input data or trigger events.
These nodes can include JavaScript functions, switches, or other processing logic.
- To add output nodes:
- Expand the Output category in Node Palette.
- Drag and drop an output node (for example, Debug node) onto the flow canvas to view or log the output of your workflow.
Depending on your use case, you can also connect output nodes to external systems or services.
- To define the data flow and logic:
- Connect the nodes by drawing lines between their output and input ports.
- Click and drag from the output port of one node to the input port of another node to create a connection.
- To configure the node properties:
- Double-click the node to open its properties panel.
- Configure the properties, such as input values, conditions, or actions, based on your workflow requirements.
- To deploy a workflow, click Deploy in the upper-right corner of Node-RED Editor.
BMC Helix Edge deploys your workflow, making it active and ready to run. - (Optional) To monitor and test the workflow, use the Node-RED debug panel to monitor the output and behavior of your workflow.
- Click Save.
After the deployment, ongoing monitoring and maintenance are essential to make sure the workflow operates effectively. This monitoring might involve periodic updates, adjustments to accommodate changing conditions, and performance optimization.
- To add a node input node:
Generating service requests by using Node-RED
- On the BMC Helix Edge page, select Rules and workflows > Workflow Builder.
- Under Note in the Workflow builder page, select a node to build a workflow.
- In the Streams pane, select a data stream for a node, and in the workflow space, perform the following steps:
- To add an input node:
- Drag and drop an input node from the left sidebar onto the workspace.
- Configure this input node to receive the event data related to the oil level.
For example, you might use an MQTT input node to subscribe to a specific MQTT topic where BMC Helix Edge publishes the oil-level data.
- To add rule node:
- Drag and drop a function or switch node to your workspace.
- Configure this node to check whether the received oil level data is below the threshold.
You must write a JavaScript function that evaluates the data and decides whether it triggers the rule.
- To add output node:
- Drag and drop an output node onto the workspace.
- Configure this output node to create a work order when the rule is met.
Depending on your setup, this action might involve making an HTTP POST request to a service that handles work orders or using a custom node if available.
- To connect nodes:
- Connect the nodes in your workflow by drawing lines between them.
- Connect the output of the rule node to the output node's input to establish the data flow.
- Configure the output node to create a work order with the necessary details when the rule is satisfied.
This step depends on the specific system or service you are integrating. - To deploy the workflow, click Deploy to save and activate your workflow.
When the oil level drops below the defined threshold, the workflow triggers the creation of a work order to replenish the oil automatically. Make sure to customize the nodes, rules, and actions to match your actual setup and requirements.
- To add an input node: