Configuration Value Conversion

更新时间:
复制 MD 格式

Use the Value Conversion node to transform a field value in a parsing task's flow message and assign the result to the original field or a new one. The converted data can then be used for downstream analysis or output.

Scenarios

  • Scenario 1: Convert value to the original field.

    A greenhouse uses sensors to report illuminance (lux). Although illuminance cannot be negative, sporadic negative readings may reach the IoT Platform and skew analysis results. You can use the value conversion node to replace such anomalous data with a default value. For example, convert negative illuminance (lux) readings to 0 to prevent logical errors in downstream processing.

  • Scenario 2: Convert value to a newly defined field.

    Temperature sensors report temperature (temperature) data to the IoT Platform. To classify temperature ranges into levels such as normal, alarm, and danger and trigger appropriate actions, use the value conversion node to create a new field, alert_level, that indicates the corresponding level.

Prerequisites

Ensure that data calculation expressions or data filtering filters are configured. For more information, see Configure data computing and data filtering.

Background information

Procedure

  1. Access the data parsing workbench.

  2. In the middle canvas, click the add image icon following the current node.

  3. From the ejected node list, single click the Value Conversion node.

  4. On the canvas, single click the Value Conversion node and set up the conversion parameters in the configuration panel on the right, as detailed in the table below.

    Configuration Item

    Description

    Conditional Field Name

    The field used for conditional evaluation, typically a numeric field. This field must be an output from the preceding node.

    The available fields are the output fields from the preceding node.

    Output Field Name

    The name of the output field produced by the value conversion node. The name can contain letters, digits, and underscores (_), cannot start with a digit, and cannot exceed 30 characters.

    Only letters, digits, and underscores (_) are supported. The name cannot start with a digit and cannot exceed 30 characters.

    Output Field Type

    Choose the data type for the output field: BIGINT, DOUBLE, or VARCHAR.

    Default Output Value When Not Matched

    The default value of the output field when no conditions are met.

    To output raw data, use ${Field Name}.

    Conditional Branch

    Configure the output value for each set of conditions. You can add multiple conditional branches, each with up to three AND conditions and a maximum of ten branches per node. Branches are evaluated in order, and the first match is used.

    1. Choose a Conditional Operator from the following options: = (equal), != (not equal), > (greater than), >= (greater than or equal), < (less than), <= (less than or equal), isNull (empty), or isNotNull (not empty).

    2. Enter the Conditional Value for the condition evaluation.

    3. (Optional) Click Add AND Condition to add and configure additional Conditional Operators and Conditional Values.

      Note
      • All conditions within a conditional branch are combined using an AND relationship.

      • A single conditional branch can include up to three AND conditions.

    4. Set the value of the output field when the branch conditions are met.

      IoT Platform validates the data type against the specified Output Field Type.

      To output the raw data of a field, use the syntax ${Field Name}.

    Click Add Conditional Branch to add more conditional branches.

    Note

    Within a value conversion node:

    • A maximum of 10 conditional branches is permitted.

    • The node evaluates conditional branches sequentially from top to bottom, executing the first successful match.

    The following example is based on Scenario 2 in the Scenarios section:

    This configuration checks the device operating temperature and assigns an alert level:

    • For 50<temperature<=80, set the alert level (alert_level) to alarm.

    • For temperature>80, set the alert level (alert_level) to danger.

    • For all other cases, set the alert level (alert_level) to normal.

    The value conversion node is equivalent to a SQL case when statement:

    select 
    case when temperature>50 and temperature<=80 then 'alarm'
         when temperature>80 then 'danger'
    else 'normal' end as alert_level
  5. To save your configuration, single click Save at the top right corner of the Data Parsing Workbench.

Important

The output fields of this node include both the newly configured output field and the fields from the preceding node.

What to do next

After configuring the value conversion node, configure other processing nodes or destination nodes to complete the parsing task. For more information, see Configure data computing and data filtering.