Device Event Virtual Peripheral
Device Event Virtual Peripheral
Function Description
Device Event (DEVICE_EVENT) is a virtual peripheral that does not correspond to physical hardware and serves only as an event emission source. Events are triggered via the ACTION_TRIGGER_EVENT(21) action in peripheral execution rules. Events can be reported to the platform via the MQTT DEVICE_EVENT topic, and can also be subscribed to by other rules for chained linkage.
Device events are typically used together with peripheral execution rules: keep the virtual event object in peripheral configuration, and chain rules through the "trigger event" action or event trigger in peripheral execution.
Supported Peripheral Types
| Type | type Value | Description |
|---|---|---|
| DEVICE_EVENT | 60 | Device event virtual peripheral |
No Hardware Required
- Does not use GPIO pins (pinCount = 0)
- Pure logical-level event source definition
- Triggered and responded to via the rule engine
JSON Configuration Examples
Device Fault Event
{
"id": "evt_fault",
"name": "Device Fault Event",
"type": 60,
"enabled": false,
"pins": [],
"params": {}
}Custom Alarm Event
{
"id": "evt_alarm",
"name": "Custom Alarm",
"type": 60,
"enabled": false,
"pins": [],
"params": {}
}Integration with Peripheral Execution
Trigger Device Event (ACTION_TRIGGER_EVENT = 21)
Trigger an event in rule actions:
{
"targetPeriphId": "evt_alarm",
"actionType": 21,
"actionValue": "Temperature Limit Exceeded",
"useReceivedValue": false,
"syncDelayMs": 0,
"execMode": 0
}After triggering:
- The event is dispatched to other rules using the rule ID as the event source
- If the rule has
reportAfterExec: true, it is reported via the MQTT DEVICE_EVENT topic
Subscribe to Events (as Trigger Source)
Other rules can subscribe to the event via an event trigger:
{
"triggerType": 4,
"triggerPeriphId": "",
"eventId": "exec_1234567"
}
eventIdis the rule ID that triggers the event, enabling chained linkage between rules.
Complete Chained Linkage Example
Rule A: Temperature limit exceeded -> Trigger alarm event
{
"id": "exec_temp_check",
"name": "Temperature Limit Detection",
"enabled": false,
"execMode": 0,
"triggers": [
{
"triggerType": 0,
"triggerPeriphId": "dht1",
"operatorType": 2,
"compareValue": "40",
"timerMode": 0,
"intervalSec": 60,
"timePoint": "",
"eventId": "",
"pollResponseTimeout": 1000,
"pollMaxRetries": 2,
"pollInterPollDelay": 100
}
],
"actions": [
{
"targetPeriphId": "evt_alarm",
"actionType": 21,
"actionValue": "High Temperature Alarm",
"useReceivedValue": false,
"syncDelayMs": 0,
"execMode": 0
}
],
"protocolType": 0,
"scriptContent": "",
"reportAfterExec": true
}Rule B: Respond to alarm event -> Activate buzzer
{
"id": "exec_alarm_action",
"name": "Alarm Response",
"enabled": false,
"execMode": 0,
"triggers": [
{
"triggerType": 4,
"triggerPeriphId": "",
"operatorType": 0,
"compareValue": "",
"timerMode": 0,
"intervalSec": 60,
"timePoint": "",
"eventId": "exec_temp_check",
"pollResponseTimeout": 1000,
"pollMaxRetries": 2,
"pollInterPollDelay": 100
}
],
"actions": [
{
"targetPeriphId": "buzzer",
"actionType": 2,
"actionValue": "500",
"useReceivedValue": false,
"syncDelayMs": 0,
"execMode": 0
}
],
"protocolType": 0,
"scriptContent": "",
"reportAfterExec": false
}Built-in Device Events
The system predefines the following device event IDs (no manual DEVICE_EVENT peripheral configuration required):
| Event ID | EventType | Description |
|---|---|---|
| sys_breakdown | 110 | Device fault |
| sys_restart | 111 | Device restart |
| device_alarm | 112 | Device alarm |
| low_power | 113 | Low battery warning |
Notes
- No Physical Operation: DEVICE_EVENT does not control any hardware, only used for logical event propagation
- Chain Limitation: Avoid creating circular trigger chains (A triggers B -> B triggers A), which may cause infinite loops
- MQTT Reporting: Events reported via the DEVICE_EVENT topic carry the event name and data
- Deduplication Protection: Minimum trigger interval for the same event is 500ms to prevent rapid duplicate triggering
