Skip to content

Modbus Actions ​

Action Types ​

ActionactionTypeDescription
ACTION_MODBUS_COIL_WRITE16Write coil (FC05)
ACTION_MODBUS_REG_WRITE17Write register (FC06)
ACTION_MODBUS_POLL18Poll collection

Configuration Examples ​

The peripheral execution page and Modbus RTU configuration page are shown below. When configuring Modbus actions, verify serial port parameters, slave address, function code, register or coil address.

AreaFieldExample Value / Status
Status OverviewRisk LevelLow
Status OverviewEnabled Tasks0
Status OverviewTimeout Rate0%
Status OverviewTotal Polls / Success / Failed / Timeout0 / 0 / 0 / 0
Basic ConfigEnable Modbus RTUEnabled
Basic ConfigPeripheral Config SelectionSelect configured RS485/UART peripheral
Basic ConfigTransfer TypePassthrough (Raw HEX frames)
Basic ConfigDE Pin (RS485)14
Sub-device NameTypeSlave AddressDevice InfoEnableActions
Temp/HumidityCollection2FC04 @0 x2 [2 mappings]ONEdit / Map / Delete
PM25-10Collection1FC03 @0 x2 [2 mappings]ONEdit / Map / Delete
Weather LouverCollection4FC03 @500 x8 [6 mappings]ONEdit / Map / Delete

Example 1: Write Coil (Control Relay On/Off) ​

Scenario: Turn on channel 0 (channel 0) of Modbus relay

Configuration Steps:

  1. Edit the rule in the Peripheral Execution Management page

  2. Click the Add Action button

  3. Fill in the action configuration:

    FieldValueDescription
    Action TypeSelect Modbus Write CoilFC05
    Target PeripheralSelect mb_relayModbus relay
    Channel Number0Based on coilBase offset
    Value11=ON, 0=OFF
  4. Click the Save button

💡 Tip: Channel number is based on the coilBase offset in peripheral configuration; check device manual to confirm


Example 2: Write Register (Set PWM Value) ​

Scenario: Write register value 512 to Modbus PWM module

Configuration Steps:

  1. Edit the rule, add an action

  2. Fill in:

    • Action Type: Select Modbus Write Register
    • Target Peripheral: Select mb_pwm
    • Register Address: 100
    • Write Value: 512
  3. Click Save

💡 Tip: Check device manual to confirm register address


Example 3: Poll Collection (Read Sensor Data) ​

Scenario: Poll Modbus task 0 for sensor data

Configuration Steps:

  1. Edit the rule, add an action

  2. Fill in:

    • Action Type: Select Modbus Poll
    • Target Peripheral: Enter modbus-task:0 (fixed format)
    • Task Index: [0] (JSON array format)
    • Report Data: ✅ Enable the rule's report data option
  3. Click Save

💡 Tip:

  • targetPeriphId format is fixed as modbus-task:N, N is device index
  • actionValue format: {"poll":[0,1,2]}, array contains task indices
  • When "Report Data" is enabled, collection results are automatically reported via MQTT

Example 4: Multi-device Polling ​

Scenario: Poll multiple tasks (0, 1, 2) at once

Configuration Steps:

  1. Edit the rule, add an action

  2. Fill in:

    • Action Type: Select Modbus Poll
    • Target Peripheral: Enter modbus-task:0
    • Task Index: [0,1,2]
  3. Click Save

💡 Tip: Multiple task indices separated by commas; system polls in order


Method 2: JSON Configuration File Import ​

Complete Rule Example ​

Platform Control Modbus Relay ​

json
{
  "id": "exec_mb_ctrl",
  "name": "Remote Control Relay",
  "enabled": false,
  "execMode": 0,
  "triggers": [
    {
      "triggerType": 0,
      "triggerPeriphId": "mb_relay_ch0",
      "operatorType": 0,
      "compareValue": "1",
      "timerMode": 0,
      "intervalSec": 60,
      "timePoint": "",
      "eventId": "",
      "pollResponseTimeout": 1000,
      "pollMaxRetries": 2,
      "pollInterPollDelay": 100
    }
  ],
  "actions": [
    {
      "targetPeriphId": "mb_relay",
      "actionType": 16,
      "actionValue": "{\"ch\":0,\"val\":1}",
      "useReceivedValue": false,
      "syncDelayMs": 0,
      "execMode": 0
    }
  ],
  "protocolType": 0,
  "scriptContent": "",
  "reportAfterExec": true
}

Precautions ​

  1. Modbus Availability: Action execution checks if Modbus channel is ready
  2. Communication Interval: Recommended syncDelayMs ≥ 100ms between multiple Modbus actions
  3. Timeout Handling: Modbus communication timeout records failure and triggers backoff mechanism
  4. Data Reporting: MODBUS_POLL results are automatically reported via MQTT when reportAfterExec: true

FastBee | fastbee.cn