Skip to content

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 ​

Typetype ValueDescription
DEVICE_EVENT60Device 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 ​

json
{
  "id": "evt_fault",
  "name": "Device Fault Event",
  "type": 60,
  "enabled": false,
  "pins": [],
  "params": {}
}

Custom Alarm Event ​

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

json
{
  "targetPeriphId": "evt_alarm",
  "actionType": 21,
  "actionValue": "Temperature Limit Exceeded",
  "useReceivedValue": false,
  "syncDelayMs": 0,
  "execMode": 0
}

After triggering:

  1. The event is dispatched to other rules using the rule ID as the event source
  2. 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:

json
{
  "triggerType": 4,
  "triggerPeriphId": "",
  "eventId": "exec_1234567"
}

eventId is the rule ID that triggers the event, enabling chained linkage between rules.

Complete Chained Linkage Example ​

Rule A: Temperature limit exceeded -> Trigger alarm event

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

json
{
  "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 IDEventTypeDescription
sys_breakdown110Device fault
sys_restart111Device restart
device_alarm112Device alarm
low_power113Low battery warning

Notes ​

  1. No Physical Operation: DEVICE_EVENT does not control any hardware, only used for logical event propagation
  2. Chain Limitation: Avoid creating circular trigger chains (A triggers B -> B triggers A), which may cause infinite loops
  3. MQTT Reporting: Events reported via the DEVICE_EVENT topic carry the event name and data
  4. Deduplication Protection: Minimum trigger interval for the same event is 500ms to prevent rapid duplicate triggering

FastBee | fastbee.cn