Skip to content

Peripheral Execution Documentation ​

Overview: The Peripheral Execution module is a rule engine that implements "execute actions when conditions are met", using a trigger-action model. It supports 4 trigger types (Platform/Timer/Event/Poll) and 27 action types (GPIO/PWM/Sensor/Display/System etc.). Rules execute asynchronously with a Worker pool pre-created with 3 tasks and a minimum heap memory gate of 30KB. Configuration is stored in /config/periph_exec.json.

All factory rules are disabled to avoid driving unknown wiring. After importing or creating a rule, verify the target peripheral and pins before enabling it; the UI and API validate actions against the target device's runtime capabilities.

This directory contains modular detailed documentation for the peripheral execution rule system, organized by triggers, actions, and complete scenarios.

NameStatusTriggerTarget PeripheralActionStatisticsOperations
ADC Voltage Collection ReportDisabledTimer TriggerADC Analog ConversionSensor Data Read -> ADC Analog ConversionTrigger Count: 1Execute Once / Edit / Enable / Delete
ADC Voltage Below 2.30V Close RelayDisabledEvent Trigger-Set Low LevelTrigger Count: 1Execute Once / Edit / Enable / Delete
ADC Voltage Above 2.50V Open RelayDisabledEvent Trigger-Set High LevelTrigger Count: 1Execute Once / Edit / Enable / Delete
ADC Voltage Display on Digital TubeDisabledTimer Trigger-Display NumberTrigger Count: 1Execute Once / Edit / Enable / Delete
NTP Time SyncDisabledPlatform Trigger (MQTT)-NTP SyncTrigger Count: 1Execute Once / Edit / Enable / Delete
OLED Temp/Humidity DisplayDisabledTimer Trigger-OLED Custom DisplayTrigger Count: 1Execute Once / Edit / Enable / Delete
OLED Custom Display - Button Trigger Device InfoDisabledEvent Trigger-OLED Custom DisplayTrigger Count: 1Execute Once / Edit / Enable / Delete
OLED Custom Display - Timer MixedDisabledTimer Trigger-OLED Custom DisplayTrigger Count: 1Execute Once / Edit / Enable / Delete
OLED Custom Display - MQTT MessageDisabledPlatform Trigger (MQTT)-OLED Custom DisplayTrigger Count: 1Execute Once / Edit / Enable / Delete
OTA UpgradeDisabledPlatform Trigger (MQTT)-OTA UpgradeTrigger Count: 1Execute Once / Edit / Enable / Delete

The rule list is used to confirm the enable status, number of triggers, number of actions, and manual execution entry for each rule. During initial on-site deployment, it is recommended to verify each rule one by one before turning on "Enable".

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

The two diagrams above are best reviewed first: the data model explains what fields a rule consists of, and the timing comparison explains when to choose platform, timer, event, or poll triggers.

Documentation Index ​

Trigger Documentation ​

DocumenttriggerTypeDescription
platform-trigger.md0Platform trigger (MQTT/Modbus command delivery)
timer-trigger.md1Timer trigger (interval/daily time point)
event-trigger.md4Event trigger (system/button/data/peripheral events)
poll-trigger.md5Poll trigger (local data source condition evaluation)

Action Documentation ​

DocumentactionTypeDescription
gpio-actions.md0,1,13,14GPIO output (high/low/inverted)
pwm-actions.md2,3,4,5PWM/breathing light/DAC
system-actions.md6,7,8,9System restart/factory reset/NTP/OTA
modbus-actions.md16,17,18Modbus coil/register/poll
sensor-actions.md19Sensor data reading
display-actions.md24,25,26,27Digital tube/OLED display
event-actions.md21,22,23Trigger event/rule control
script-actions.md10,15Call peripheral/command script

Complete Scenario Documentation ​

DocumentScenarioModules Involved
temperature-alarm.mdDHT temperature control + relay linkageDHT11/22 + Relay
smoke-alarm.mdSmoke alarm + buzzerMQ-2 + Buzzer + MQTT
light-control.mdPhotosensitive auto light controlPhotosensitive ADC + LED/Relay
button-control.mdButton multi-mode controlButton + Multi-action
modbus-monitor.mdModbus device monitoringModbus sub-device + Alarm
ultrasonic-alarm.mdUltrasonic distance alarmHC-SR04 + Buzzer

Quick Start ​

Rule Structure ​

json
{
  "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 ​

triggerTypeNameTypical Use
0Platform TriggerIoT platform MQTT command matching
1Timer TriggerPeriodic collection, scheduled control
4Event TriggerWiFi/MQTT/button/sensor data events
5Poll TriggerModbus sensor periodic data condition evaluation

Action Type Quick Reference ​

actionTypeNameParameter Description
0High LeveltargetPeriphId=GPIO peripheral ID
1Low LeveltargetPeriphId=GPIO peripheral ID
2FlashactionValue=interval ms
3Breathing LightactionValue=cycle ms
4Set PWMactionValue=duty cycle value
5Set DACactionValue=0~255
6System RestartNo parameters
7Factory ResetNo parameters
8NTP SyncNo parameters
9OTA UpgradeactionValue=URL
10Call PeripheraltargetPeriphId=target peripheral
13High Level (Inverted)Physical output low level
14Low Level (Inverted)Physical output high level
15Command ScriptactionValue=script content
16Modbus CoilFC05
17Modbus RegisterFC06
18Modbus PollCollect sub-device data
19Sensor ReadCollect temperature/humidity/distance/current/voltage
21Trigger EventactionValue=event ID
22Enable RuletargetPeriphId=rule ID
23Disable RuletargetPeriphId=rule ID
24Display NumberactionValue="12.34"
25Display TextactionValue="PLAY"
26Clear ScreenNo parameters
27OLED DisplayactionValue=multi-line template

Condition Operators ​

operatorTypeNameDescription
0Equal (EQ)value == compareValue
1Not Equal (NEQ)value != compareValue
2Greater Than (GT)value > compareValue
3Less Than (LT)value < compareValue
4Greater Than or Equal (GTE)value >= compareValue
5Less Than or Equal (LTE)value <= compareValue
6Between (BETWEEN)compareValue="min,max"
7Not Between (NOT_BETWEEN)compareValue="min,max"
8Contains (CONTAIN)String contains
9Not Contains (NOT_CONTAIN)String does not contain

FastBee | fastbee.cn