S7 Write
x/s7Write component: v0.37.0+ Batch writes a list of point values to Siemens S7 series PLCs (S7-200SMART/300/400/1200/1500). A successful write is forwarded via the Success chain.
Additional extension library required: rulego-components-iot (opens new window)
# Configuration
| Field | Type | Description | Default |
|---|---|---|---|
| server | string | PLC address in host:port format; the ISO-on-TCP default port is 102 | 127.0.0.1:102 |
| rack | int | Rack number | 0 |
| slot | int | CPU slot: S7-1200/1500/200SMART=1, S7-300/400=2 | 1 |
| timeout | int | Request timeout in seconds | 5 |
| points | []object | Default points table; points supplied via msg.Data take precedence when valid | [] |
# Point fields
| Field | Type | Description | Default |
|---|---|---|---|
| name | string | Point name | None |
| addr | string | Siemens address (see syntax below); supports ${msg.xx} | None |
| type | string | Data type, see options below | None |
| value | string | Value to write (as a string); supports ${msg.xx} | None |
| scale | float | Optional scale factor; engineering value = raw value × scale + offset | - |
| offset | float | Optional offset | - |
| endian | string | Optional byte order | - |
# Point fields
addr field: Uses Siemens address syntax; supports ${msg.xx} template variables.
- DB area:
DB<n>.<DBX|DBB|DBW|DBD><offset>[.bit], e.g.DB1.DBD0,DB1.DBW2,DB1.DBX0.1 - M/I/Q areas: word/dword addresses such as
MW0,MD0,IW0,QW0; bit addresses such asM0.1
Data type options:
| Type | Bytes | Value format |
|---|---|---|
BOOL | 1 | Boolean; value accepts true/false/0/1; use a bit address (e.g. DB1.DBX0.1, M0.1); implemented as read-modify-write |
BYTE | 1 | Unsigned byte |
INT | 2 | Signed 16-bit integer |
WORD | 2 | Unsigned 16-bit integer |
DINT | 4 | Signed 32-bit integer |
DWORD | 4 | Unsigned 32-bit integer |
REAL | 4 | 32-bit float |
LREAL | 8 | 64-bit float |
STRING | 256 | S7 string; content longer than 254 bytes is truncated |
# Input
Points to write are read from msg.Data (a JSON array); if msg.Data is empty, the configured points are used instead. Each point object has these fields:
| Field | Type | Description |
|---|---|---|
| name | string | Point name (optional) |
| addr | string | Siemens address, e.g. DB1.DBD8, M10.5 |
| type | string | Data type |
| value | string | Value to write; supports ${msg.xx} |
| scale | float | Scale factor (optional) |
| offset | float | Offset (optional) |
Example msg.Data:
[{"addr":"DB1.DBD8","type":"REAL","value":"23.5"}]
1
# Features
- Periodic writes: Place an
endpoint/scheduleendpoint before this node to trigger it on a schedule. For on-demand writes, an upstream node may inject the points list viamsg.Data. - Template variables: Point fields such as
addrandvaluesupport${msg.xx}/${metadata.xx}templates. - Dynamic points precedence: When
msg.Datacarries a valid points JSON array, it takes precedence; otherwise the configuredpointsare used. - Chain-scoped connection pool: Other S7 nodes in the same chain may reuse an established TCP connection via
ref://nodeIDto avoid duplicate connections. - Failure reconnect/retry: A write failure triggers an automatic reconnect and retry, up to 3 times (
maxRetries=3). Any single point failure fails the overall operation and routes toFailure.
# Relation Type
- Success: Execution succeeds; the message is sent to the
Successchain. - Failure: Execution fails; the message is sent to the
Failurechain.
# Example
{
"ruleChain": {
"id": "s7_write_demo",
"name": "S7 write demo",
"root": true,
"debugMode": false
},
"metadata": {
"firstNodeIndex": 0,
"nodes": [
{
"type": "x/s7Write",
"name": "Write PLC data",
"debugMode": false,
"configuration": {
"server": "192.168.1.100:102",
"rack": 0,
"slot": 1,
"timeout": 5,
"points": [
{"name":"setTemp","addr":"DB1.DBD0","type":"REAL","value":"${msg.setTemp}"},
{"name":"start","addr":"M10.5","type":"BOOL","value":"true"}
]
}
}
],
"connections": []
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Edit this page on GitHub (opens new window)
Last Updated: 2026/07/29, 07:07:39