Peripheral Execution Management
1. Overview
Peripheral Execution (Periph-Exec) is the automation rule engine of the FastBee system, achieving device linkage by configuring Triggers and Actions. Configuration is stored in /config/periph_exec.json.
Factory default rules are all enabled: false, not auto-executing in unknown wiring environments. After adding or importing rules, save as disabled first, confirm target peripheral, pin and action parameters are correct before enabling.
Rule list is for quick verification of triggers, action count, enabled status and manual execution entry. When adding or editing rules, first confirm target peripheral exists and is in expected enabled state.
The diagram maps "triggers, rules, actions, execution results" in the page to the runtime chain. When configuring in the field, prioritize making each rule name readable, trigger condition single and clear, action sequence rollbackable.
When adding rules, follow the lifecycle diagram: disabled save, validate params, manual execute, enable run, abnormal rollback. This prevents driving field loads immediately after saving in unknown wiring environments.
2. Web Interface Operation Guide
2.1 View Rule List
Rule list displays:
| Field | Description |
|---|---|
| Name | Rule display name |
| Status | Enabled / Disabled |
| Trigger | Trigger type (Timer, Event, Platform, Poll) |
| Actions | Action count |
| Trigger Count | Number of times triggered |
| Operations | Execute Once / Edit / Enable / Delete |
2.2 Add Rule
- Click + Add Rule button
- Fill in rule name
- Select trigger type and configure trigger parameters
- Add actions (one or more)
- Save rule
2.3 Edit Rule
- Find target rule in list
- Click Edit button
- Modify trigger or actions
- Save changes
2.4 Execute Once
- Find target rule in list
- Click Execute Once button
- View execution log
Note: Execute once does not depend on rule enabled status, convenient for debugging.
2.5 Enable/Disable Rule
- Enable: Rule joins scheduler, auto-triggers when conditions met
- Disable: Rule leaves scheduler, no longer auto-triggers
2.6 Delete Rule
- Find target rule in list
- Click Delete button
- Confirm deletion
2.7 Backup and Restore
The current Peripheral Exec page operates on one rule at a time. To back up or restore periph_exec.json, use Device Configuration > Advanced Configuration > Configuration Import/Export. The page does not provide batch enable/disable controls.
3. Trigger Types
Trigger objects use the flat fields below. A rule may contain up to three triggers; they have OR semantics.
triggerType | Trigger | Main fields |
|---|---|---|
0 | Platform | triggerPeriphId, operatorType, compareValue |
1 | Timer | timerMode, intervalSec, timePoint |
4 | Event | eventId, operatorType, compareValue |
5 | Poll | triggerPeriphId, operatorType, compareValue, intervalSec, poll timeout/retry fields |
3.1 Platform Trigger (triggerType=0)
Matches values received from the platform. Set operatorType=1 when the received value should be passed directly to an action.
{
"triggerType": 0,
"triggerPeriphId": "relay_1",
"operatorType": 0,
"compareValue": "on"
}3.2 Timer Trigger (triggerType=1)
timerMode=0 runs at an interval in seconds; timerMode=1 runs once each day at HH:MM.
{
"triggerType": 1,
"timerMode": 0,
"intervalSec": 60
}{
"triggerType": 1,
"timerMode": 1,
"timePoint": "08:30"
}3.3 Event Trigger (triggerType=4)
Uses a static or dynamic event ID returned by the event-list APIs. Conditions are optional when the event ID alone is sufficient.
{
"triggerType": 4,
"eventId": "wifi_connected",
"operatorType": 0,
"compareValue": ""
}3.4 Poll Trigger (triggerType=5)
Actively reads a peripheral and evaluates the returned value. intervalSec is in seconds; timeout and inter-poll delay are in milliseconds.
{
"triggerType": 5,
"triggerPeriphId": "dht_temp",
"operatorType": 2,
"compareValue": "35",
"intervalSec": 5,
"pollResponseTimeout": 1000,
"pollMaxRetries": 2,
"pollInterPollDelay": 100
}operatorType values are 0 equal, 1 not equal, 2 greater than, 3 less than, 4 greater than or equal, 5 less than or equal, 6 inside range, 7 outside range, 8 contains and 9 does not contain.
4. Action Types
Actions also use a flat structure. targetPeriphId identifies the target, actionType selects the operation, actionValue carries its parameter, and syncDelayMs delays that action by up to 10 seconds.
{
"targetPeriphId": "relay_1",
"actionType": 0,
"actionValue": "",
"useReceivedValue": false,
"syncDelayMs": 0,
"execMode": 0
}Common action types include GPIO high/low (0/1), blink (2), PWM (4), system restart (6), generic peripheral command (10), NeoPixel effect (11), command script (15), Modbus coil/register write (16/17), Modbus poll (18), sensor read (19), event emission (21), display (24-27) and UART send (29). The Web page filters actions by active feature and target peripheral type.
5. Configuration File Format
All execution rules stored in /config/periph_exec.json:
{
"rules": [
{
"id": "rule_001",
"name": "Temperature Alarm",
"enabled": false,
"execMode": 0,
"triggers": [
{
"triggerType": 5,
"triggerPeriphId": "dht_temp",
"operatorType": 2,
"compareValue": "35",
"intervalSec": 5,
"pollResponseTimeout": 1000,
"pollMaxRetries": 2,
"pollInterPollDelay": 100
}
],
"actions": [
{
"targetPeriphId": "relay_fan",
"actionType": 0,
"actionValue": "",
"useReceivedValue": false,
"syncDelayMs": 0,
"execMode": 0
}
],
"protocolType": 0,
"scriptContent": "",
"reportAfterExec": true
}
]
}6. Runtime Availability
Peripheral Exec is compiled in the release baseline. Timer, event, platform and poll triggers share the same rule engine. An action is shown and accepted only when its dependency is active: display actions require the display feature, Modbus actions require modbus, scripts require ruleScript/commandScript, and MQTT actions require mqtt. Check /api/features/status on the target device.
7. Troubleshooting
| Issue | Possible Cause | Solution |
|---|---|---|
| Rule not triggering | Trigger condition not met | Check trigger type and parameters, confirm source peripheral working |
| Action not executing | Target peripheral disabled | Enable target peripheral |
| Script execution error | Syntax error | Check script syntax, refer to Rule Script documentation |
| Modbus action timeout | Communication failure | Check Modbus wiring, baud rate, slave address |
| Rule execution too slow | Too many actions | Reduce action count, use async execution |
| Trigger count not increasing | Scheduler not running | Confirm at least one rule enabled |
| Import config failed | JSON format error | Check JSON syntax, ensure field types correct |
| MQTT action not sending | MQTT not connected | Check MQTT connection status |
8. Related Documentation
- Peripheral Configuration - Peripheral hardware configuration
- Rule Script - Script syntax and built-in functions
- Protocol Configuration - MQTT and Modbus protocol settings

