Skip to main content

Data Conversion

note

Screenshots in this guide may look slightly different from what you see on your device. Please follow the actual interface for reference.

Overview

When two blocks are connected but their output and input data types don't match, Aqara Studio automatically inserts a data conversion block. With this feature, you can easily define the final form of data in your automation workflow without any additional operations. For example, converting the number 1 to the string "1.0", or mapping the boolean value false to a more intuitive string like "Device is offline".

Data conversion illustration

This flexible data conversion capability allows you to seamlessly perform mathematical calculations, logical operations, and text concatenation, while connecting various point data blocks. This enables raw data to naturally integrate into various logic, helping you to freely customize your workflows.

This document explains the conversion rules for different parameter types.

Boolean to Other Types

Boolean to Enumeration

Boolean to enumeration

To convert from a boolean value to an enumeration value, you need to set the mapping rule in the Data Conversion block:

  • Truthy Value: Select the target enumeration value when the input is true.
  • Falsy Value: Select the target enumeration value when the input is false.

Boolean to Number

Boolean to number

To convert from a boolean value to a number, you need to set the mapping rule in the Data Conversion block:

  • Truthy Value: Set the target number when the input is true.
  • Falsy Value: Select the target number when the input is false.

Boolean to String

Boolean to string

To convert from a boolean value to a string, you need to set the mapping rule in the Data Conversion block:

  • Truthy Value: Select the target string when the input is true.
  • Falsy Value: Select the target string when the input is false.

Enumeration to Other Types

Enumeration to Boolean

Enumeration to boolean

You need to specify an enumeration value as false to complete the conversion:

  • Falsy Value: If the input enumeration value matches the configured value, the output is false. Otherwise, the output is true.

Enumeration to Number

Enumeration to number

When an enumeration block is connected to a number block, the number block directly obtains the numerical value of the input enumeration. For example, an enumeration value with index 0 corresponds to the number 0.

Enumeration to String

Enumeration to string

When an enumeration block is connected to a string block, the string block directly obtains the name of the input enumeration value. As shown in the figure, the string variable directly displays the device's current mode, which is "Low".

Number to Other Types

Number to Boolean

Number to boolean

You need to specify an number as false to complete the conversion:

  • Falsy Value: If the input number matches the configured number, the output is false. Otherwise, the output is true.

Number to Enumeration

Number to enumeration

When a number block is connected to an enumeration block, the input number is converted to the corresponding enumeration value based on preset mapping relationships. For example, the number 0 corresponds to the enumeration value with index 0.

Number to String

Number to string

When a number block is connected to a string block, you need to specify a "format" string. This format determines whether the final string includes decimal places, thousands separators, or other symbols.

Basic Format Symbols

SymbolMeaningExample PatternNumber (Before)String (After)
0Digit placeholder. Pads with zeros if there are not enough digits.000123123
5005
#Digit placeholder. Shows digits only if present (no zero padding).###123123
55
.Decimal point separator.0.003.141593.14
,Thousands separator.#,###12341,234
%Converts the number to a percentage.0%0.1515%
EScientific notation format.0.00E0012341.23E03

Examples

Basic Number
FormatDescriptionNumber (Before)String (After)
0Integer123.7124
0.0One decimal place123.7123.7
0.00Two decimal places123.7123.70
0.000Three decimal places123.7123.700
Basic number format example
Flexible Decimal Places
FormatDescriptionNumber (Before)String (After)
#Rounds to integer (no zero padding)123.7124
#.#Formats with up to 1 decimal123.7123.7
123.0123
#.##Formats with up to 2 decimals123.7123.7
123.00123
Flexible digit example
Thousands Separator
FormatDescriptionNumber (Before)String (After)
#,###Thousands separator12341,234
#,###.00Thousands separator + 2 decimals1234.51,234.50
Thousand Place example
Percentage
FormatDescriptionNumber (Before)String (After)
0%Percentage0.1515%
0.0%One decimal percentage0.1515.0%
Percentage Example
Scientific Notation
FormatDescriptionNumber (Before)String (After)
0.00E00Scientific notation12341.23E03
Scientific notation example
Currency Format
FormatDescriptionNumber (Before)String (After)
¥#,###.00Chinese Yuan format1234.5¥1,234.50
$#,###.00US Dollar format1234.5$1,234.50
Currency example

String to Other Types

String to Boolean

String to boolean

To convert from a string to a boolean value, you need to set the mapping rule in the Data Conversion block:

  • Falsy Value: Specify which input value should output false.
  • Truthy Value: Specify which input value should output true.

String to Number

String to number

You simply need to connect a numeric string block to a number block, and the system will automatically convert it to a number type without any additional configuration.