Skip to content

Transforming Real-Time Data with Transforms

The Transforms feature in Machinechat JEDI (introduced in version 3.21.0) allows users to dynamically process and manipulate real-time IoT data. By using Calculation and Translation transforms, you can unlock deeper insights and enable advanced automation.

Key Use Cases

  • Data Derivation
    Automatically calculate derived metrics like energy consumption rates or efficiency percentages.
    (Calculation Transforms)

  • State Mapping
    Map sensor readings to meaningful states, such as converting temperature ranges to "Cold," "Moderate," or "Hot."
    (Translation Transforms)


Configuration

Adding a Transform

  1. To add a transform, navigate to Settings -> Transforms, and click the Add Transform button.

  2. Select the desired transform type: Calculation or Translation.

Transforms Configuration
Transform Configuration

Calculation Transforms

Calculation Transforms let you evaluate expressions to calculate new metrics based on real-time data.

Example:

Suppose you have a sensor reporting temperature in Kelvin and you want to convert it to Fahrenheit.

Expression:
((metric('Test_Device', 'Temperature')-273) *9/5) + 32

Steps to configure:

  1. Name and Description
    Provide a name, e.g., "Temperature Conversion" and a description.

  2. Expression
    Use built-in functions like metric() and delta(). Refer to the Expression Functions section below for syntax details.

  3. Device ID and Metric Name
    Specify the target Device ID and a new or existing Metric Name.
    Using an existing metric will overwrite its value.

  4. Precision (Optional)
    Set a precision value for numerical results (0–4 decimal places).

  5. Finalize
    Click Add Transform to save.

Calculation Example
Calculation Transform Example

Translation Transforms

Translation Transforms evaluate conditions and assign meaningful values to metrics based on the results.

Example:

Map temperature readings into categories for better visualization.

Condition Value Value Data Type
metric('Test_Device', 'Temperature_F') < 45 "Cold" String
metric('Test_Device', 'Temperature_F') >= 45 && metric('Test_Device', 'Temperature_F') < 80 "Moderate" String
metric('Test_Device', 'Temperature_F') >= 80 "Temperature Over 80 F" String

Steps to configure:

  1. Name and Description
    E.g., "Temperature Status"

  2. Condition
    Enter an expression. Add additional translation transforms with exhaustive conditions to cover all possible cases. Refer to the Expression Functions section below for guidance.

  3. Value Data Type and Value
    Select the Value Data Type (e.g., String, Integer) and define the value assigned when the condition evaluates as true.

  4. Device ID and Metric Name
    Provide the target Device ID and a new Metric Name.

  5. Finalize
    Click Add Transform to save.

Translation Example
Translation Transform Example

Transform Functions Reference

The Transforms feature supports a wide range of functions to build powerful expressions. Below are the details:

Core Functions

1. metric()

Retrieves the current value of a metric from a specific node.

Syntax:
metric('nodeName', 'metricName')

Examples: - Temperature threshold check:
metric('sensor1', 'temperature') > 30 - Multiple condition check:
metric('sensor1', 'temperature') > 25 && metric('sensor1', 'humidity') < 80 - Exact value match:
metric('device1', 'status') == 1


2. delta()

Calculates the difference between the current and previous values of a metric.

Syntax:
delta('nodeName', 'metricName')

Examples: - Rate of change detection:
delta('sensor1', 'temperature') > 5 - Trend direction check:
delta('sensor1', 'counter') < 0


Built-in Helper Functions

String Functions:

  • contains(s, substr)
    Checks if a string contains a substring.
    contains(metric('device1', 'status'), "ERROR")

Math Functions:

  • abs(x)
    Returns the absolute value.
    abs(delta('sensor1', 'pressure')) > 10
  • ceil(x) / floor(x)
    Rounds numbers up or down.

Type Conversion Functions:

  • bool(x)
    Converts a value to boolean.
  • string(x)
    Converts a value to string.

Real-World Examples

Renewable Energy:
Calculate and monitor energy efficiency over time using Calculation Transforms.

Smart Home:
Convert sensor readings into user-friendly states like "Lights On/Off" or "Doors Locked/Unlocked" with Translation Transforms.

Industrial IoT:
Track machine utilization rates by calculating operating time versus idle time.

Tip

Use Calculation Transforms for numerical and data-driven calculations.
Use Translation Transforms to map raw data into actionable states or labels.


Ready to harness the power of Transforms? Start configuring your Calculation and Translation Transforms today!

Have a question?
Contact our support team: support@machinechat.io

Was this page helpful?