From ca8fdb7753d8eb1f18bb9269c83b5ae40fc6114d Mon Sep 17 00:00:00 2001 From: Vladimir Zahradnik Date: Tue, 20 Oct 2020 14:15:15 +0200 Subject: [PATCH 1/2] Add documentation for Modbus light --- source/_integrations/modbus.markdown | 119 ++++++++++++++++++++++++--- 1 file changed, 109 insertions(+), 10 deletions(-) diff --git a/source/_integrations/modbus.markdown b/source/_integrations/modbus.markdown index 5d9e7f06b9e2..0614565dad6c 100644 --- a/source/_integrations/modbus.markdown +++ b/source/_integrations/modbus.markdown @@ -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). @@ -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 @@ -738,6 +740,111 @@ 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: + - name: hub1 + type: tcp + host: IP_ADDRESS + port: 502 + lights: + - name: Light1 + address: 13 + input_type: coil + - name: Light2 + slave: 2 + address: 14 + input_type: coil + - name: Register1 + address: 11 + command_on: 1 + command_off: 0 +``` + +{% 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 switch. + required: true + type: integer + command_off: + description: Value to write to turn off the switch. + required: true + type: integer + input_type: + description: type of adddress (holding/discrete/coil) + required: false + default: holding + type: integer + name: + description: Name of the switch. + 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: true + type: integer + state_on: + description: Register value when switch is on. + required: false + default: same as command_on + type: integer + state_off: + description: Register value when switch is off. + required: false + default: same as command_off + type: integer + verify_register: + description: Register to readback. + required: false + default: same as register + type: string + verify_state: + description: Define if is possible to readback the status of the switch. + required: false + default: true + type: boolean +{% endconfiguration %} + +#### Full example + +Example lights, for which the state is polled from Modbus every 15 seconds. + +```yaml +modbus: + - name: hub1 + type: tcp + host: IP_ADDRESS + port: 502 + lights: + - 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: @@ -798,12 +905,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. \ No newline at end of file From 530aa1ec2886b013d9ac27a84b5076f62e5797d3 Mon Sep 17 00:00:00 2001 From: Vladimir Zahradnik Date: Mon, 3 May 2021 11:05:05 +0200 Subject: [PATCH 2/2] Update Modbus light docs --- source/_integrations/modbus.markdown | 79 ++++++++++++++++------------ 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/source/_integrations/modbus.markdown b/source/_integrations/modbus.markdown index 0614565dad6c..2de83e48302e 100644 --- a/source/_integrations/modbus.markdown +++ b/source/_integrations/modbus.markdown @@ -749,22 +749,27 @@ To use your Modbus lights in your installation, add the following to your `confi ```yaml # Example configuration.yaml entry modbus: - - name: hub1 - type: tcp + - type: tcp host: IP_ADDRESS port: 502 lights: - name: Light1 address: 13 - input_type: coil + write_type: coil - name: Light2 slave: 2 address: 14 - input_type: coil + 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 %} @@ -778,20 +783,22 @@ lights: required: true type: integer command_on: - description: Value to write to turn on the switch. - required: true + 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 switch. - required: true + description: Value to write to turn off the light. + required: false + default: 0x00 type: integer - input_type: - description: type of adddress (holding/discrete/coil) + write_type: + description: type of adddress (holding/coil) required: false default: holding type: integer name: - description: Name of the switch. + description: Name of the light. required: true type: string scan_interval: @@ -801,33 +808,39 @@ lights: default: 15 slave: description: The number of the slave (can be omitted for tcp and udp Modbus). - required: true - type: integer - state_on: - description: Register value when switch is on. required: false - default: same as command_on type: integer - state_off: - description: Register value when switch is off. - required: false - default: same as command_off - type: integer - verify_register: - description: Register to readback. - required: false - default: same as register - type: string - verify_state: - description: Define if is possible to readback the status of the switch. - required: false - default: true - type: boolean + 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 polled from Modbus every 15 seconds. +Example lights, for which the state is not polled. ```yaml modbus: @@ -835,7 +848,7 @@ modbus: type: tcp host: IP_ADDRESS port: 502 - lights: + switches: - name: Light1 slave: 1 address: 13