PeriphExec Documentation
PeriphExec Documentation
Overview: PeriphExec is a trigger-action rule engine implementing "execute an action when a condition is met." It supports 4 trigger types (platform/timer/event/polling) and 27 action types (GPIO/PWM/sensor/display/system etc.). Rules run asynchronously with a pre-created Worker pool of 3 tasks and a minimum heap gate of 30 KB. Configuration is stored in
/config/periph_exec.json.
Factory data/config/periph_exec.json defaults all rules to disabled to prevent auto-driving peripherals with unknown wiring. After importing examples or creating rules, confirm target peripherals exist and pins are verified before enabling. Lite/Standard filesystem generation filters actions unsupported by the current tier or referencing removed peripherals.
This directory contains module-level documentation organized by trigger, action, and complete scenarios.

The rule list shows each rule's enabled state, trigger count, action count, and manual execution entry. On first field deployment, validate each rule individually before enabling.
The two diagrams above are a good starting point: the data model shows what fields compose a rule, and the timing comparison explains when to choose platform, timer, event, or polling triggers.
Document Index
Trigger Documentation
| Document | triggerType | Description |
|---|---|---|
| platform-trigger.md | 0 | Platform trigger (MQTT/Modbus command dispatch) |
| timer-trigger.md | 1 | Timer trigger (interval / daily time point) |
| event-trigger.md | 4 | Event trigger (system/button/data/peripheral events) |
| poll-trigger.md | 5 | Polling trigger (local data source condition evaluation) |
Action Documentation
| Document | actionType | Description |
|---|---|---|
| gpio-actions.md | 0,1,13,14 | GPIO output (high/low/inverted) |
| pwm-actions.md | 2,3,4,5 | PWM / breathing light / DAC |
| system-actions.md | 6,7,8,9 | System reboot / factory reset / NTP / OTA |
| modbus-actions.md | 16,17,18 | Modbus coil / register / polling |
| sensor-actions.md | 19 | Sensor data read |
| display-actions.md | 24,25,26,27 | Digital tube / OLED display |
| event-actions.md | 21,22,23 | Trigger event / rule control |
| script-actions.md | 10,15 | Call peripheral / command script |
Complete Scenario Documentation
| Document | Scenario | Modules Involved |
|---|---|---|
| temperature-alarm.md | DHT temperature control + relay | DHT11/22 + Relay |
| smoke-alarm.md | Smoke alarm + buzzer | MQ-2 + Buzzer + MQTT |
| light-control.md | Auto light control | Photoresistor ADC + LED/Relay |
| button-control.md | Button multi-mode control | Button + Multi-action |
| modbus-monitor.md | Modbus device monitoring | Modbus sub-device + Alarm |
| ultrasonic-alarm.md | Ultrasonic distance alarm | HC-SR04 + Buzzer |
Quick Start
Rule Structure
{
"id": "exec_<timestamp>",
"name": "Rule Name",
"enabled": true,
"execMode": 0,
"triggers": [ /* Trigger array, OR relationship */ ],
"actions": [ /* Action array, sequential execution */ ],
"reportAfterExec": true
}Trigger Type Quick Reference
| triggerType | Name | Typical Use |
|---|---|---|
| 0 | Platform Trigger | IoT platform MQTT command matching |
| 1 | Timer Trigger | Periodic collection, scheduled control |
| 4 | Event Trigger | WiFi/MQTT/button/sensor data events |
| 5 | Polling Trigger | Modbus sensor periodic data condition evaluation |
Action Type Quick Reference
| actionType | Name | Parameters |
|---|---|---|
| 0 | High Level | targetPeriphId = GPIO peripheral ID |
| 1 | Low Level | targetPeriphId = GPIO peripheral ID |
| 2 | Blink | actionValue = interval in ms |
| 3 | Breathing | actionValue = period in ms |
| 4 | Set PWM | actionValue = duty cycle value |
| 5 | Set DAC | actionValue = 0~255 |
| 6 | System Reboot | No parameters |
| 7 | Factory Reset | No parameters |
| 8 | NTP Sync | No parameters |
| 9 | OTA Upgrade | actionValue = URL |
| 10 | Call Peripheral | targetPeriphId = target peripheral |
| 13 | High (Inverted) | Physical output low |
| 14 | Low (Inverted) | Physical output high |
| 15 | Command Script | actionValue = script content |
| 16 | Modbus Coil | FC05 |
| 17 | Modbus Register | FC06 |
| 18 | Modbus Polling | Collect sub-device data |
| 19 | Sensor Read | Collect temp/humidity/distance/current/voltage |
| 21 | Trigger Event | actionValue = event ID |
| 22 | Enable Rule | targetPeriphId = rule ID |
| 23 | Disable Rule | targetPeriphId = rule ID |
| 24 | Display Number | actionValue = "12.34" |
| 25 | Display Text | actionValue = "PLAY" |
| 26 | Clear Screen | No parameters |
| 27 | OLED Display | actionValue = multi-line template |
Condition Operators
| operatorType | Name | Description |
|---|---|---|
| 0 | Equal (EQ) | value == compareValue |
| 1 | Not Equal (NEQ) | value != compareValue |
| 2 | Greater Than (GT) | value > compareValue |
| 3 | Less Than (LT) | value < compareValue |
| 4 | Greater or Equal (GTE) | value >= compareValue |
| 5 | Less or Equal (LTE) | value <= compareValue |
| 6 | Between (BETWEEN) | compareValue = "min,max" |
| 7 | Not Between (NOT_BETWEEN) | compareValue = "min,max" |
| 8 | Contains (CONTAIN) | String contains |
| 9 | Not Contains (NOT_CONTAIN) | String does not contain |
Safety Workflow
- Keep imported or newly created rules disabled.
- Confirm all target peripheral IDs exist and wiring is correct.
- Run one manual execution if available.
- Enable the rule only after logs and hardware behavior match expectations.
- Export a backup before editing multiple production rules.
For the full Chinese source page, see 外设执行文档.
