Event Trigger (EVENT_TRIGGER)
Event Trigger (EVENT_TRIGGER)
Overview
| 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 |
Event trigger is suitable for events already generated by button state machines, sensor caches, system status, or other rules. It does not actively collect data; instead, it evaluates conditions and executes actions when events appear.
Event trigger (triggerType = 4) is used to respond to internal system events. When a specified event occurs, the rule is automatically executed. Supports system events (WiFi/MQTT/NTP/button etc.) and custom events (peripheral execution completed/device events).
When configuring event trigger, first confirm that the event source produces a clear eventId, then configure triggerPeriphId and actions; if the rule is not triggering, check the event name in the logs first.
Field Description
| Field | Type | Description |
|---|---|---|
| triggerType | 4 | Event trigger |
| eventId | String | Event ID (matches STATIC_EVENTS or dynamic rule ID) |
| triggerPeriphId | String | Event source peripheral ID (specify specific button for button events; empty matches any) |
Available System Event List
WiFi Events
| eventId | Description |
|---|---|
| wifi_connected | WiFi connected successfully |
| wifi_disconnected | WiFi disconnected |
| wifi_conn_failed | WiFi connection failed |
MQTT Events
| eventId | Description |
|---|---|
| mqtt_connected | MQTT connected successfully |
| mqtt_disconnected | MQTT disconnected |
| mqtt_conn_failed | MQTT connection failed |
| mqtt_enabled | MQTT protocol enabled |
System Events
| eventId | Description |
|---|---|
| ntp_synced | NTP time sync completed |
| ota_start | OTA upgrade started |
| ota_success | OTA upgrade succeeded |
| ota_failed | OTA upgrade failed |
| system_boot | System boot |
| system_ready | System ready |
Button Events
| eventId | Description |
|---|---|
| button_click | Button single click |
| button_double_click | Button double click |
| button_long_press_2s | Button long press 2 seconds |
| button_long_press_5s | Button long press 5 seconds |
| button_long_press_10s | Button long press 10 seconds |
| button_press | Button press |
| button_release | Button release |
Data Events
| eventId | Description |
|---|---|
| data_receive | Data received (protocol data arrived) |
| data_report | Data reported (protocol data sent) |
Peripheral Execution Events
| eventId | Description |
|---|---|
| periph_exec_completed | Peripheral execution rule completed |
| (Rule ID) | Specified rule execution completed (for chained linkage) |
Configuration Examples
Method 1: Web Interface Configuration (Recommended)
The peripheral execution page is shown below. When configuring event trigger, verify the event ID, comparison conditions, and whether the data source has been produced by peripheral actions.
Example 1: Trigger on WiFi Connection Success
Scenario: Execute certain actions after WiFi connects successfully
Configuration Steps:
Click left menu Peripheral Configuration → Switch to Peripheral Execution Management tab
Click the Add Rule button
Fill in basic configuration:
- Rule Name:
Execute After WiFi Connected - Report Data: Enable as needed
- Enable: ✅ Enabled
- Rule Name:
Configure trigger:
- Trigger Type: Select Event Trigger
- Event ID: Select
wifi_connected(WiFi connected successfully)
Configure actions: Add actions to execute
Click the Save button
Example 2: Button Single Click Trigger (Specific Button)
Scenario: Trigger when specific button btn1 is single-clicked
Configuration Steps:
Create rule, name:
Button Click ActionTrigger configuration:
- Trigger Type: Select Event Trigger
- Event ID: Select
button_click(button single click) - Target Peripheral ID: Enter
btn1(specify button)
Configure actions
Click Save
💡 Tip: When triggerPeriphId is specified, only that button will trigger the rule
Example 3: Button Single Click Trigger (Any Button)
Scenario: Trigger on any button single click
Configuration Steps:
Create rule, name:
Any Button ClickTrigger configuration:
- Trigger Type: Select Event Trigger
- Event ID: Select
button_click - Target Peripheral ID: Leave empty (matches any button)
Configure actions
Click Save
Example 4: Chained Linkage (Rule A Completion Triggers Rule B)
Scenario: Rule B is automatically triggered after Rule A completes execution
Configuration Steps:
Create Rule B, name:
Rule B - Chained TriggerTrigger configuration:
- Trigger Type: Select Event Trigger
- Event ID: Enter Rule A's ID (e.g.,
exec_1234567) - Note: Copy from Rule A's ID input field
Configure actions
Click Save
💡 Tip:
- Rule ID format is
exec_XXXXXXX- Avoid creating circular triggers such as A→B→A
- Rule IDs can be found in the rule list
Method 2: JSON Configuration File Import
Precautions
- Deduplication Interval: Minimum trigger interval for the same event is 1 second, preventing rapid repeated triggering
- Button Peripheral ID: When
triggerPeriphIdis empty, matches any button event; when specified, only that button triggers - NTP Prerequisite: Some events (e.g., ntp_synced) only trigger under specific conditions
- Chain Loops: Avoid Rule A→B→A forming infinite loops
- Boot Sequence: system_boot fires after PeriphExecManager initialization is complete
