Skip to content

Event and Rule Control Actions ​

Action Types ​

ActionactionTypeDescription
ACTION_TRIGGER_EVENT21Trigger device event
ACTION_ENABLE_EXEC_RULE22Enable specified rule
ACTION_DISABLE_EXEC_RULE23Disable specified rule

Configuration Examples ​

The peripheral execution page is shown below. When configuring event actions, verify the event ID, target rule, and whether circular triggers may occur.

Example 1: Trigger Device Event (Chained Linkage) ​

Scenario: Trigger a custom event for other rules to subscribe to

Configuration Steps:

  1. Edit the rule in the Peripheral Execution Management page

  2. Click the Add Action button

  3. Fill in the action configuration:

    FieldValueDescription
    Action TypeSelect Trigger EventTrigger device event
    Event IDEnter evt_alarmCustom event ID
    Event DataEnter High Temperature AlarmOptional, data carried by the event
  4. Click the Save button

💡 Tip:

  • Other rules can subscribe to this event via event trigger
  • When "Report Data" is enabled, the event will be reported via MQTT DEVICE_EVENT topic

Example 2: Enable Specified Rule ​

Scenario: Dynamically enable the temperature control rule exec_temp_ctrl

Configuration Steps:

  1. Edit the rule, add an action

  2. Fill in:

    • Action Type: Select Enable Rule
    • Target Rule ID: Enter exec_temp_ctrl
  3. Click Save

💡 Tip: targetPeriphId must be an existing rule ID (format: exec_XXXXXXX)


Example 3: Disable Specified Rule ​

Scenario: Dynamically disable a specified rule

Configuration Steps:

  1. Edit the rule, add an action

  2. Fill in:

    • Action Type: Select Disable Rule
    • Target Rule ID: Enter the rule ID to disable
  3. Click Save

💡 Tip: enable/disable operations are persisted to periph_exec.json


Application Scenarios ​

Scenario 1: Button Toggle Rule Enable State ​

Steps:

  1. Create a rule, name: Toggle Temp Control
  2. Trigger: Event trigger → button_click → target btn1
  3. Action: Select Enable Rule → target exec_temp_ctrl
  4. Save

💡 Tip: You can create two rules, single-click to enable, double-click to disable


Scenario 2: Chained Linkage (Rule A → Rule B) ​

Steps:

  1. Rule A Configuration:

    • Action 1: Execute main logic
    • Action 2: Select Trigger Event → Event ID filled with Rule A's own ID
  2. Rule B Configuration:

    • Trigger: Event trigger → Event ID filled with Rule A's ID
    • Action: Execute subsequent logic

💡 Tip: Avoid creating circular triggers such as A→B→A


Method 2: JSON Configuration File Import ​

Precautions ​

  1. Circular Protection: Avoid A enables B → B enables A circular dependencies
  2. Event Deduplication: The same event will not trigger repeatedly within 500ms
  3. Rule ID: targetPeriphId must be an existing rule ID (format: exec_XXXXXXX)
  4. Persistence: enable/disable operations are persisted to periph_exec.json

FastBee | fastbee.cn