Skip to content

Event Trigger (EVENT_TRIGGER) ​

Overview ​

TriggerInput SourceCheck TimingSuitable ScenariosCommon Risks
Platform TriggerMQTT platform commandMatch fields immediately upon message arrivalRemote on/off, parameter delivery, linkage controlInconsistent field names, duplicate messageId, insufficient permissions
Timer TriggerLocal clock / cron / intervalExecute when time point is reachedPeriodic reporting, scheduled on/off, night modeNTP not synced, first trigger semantics unclear
Event TriggerButton, sensor, system eventsMatch eventId when event is publishedButton control, threshold alarm, state changeDebouncing, event name spelling, cached value expiry
Poll TriggerActively read peripheral or protocol dataCheck conditions every pollIntervalModbus collection, analog threshold, distance alarmToo 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 ​

FieldTypeDescription
triggerType4Event trigger
eventIdStringEvent ID (matches STATIC_EVENTS or dynamic rule ID)
triggerPeriphIdStringEvent source peripheral ID (specify specific button for button events; empty matches any)

Available System Event List ​

WiFi Events ​

eventIdDescription
wifi_connectedWiFi connected successfully
wifi_disconnectedWiFi disconnected
wifi_conn_failedWiFi connection failed

MQTT Events ​

eventIdDescription
mqtt_connectedMQTT connected successfully
mqtt_disconnectedMQTT disconnected
mqtt_conn_failedMQTT connection failed
mqtt_enabledMQTT protocol enabled

System Events ​

eventIdDescription
ntp_syncedNTP time sync completed
ota_startOTA upgrade started
ota_successOTA upgrade succeeded
ota_failedOTA upgrade failed
system_bootSystem boot
system_readySystem ready

Button Events ​

eventIdDescription
button_clickButton single click
button_double_clickButton double click
button_long_press_2sButton long press 2 seconds
button_long_press_5sButton long press 5 seconds
button_long_press_10sButton long press 10 seconds
button_pressButton press
button_releaseButton release

Data Events ​

eventIdDescription
data_receiveData received (protocol data arrived)
data_reportData reported (protocol data sent)

Peripheral Execution Events ​

eventIdDescription
periph_exec_completedPeripheral execution rule completed
(Rule ID)Specified rule execution completed (for chained linkage)

Configuration Examples ​

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:

  1. Click Peripheral Execution in the left menu

  2. Click the Add Rule button

  3. Fill in basic configuration:

    • Rule Name: Execute After WiFi Connected
    • Report Data: Enable as needed
    • Enable: ✅ Enabled
  4. Configure trigger:

    • Trigger Type: Select Event Trigger
    • Event ID: Select wifi_connected (WiFi connected successfully)
  5. Configure actions: Add actions to execute

  6. Click the Save button


Example 2: Button Single Click Trigger (Specific Button) ​

Scenario: Trigger when specific button btn1 is single-clicked

Configuration Steps:

  1. Create rule, name: Button Click Action

  2. Trigger configuration:

    • Trigger Type: Select Event Trigger
    • Event ID: Select button_click (button single click)
    • Target Peripheral ID: Enter btn1 (specify button)
  3. Configure actions

  4. 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:

  1. Create rule, name: Any Button Click

  2. Trigger configuration:

    • Trigger Type: Select Event Trigger
    • Event ID: Select button_click
    • Target Peripheral ID: Leave empty (matches any button)
  3. Configure actions

  4. 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:

  1. Create Rule B, name: Rule B - Chained Trigger

  2. Trigger 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
  3. Configure actions

  4. 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 ​

  1. Deduplication Interval: Minimum trigger interval for the same event is 1 second, preventing rapid repeated triggering
  2. Button Peripheral ID: When triggerPeriphId is empty, matches any button event; when specified, only that button triggers
  3. NTP Prerequisite: Some events (e.g., ntp_synced) only trigger under specific conditions
  4. Chain Loops: Avoid Rule A→B→A forming infinite loops
  5. Boot Sequence: system_boot fires after PeriphExecManager initialization is complete

FastBee | fastbee.cn