Event and Rule Control Actions
Event and Rule Control Actions
Action Types
| Action | actionType | Description |
|---|---|---|
| ACTION_TRIGGER_EVENT | 21 | Trigger device event |
| ACTION_ENABLE_EXEC_RULE | 22 | Enable specified rule |
| ACTION_DISABLE_EXEC_RULE | 23 | Disable specified rule |
Configuration Examples
Method 1: Web Interface Configuration (Recommended)
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:
Edit the rule in the Peripheral Execution Management page
Click the Add Action button
Fill in the action configuration:
Field Value Description Action Type Select Trigger Event Trigger device event Event ID Enter evt_alarmCustom event ID Event Data Enter High Temperature AlarmOptional, data carried by the event 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:
Edit the rule, add an action
Fill in:
- Action Type: Select Enable Rule
- Target Rule ID: Enter
exec_temp_ctrl
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:
Edit the rule, add an action
Fill in:
- Action Type: Select Disable Rule
- Target Rule ID: Enter the rule ID to disable
Click Save
💡 Tip: enable/disable operations are persisted to periph_exec.json
Application Scenarios
Scenario 1: Button Toggle Rule Enable State
Steps:
- Create a rule, name:
Toggle Temp Control - Trigger: Event trigger →
button_click→ targetbtn1 - Action: Select Enable Rule → target
exec_temp_ctrl - Save
💡 Tip: You can create two rules, single-click to enable, double-click to disable
Scenario 2: Chained Linkage (Rule A → Rule B)
Steps:
Rule A Configuration:
- Action 1: Execute main logic
- Action 2: Select Trigger Event → Event ID filled with Rule A's own ID
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
- Circular Protection: Avoid A enables B → B enables A circular dependencies
- Event Deduplication: The same event will not trigger repeatedly within 500ms
- Rule ID: targetPeriphId must be an existing rule ID (format:
exec_XXXXXXX) - Persistence: enable/disable operations are persisted to periph_exec.json
