S7

The "S7" shortcut stands for "Step 7", depending on context, in other publications they might be also referred as s7comm.

Devices which speak by this protocol are mostly Siemens PLCs from Simatic product family. This protocol can be used for PLC-to-PLC but also for HMI-to-PLC communication. The binding allows to read values from the PLC as well as write. Depending on actual PLC model subscriptions might be supported. Subscriptions are notifications sent by PLC when change-of-value or specific time interval passes. As a rule of thumb you can expect that subscriptions are supported in higher end models (S7-400, S7-1500). Lower models of Simatic family are more restrictive.

Table 1. S7 binding capability table
Device discovery Channel discovery Read Write Subscribe

No

No

Yes

Yes

No

While upper class of S7 device family supports subscriptions, they are not supported by this binding.

Supported hardware

PLC models supported by this integration are S7-300, 400, 1200, 1500 and Siemens Logo. All these devices use under the hood the same protocol.

Supported things and bridges

Thing Type Name Description

network

bridge

Siemens S7 TCP/IP Bridge

TCP/IP Connection to Siemens PLC

s7

thing

Siemens S7 device

A PLC with S7 communication capabilities which can be polled for data.

In order to start reading data you need to create at least one network bridge with s7 device. Be aware that there might be multiple s7 devices for a single connection allowing to group PLC inputs and outputs. If your PLC controls multiple motors then each of them can be created as a s7 thing with separate state.

Because it is possible to configure polling (sampling) interval for each of above elements you can also group I/O by frequency of updates.

Textual configuration

Below is example of a text configuration which you can upload to your openhab. It allows to use a regular version control system to track changes over time. The same can be done via user interface.

dsl
Bridge co7io-s7:network:test-device "S7-1200 vYXZ" [ host="10.10.10.10", rack=0, slot=0 ] {

  Thing s7 device_inputs "Inputs" [ refreshInterval="500" ] {
    Type switch: Input001 "Input 001" [ field="I0.1:BOOL" ]
    Type switch: Input002 "Input 002" [ field="I0.2:BOOL" ]
    Type switch: Input003 "Input 003" [ field="I0.3:BOOL" ]
    Type switch: Input004 "Input 004" [ field="I0.4:BOOL" ]
    Type switch: Input005 "Input 005" [ field="I0.5:BOOL" ]
  }

  Thing s7 device_outputs "Outputs" [ refreshInterval="500" ] {
    Type switch: Output001 "Output 001" [ field="Q0.1:BOOL" ]
    Type switch: Output002 "Output 002" [ field="Q0.2:BOOL" ]
    Type switch: Output003 "Output 003" [ field="Q0.3:BOOL" ]
    Type switch: Output004 "Output 004" [ field="Q0.3:BOOL" ]
    Type switch: Output005 "Output 005" [ field="Q0.5:BOOL" ]
  }
}
yaml
---
things:
- kind: "Bridge"
  UID: "co7io-s7:network:test-device"
  label: "S7-1200 vYXZ"
  configuration:
    host: "10.10.10.10"
    rack: 0
    slot: 0
  things:
  - id: "device_inputs"
    type: "co7io-s7:s7"
    label: "Inputs"
    configuration:
      refreshInterval: "500"
    channels:
    - id: "Input001"
      type: "switch"
      label: "Input 001"
      configuration:
        field: "I0.1:BOOL"
    - id: "Input002"
      type: "switch"
      label: "Input 002"
      configuration:
        field: "I0.2:BOOL"
    - id: "Input003"
      type: "switch"
      label: "Input 003"
      configuration:
        field: "I0.3:BOOL"
    - id: "Input004"
      type: "switch"
      label: "Input 004"
      configuration:
        field: "I0.4:BOOL"
    - id: "Input005"
      type: "switch"
      label: "Input 005"
      configuration:
        field: "I0.5:BOOL"
  - id: "device_outputs"
    type: "co7io-s7:s7"
    label: "Outputs"
    configuration:
      refreshInterval: "500"
    channels:
    - id: "Output001"
      type: "switch"
      label: "Output 001"
      configuration:
        field: "Q0.1:BOOL"
    - id: "Output002"
      type: "switch"
      label: "Output 002"
      configuration:
        field: "Q0.2:BOOL"
    - id: "Output003"
      type: "switch"
      label: "Output 003"
      configuration:
        field: "Q0.3:BOOL"
    - id: "Output004"
      type: "switch"
      label: "Output 004"
      configuration:
        field: "Q0.3:BOOL"
    - id: "Output005"
      type: "switch"
      label: "Output 005"
      configuration:
        field: "Q0.5:BOOL"