The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.
When communication is performed based on a topic, you can use the rule engine to process the data in the topic and then forward it to other Tencent Cloud services or your business backend services, implementing services such as data acquisition, computing, and storage.
Step
1. Log in to the Internet of Things Hub console and click View details on the upper right of the Overview module.
2. Select the Rule Engine from the left menu.
3. On the rule engine page, click Create Rule, enter the rule name, and click Confirm.
Rule name: Supports combinations of letters, digits, and underscores, with a maximum of 32 characters. (The name cannot be modified after creation, please fill it in carefully.)
Rule Description: 0–256 characters. This can be modified.
4. After the rule is created successfully, you will be automatically redirected to the rule details page to edit data filtering and behavior operations.
Report filter: By selecting equipment, topic type, and setting the required extract content field and condition, generate the SQL statements for data extraction.
Field
Condition
JSON data reported by equipment supports extracting data content through fields, with multiple fields separated by commas. If all fields need to be forwarded, enter '*'. For non-json data reported by equipment, only '*' can be entered to forward all content. The field definitions are as follows:
Only '*', ',', '.', spaces, letters, and numbers are supported in the field. It cannot be empty and must not exceed 300 characters.
The field represents the key in JSON. If the data format is non-JSON, field filtering cannot be used. You can use '*' to forward all data.
The reported JSON data format can be nested JSON. For example: {"device_status":{"switch":"on"}}, you can get the value of switch through device_status.switch.
SQL and JSON subarrays are not supported.
Supported only when the device reports JSON data. Fill in the field (this field must be in the JSON data reported by the device) calculation expression in the condition. Data will be extracted and forwarded only when the message reported by the device meets the condition expression. Supported expressions are shown in the table below:
Operator
Description
Example
=
Equal to
color = 'red'
<>
Not equal to
color <> 'red'
AND
Logical AND
color = 'red' AND siren = 'on'
OR
Logical OR
color = 'red' OR siren = 'on'
( )
The content in the parentheses is a complete entity
color = 'red' AND (siren = 'on' OR siren ='isTest')
+
Arithmetic addition
age = 4 + 5
-
Arithmetic subtraction
age = 5 - 4
/
Remove
age = 20 / 4
*
Multiply
age = 5 * 4
%
Modulo
age = 0 % 6
<
Less than
5 < 6
<=
Less than or equal to
5 <= 6
>
Greater than
6 > 5
>=
Greater than or equal to
6 >= 5
Behavior operation: Used to configure the target for receiving data, supporting the following behavior types:
Action for forwarding error: By configuring a different behavior type from the behavior operation, if the behavior operation fails to forward after three retries, it will forward once to the error action to ensure no loss of device data.