Platform Trigger (PLATFORM_TRIGGER)
Platform Trigger (PLATFORM_TRIGGER)
Overview
Platform trigger (triggerType = 0) is used to respond to data commands delivered by the IoT platform via MQTT. When the platform-delivered data matches the trigger conditions, the corresponding rule's action list is executed.
| Trigger | Input Source | Check Timing | Suitable Scenarios | Common Risks |
|---|---|---|---|---|
| Platform Trigger | MQTT / HTTP / Cloud commands | Match fields immediately upon message arrival | Remote on/off, parameter delivery, linkage control | Inconsistent field names, duplicate messageId, insufficient permissions |
| Timer Trigger | Local clock / cron / interval | Execute when time point is reached | Periodic reporting, scheduled on/off, night mode | NTP not synced, first trigger semantics unclear |
| Event Trigger | Button, sensor, system events | Match eventId when event is published | Button control, threshold alarm, state change | Debouncing, event name spelling, cached value expiry |
| Poll Trigger | Actively read peripheral or protocol data | Check conditions every pollInterval | Modbus collection, analog threshold, distance alarm | Too frequent, serial port busy, low memory frequency reduction |
Platform trigger only evaluates conditions when a platform message arrives; it does not actively read local sensors. If you need to read peripherals at a fixed frequency, use timer or poll trigger instead.
Trigger Mechanism
- Platform sends data command via MQTT:
[{"id":"xxx","value":"yyy"}] - System parses the
idandvaluefrom the command - Matches
triggerPeriphIdin the rule against theidin the delivered data - Evaluates conditions using
operatorTypeandcompareValue - If conditions are met, triggers rule execution
Field Description
| Field | Type | Description |
|---|---|---|
| triggerType | 0 | Platform trigger |
| triggerPeriphId | String | Data source peripheral ID (matches item.id in delivered data) |
| operatorType | uint8 | Condition operator (see table below) |
| compareValue | String | Comparison value |
Condition Operators
| Operator | Value | Description | Example |
|---|---|---|---|
| EQ | 0 | Equal | value == "1" |
| NEQ | 1 | Not equal | value != "0" |
| GT | 2 | Greater than | value > "30" |
| LT | 3 | Less than | value < "10" |
| GTE | 4 | Greater than or equal | value >= "50" |
| LTE | 5 | Less than or equal | value <= "100" |
| BETWEEN | 6 | Between | "20" <= value <= "80" |
| NOT_BETWEEN | 7 | Not between | value < "20" or value > "80" |
| CONTAIN | 8 | Contains | value contains "alarm" |
| NOT_CONTAIN | 9 | Not contains | value does not contain "ok" |
BETWEEN operator's compareValue format is
"min,max", e.g.,"20,80"
Configuration Examples
Method 1: Web Interface Configuration (Recommended)
The peripheral execution page is shown below. When configuring platform trigger, verify the MQTT/platform delivered content, comparison value, and target action to avoid accidental triggering of field peripherals.
Example 1: Exact Match (Equal)
Scenario: Trigger when platform sends [{"id":"gpio_button","value":"0"}]
Configuration Steps:
Click left menu Peripheral Configuration → Switch to Peripheral Execution Management tab
Click the Add Rule button
Fill in basic configuration:
- Rule Name:
Platform Button Trigger - Report Data: Enable as needed
- Enable: ✅ Enabled
- Rule Name:
Configure trigger:
- Trigger Type: Select Platform Trigger
- Target Peripheral ID: Enter
gpio_button(match the id in delivered data) - Operator: Select
Equal (=) - Compare Value: Enter
0
Configure actions (add as needed)
Click the Save button
Test Method: Send [{"id":"gpio_button","value":"0"}] via MQTT
Example 2: Threshold Evaluation (Greater Than)
Scenario: Trigger when temperature sensor reported value > 35
Configuration Steps:
- Create rule, name:
Temperature Exceedance Alarm - Trigger configuration:
- Trigger Type: Select Platform Trigger
- Target Peripheral ID: Enter
dht1 - Operator: Select
Greater Than (>) - Compare Value: Enter
35
- Configure actions: Add alarm-related actions
- Click Save
Test Method: Send [{"id":"dht1","value":"40"}] via MQTT
Example 3: Range Evaluation
Scenario: Trigger when humidity value is within 20~80 range
Configuration Steps:
- Create rule, name:
Humidity Normal Range - Trigger configuration:
- Trigger Type: Select Platform Trigger
- Target Peripheral ID: Enter
humidity - Operator: Select
Between (BETWEEN) - Compare Value: Enter
20,80(format: min,max)
- Configure actions
- Click Save
Test Method: Send [{"id":"humidity","value":"50"}] via MQTT
Method 2: JSON Configuration File Import
Complete Rule Example
Platform sends restart command to trigger system restart:
{
"id": "exec_platform_restart",
"name": "Platform Remote Restart",
"enabled": false,
"execMode": 0,
"triggers": [
{
"triggerType": 0,
"triggerPeriphId": "sys_restart",
"operatorType": 0,
"compareValue": "1",
"timerMode": 0,
"intervalSec": 60,
"timePoint": "",
"eventId": "",
"pollResponseTimeout": 1000,
"pollMaxRetries": 2,
"pollInterPollDelay": 100
}
],
"actions": [
{
"targetPeriphId": "",
"actionType": 6,
"actionValue": "",
"useReceivedValue": false,
"syncDelayMs": 500,
"execMode": 0
}
],
"protocolType": 0,
"scriptContent": "",
"reportAfterExec": false
}Precautions
- ID Matching:
triggerPeriphIdmust precisely match theidfield in platform-delivered data - Numeric Comparison: compareValue is parsed as a float for numeric comparison
- String Comparison: CONTAIN/NOT_CONTAIN perform substring matching
- handleDataCommand: Platform trigger is processed via
handleDataCommandmethod, executes synchronously and returns immediately
