Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 122 additions & 10 deletions source/_integrations/modbus.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ha_platforms:
- cover
- sensor
- switch
- light
---

[Modbus](http://www.modbus.org/) is a serial communication protocol to control PLCs (Programmable Logic Controller).
Expand All @@ -31,8 +32,9 @@ Platforms:
- cover
- sensor
- switch
- light

are all defined as part of the modbus configuration. The old configuration style, (having each outside the modbus configuration is still supported, but will cause a warning, and will be removed in a later release).
are all defined as part of the modbus configuration. The old configuration style (having each outside the modbus configuration) is still supported, but will cause a warning, and will be removed in a later release).

### Network connection

Expand Down Expand Up @@ -738,6 +740,124 @@ modbus:
address: 14
```

### Configuring platform light

The `modbus` light platform allows you to control [Modbus](http://www.modbus.org/)-enabled lights. We support two types of Modbus lights — coil-based and register-based.

To use your Modbus lights in your installation, add the following to your `configuration.yaml` file:

```yaml
# Example configuration.yaml entry
modbus:
- type: tcp
host: IP_ADDRESS
port: 502
lights:
- name: Light1
address: 13
write_type: coil
- name: Light2
slave: 2
address: 14
write_type: coil
verify:
- name: Register1
address: 11
command_on: 1
command_off: 0
verify:
input_type: holding
address: 127
state_on: 25
state_off: 1
```

{% configuration %}
lights:
description: The array contains a list of all your Modbus lights.
required: true
type: map
keys:
address:
description: Coil number or register
required: true
type: integer
command_on:
description: Value to write to turn on the light.
required: false
default: 0x01
type: integer
command_off:
description: Value to write to turn off the light.
required: false
default: 0x00
type: integer
write_type:
description: type of adddress (holding/coil)
required: false
default: holding
type: integer
name:
description: Name of the light.
required: true
type: string
scan_interval:
description: Defines the update interval of the sensor in seconds.
required: false
type: integer
default: 15
slave:
description: The number of the slave (can be omitted for tcp and udp Modbus).
required: false
type: integer
default: 0
verify:
description: read from modbus device to verify light.
required: false
type: map
keys:
address:
description: address to read from.
required: false
default: write address
type: integer
input_type:
description: type of adddress (holding/coil/discrete/input)
required: false
default: write_type
type: integer
state_on:
description: value when light is on.
required: false
default: same as command_on
type: integer
state_off:
description: value when light is off.
required: false
default: same as command_off
type: integer
{% endconfiguration %}

#### Full example

Example lights, for which the state is not polled.

```yaml
modbus:
- name: hub1
type: tcp
host: IP_ADDRESS
port: 502
switches:
- name: Light1
slave: 1
address: 13
input_type: coil
- name: Light2
slave: 2
address: 14
```

#### Multiple connections

Multiple connections are possible, add something like the following to your `configuration.yaml` file:
Expand Down Expand Up @@ -798,12 +918,4 @@ logger:
pymodbus.client: debug
```

and restart Home Assistant, reproduce the problem, and include the log in the issue.

## Building on top of Modbus

- [Modbus Binary Sensor](/integrations/binary_sensor.modbus/)
- [Modbus Climate](/integrations/climate.modbus/)
- [Modbus Cover](/integrations/cover.modbus/)
- [Modbus Sensor](/integrations/sensor.modbus/)
- [Modbus Switch](/integrations/switch.modbus/)
and restart Home Assistant, reproduce the problem, and include the log in the issue.