Modbus Switch


The modbus switch platform allows you to control Modbus coils or registers.

Configuration

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

# Example configuration.yaml entry
switch:
  platform: modbus
  coils:
    - name: Switch1
      hub: hub1
      slave: 1
      coil: 13
    - name: Switch2
      slave: 2
      coil: 14
  registers:
    - name: Register1
      hub: hub1
      slave: 1
      register: 11
      command_on: 1
      command_off: 0

Configuration Variables

coils map(Optional)

A list of relevant coils to read from/write to.

hub string(Optional, default: default)

The name of the hub.

slave integerRequired

The number of the slave (can be omitted for tcp and udp Modbus).

name stringRequired

Name of the switch.

coil integerRequired

Coil number.

registers map(Optional)

A list of relevant registers to read from/write to.

hub string(Optional, default: default)

The hub to use.

slave integerRequired

The number of the slave (can be omitted for tcp and udp Modbus).

name stringRequired

Name of the switch.

register integerRequired

Register number.

command_on integerRequired

Value to write to turn on the switch.

command_off integerRequired

Value to write to turn off the switch.

verify_state boolean(Optional, default: true)

Define if is possible to readback the status of the switch.

verify_register string(Optional, default: same as register)

Register to readback.

register_type string(Optional, default: holding)

Modbus register types are holding or input.

state_on integer(Optional, default: same as command_on)

Register value when switch is on.

state_off integer(Optional, default: same as command_off)

Register value when switch is off.

It’s possible to change the default 30 seconds scan interval for the switch state updates as shown in the Platform options documentation.

Full example

Example switches, for which the state is polled from Modbus every 10 seconds.

switch:
  platform: modbus
  scan_interval: 10
  coils:
    - name: Switch1
      hub: hub1
      slave: 1
      coil: 13
    - name: Switch2
      hub: hub1
      slave: 2
      coil: 14