Modbus Actions
Modbus Actions
Action Types
| Action | actionType | Description |
|---|---|---|
| ACTION_MODBUS_COIL_WRITE | 16 | Write coil (FC05) |
| ACTION_MODBUS_REG_WRITE | 17 | Write register (FC06) |
| ACTION_MODBUS_POLL | 18 | Poll collection |
Configuration Examples
Method 1: Web Interface Configuration (Recommended)
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.
| Area | Field | Example Value / Status |
|---|---|---|
| Status Overview | Risk Level | Low |
| Status Overview | Enabled Tasks | 0 |
| Status Overview | Timeout Rate | 0% |
| Status Overview | Total Polls / Success / Failed / Timeout | 0 / 0 / 0 / 0 |
| Basic Config | Enable Modbus RTU | Enabled |
| Basic Config | Peripheral Config Selection | Select configured RS485/UART peripheral |
| Basic Config | Transfer Type | Passthrough (Raw HEX frames) |
| Basic Config | DE Pin (RS485) | 14 |
| Sub-device Name | Type | Slave Address | Device Info | Enable | Actions |
|---|---|---|---|---|---|
| Temp/Humidity | Collection | 2 | FC04 @0 x2 [2 mappings] | ON | Edit / Map / Delete |
| PM25-10 | Collection | 1 | FC03 @0 x2 [2 mappings] | ON | Edit / Map / Delete |
| Weather Louver | Collection | 4 | FC03 @500 x8 [6 mappings] | ON | Edit / Map / Delete |
Example 1: Write Coil (Control Relay On/Off)
Scenario: Turn on channel 0 (channel 0) of Modbus relay
Configuration Steps:
Edit the rule in the Peripheral Execution Management page
Click the Add Action button
Fill in the action configuration:
Field Value Description Action Type Select Modbus Write Coil FC05 Target Peripheral Select mb_relayModbus relay Channel Number 0Based on coilBase offset Value 11=ON, 0=OFF 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:
Edit the rule, add an action
Fill in:
- Action Type: Select Modbus Write Register
- Target Peripheral: Select
mb_pwm - Register Address:
100 - Write Value:
512
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:
Edit the rule, add an action
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
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:
Edit the rule, add an action
Fill in:
- Action Type: Select Modbus Poll
- Target Peripheral: Enter
modbus-task:0 - Task Index:
[0,1,2]
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
{
"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
- Modbus Availability: Action execution checks if Modbus channel is ready
- Communication Interval: Recommended syncDelayMs ≥ 100ms between multiple Modbus actions
- Timeout Handling: Modbus communication timeout records failure and triggers backoff mechanism
- Data Reporting: MODBUS_POLL results are automatically reported via MQTT when
reportAfterExec: true
