The Value Conversion node allows you to transform a field in the flow message of a parsing task into a different value, which can then be assigned to either the original field or a new one. This transformation facilitates diverse data generation for further analysis or output.
Scenarios
Scenario 1: Convert value to the original field.
A greenhouse employs sensors to monitor illuminance (lux). While illuminance inherently cannot be negative, sporadic negative readings may be transmitted to the IoT Platform, which can significantly skew data analysis outcomes. To address this, the value conversion node can be utilized to transform any aberrant data into a predetermined default value. For instance, negative illuminance (lux) readings can be converted to the default value of 0, streamlining further data utilization and preventing logical discrepancies.
Scenario 2: Convert value to a newly defined field.
To ensure a device operates within its designated temperature (temperature) range and to prevent faults, temperature sensors transmit temperature (temperature) data to the IoT Platform. For categorizing temperature ranges into levels such as normal, alarm, and danger, and to initiate appropriate actions based on these classifications, employ the value conversion node to introduce a new field, alert_level, which indicates the respective level.
Prerequisites
Ensure that data calculation expressions or data filtering filters are set up. For more information, see Configure data computing and data filtering.
Background information
For an overview of the data parsing feature, refer to Usage Notes.
For guidance on navigating the data parsing workspace, see Data Parsing Workspace Instructions.
Procedure
In the middle canvas, click the add
icon following the current node.From the ejected node list, single click the Value Conversion node.
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
Identify the field for conditional evaluation, typically a numeric field. This field should be an output from the preceding node.
The fields available for selection are the output fields from the preceding node.
Output Field Name
Define the name for the output field produced by the value conversion node. This name can include numbers, letters, and underscores, must not begin with a number, and should not exceed 30 characters in length.
Supports only numbers, letters, and underscores; must not begin with a number; and the length must not exceed 30 characters.
Output Field Type
Choose the data type for the output field: BIGINT, DOUBLE, or VARCHAR.
Default Output Value When Not Matched
Define the default output field value for instances when no conditions of the value conversion node are met.
To output raw data, utilize
${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. The system evaluates branches in sequence and uses the first match.
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).
Input the desired Conditional Value for the condition evaluation.
(Optional) Click Add AND Condition to add and configure additional Conditional Operators and Conditional Values.
NoteAll conditions within a conditional branch are combined using an AND relationship.
A single conditional branch can include up to three AND conditions.
Define the output field's value for when the branch conditions are met.
The IoT Platform will verify the data type based on the specified Output Field Type.
To output the raw data of a field, use the syntax
${Field Name}.
Simply Add Conditional Branch with a single click to set up multiple conditional branches.
NoteWithin 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.
Refer to the configuration example below, which is based on "Scenario 2" from the Scenarios section:
This configuration determines the operating temperature range of the device and assigns different alert levels accordingly:
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 can be likened to a SQL
case whenstatement, as shown below:select case when temperature>50 and temperature<=80 then 'alarm' when temperature>80 then 'danger' else 'normal' end as alert_levelTo save your configuration, single click Save at the top right corner of the Data Parsing Workbench.
The node's output fields include both the newly configured output field names and those from the previous node.
What to do next
After setting up the value conversion node, proceed to configure other processing nodes or target nodes to finalize the parsing task configuration. For more information, see Configure data computing and data filtering.