diff --git a/source/_components/binary_sensor.modbus.markdown b/source/_components/binary_sensor.modbus.markdown index fbc300c2984..e57f19b7581 100644 --- a/source/_components/binary_sensor.modbus.markdown +++ b/source/_components/binary_sensor.modbus.markdown @@ -25,9 +25,11 @@ binary_sensor: - platform: modbus coils: - name: Sensor1 + hub: hub1 slave: 1 coil: 100 - name: Sensor2 + hub: hub1 slave: 1 coil: 110 ``` @@ -42,6 +44,11 @@ coils: description: Name of the sensor. required: true type: string + hub: + description: The name of the hub. + required: false + default: default + type: string slave: description: The number of the slave (Optional for TCP and UDP Modbus). required: true @@ -64,9 +71,11 @@ binary_sensor: scan_interval: 10 coils: - name: Sensor1 + hub: hub1 slave: 1 coil: 100 - name: Sensor2 + hub: hub1 slave: 1 coil: 110 ``` diff --git a/source/_components/climate.flexit.markdown b/source/_components/climate.flexit.markdown index 36cda1ecf58..4ef2ab70609 100644 --- a/source/_components/climate.flexit.markdown +++ b/source/_components/climate.flexit.markdown @@ -35,6 +35,11 @@ name: description: Displayed name of the A/C unit. required: false type: string +hub: + description: The name of the hub where this slave is located. + required: false + default: default + type: string {% endconfiguration %}

@@ -61,4 +66,4 @@ climate: - platform: flexit name: Main A/C slave: 21 -``` \ No newline at end of file +``` diff --git a/source/_components/climate.modbus.markdown b/source/_components/climate.modbus.markdown index 77d62c2cf86..6aa4b250ad6 100644 --- a/source/_components/climate.modbus.markdown +++ b/source/_components/climate.modbus.markdown @@ -25,6 +25,7 @@ To use your Modbus thermostat in your installation, add the following to your `c climate: - platform: modbus name: Watlow F4T + hub: hub1 slave: 1 target_temp_register: 2782 current_temp_register: 27586 @@ -35,6 +36,11 @@ name: description: Name of the device required: true type: string +hub: + description: The name of the hub. + required: false + default: default + type: string slave: description: The number of the slave (Optional for tcp and upd Modbus, use 1). required: true diff --git a/source/_components/modbus.markdown b/source/_components/modbus.markdown index e08cd84e03a..fe3ffbbcd79 100644 --- a/source/_components/modbus.markdown +++ b/source/_components/modbus.markdown @@ -28,6 +28,7 @@ For a network connection, add the following to your `configuration.yaml` file: ```yaml # Example configuration.yaml entry for a TCP connection modbus: + name: hub1 type: tcp host: IP_ADDRESS port: 2020 @@ -46,6 +47,11 @@ port: description: The network port for the communication. required: true type: integer +name: + description: Name for this hub. Must be unique, so it is required when setting up multiple instances. + required: false + default: default + type: string timeout: description: Timeout for slave response in seconds. required: false @@ -60,6 +66,7 @@ For a serial connection, add the following to your `configuration.yaml` file: ```yaml # Example configuration.yaml entry for a serial connection modbus: + name: hub1 type: serial method: rtu port: /dev/ttyUSB0 @@ -98,6 +105,11 @@ parity: description: "The parity for the serial connection; can be `E`, `O` or `N`." required: true type: string +name: + description: Name for this hub. Must be unique, so it is required when setting up multiple instances. + required: false + default: default + type: string timeout: description: Timeout for slave response in seconds. required: false @@ -105,17 +117,36 @@ timeout: type: integer {% endconfiguration %} +### {% linkable_title Multiple connections %} + +Multiple connections are possible, add something like the following to your `configuration.yaml` file: + +```yaml +# Example configuration.yaml entry for multiple TCP connections +modbus: + - type: tcp + host: IP_ADDRESS_1 + port: 2020 + hub: hub1 + + - type: tcp + host: IP_ADDRESS_2 + port: 501 + hub: hub2 +``` + ### {% linkable_title Services %} | Service | Description | | ------- | ----------- | -| write_register | Write register. Requires `unit`, `address` and `value` fields. `value` can be either single value or an array | +| write_register | Write register. Requires `hub`, `unit`, `address` and `value` fields. `value` can be either single value or an array | #### {% linkable_title Service Data Attributes %} | Attribute | Description | | --------- | ----------- | +| hub | Hub name (defaults to 'default' when omitted) | | unit | Slave address (set to 255 you talk to Modbus via TCP) | | address | Address of the Register (e.g., 138) | | value | An array of 16-bit values. Might need reverse ordering. E.g., to set 0x0004 you might need to set `[4,0]` | diff --git a/source/_components/sensor.modbus.markdown b/source/_components/sensor.modbus.markdown index bc6b78b8e30..cc4cd589785 100644 --- a/source/_components/sensor.modbus.markdown +++ b/source/_components/sensor.modbus.markdown @@ -26,15 +26,18 @@ sensor: platform: modbus registers: - name: Sensor1 + hub: hub1 unit_of_measurement: °C slave: 1 register: 100 - name: Sensor2 + hub: hub1 unit_of_measurement: mg slave: 1 register: 110 count: 2 - name: Sensor3 + hub: hub1 unit_of_measurement: °C slave: 1 register: 120 @@ -55,6 +58,11 @@ registers: description: Name of the sensor. required: true type: string + hub: + description: The name of the hub. + required: false + default: default + type: string slave: description: The number of the slave (Optional for tcp and upd Modbus). required: true @@ -118,6 +126,7 @@ sensor: scan_interval: 10 registers: - name: Room_1 + hub: hub1 slave: 10 register: 0 register_type: holding diff --git a/source/_components/switch.modbus.markdown b/source/_components/switch.modbus.markdown index 4e897a296b3..c31dc5c458a 100644 --- a/source/_components/switch.modbus.markdown +++ b/source/_components/switch.modbus.markdown @@ -26,6 +26,7 @@ switch: slave: 1 coils: - name: Switch1 + hub: hub1 slave: 1 coil: 13 - name: Switch2 @@ -33,6 +34,7 @@ switch: coil: 14 registers: - name: Register1 + hub: hub1 slave: 1 register: 11 command_on: 1 @@ -45,6 +47,11 @@ coils: required: false type: map keys: + hub: + description: The name of the hub. + required: false + default: default + type: string slave: description: The number of the slave (can be omitted for tcp and udp Modbus). required: true @@ -62,6 +69,11 @@ register: required: false type: map keys: + hub_name: + description: The hub to use. + required: false + default: default + type: string slave: description: The number of the slave (can be omitted for tcp and udp Modbus). required: true