mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-14 21:06:50 +00:00
Add support for multiple modbus hubs. (#8027)
* Add support for multiple modbus hubs. * fixed typo * Update documentation for flexit * Hub name is optional
This commit is contained in:
parent
2e2cd6dc96
commit
6cf9eee5fa
@ -25,9 +25,11 @@ binary_sensor:
|
|||||||
- platform: modbus
|
- platform: modbus
|
||||||
coils:
|
coils:
|
||||||
- name: Sensor1
|
- name: Sensor1
|
||||||
|
hub: hub1
|
||||||
slave: 1
|
slave: 1
|
||||||
coil: 100
|
coil: 100
|
||||||
- name: Sensor2
|
- name: Sensor2
|
||||||
|
hub: hub1
|
||||||
slave: 1
|
slave: 1
|
||||||
coil: 110
|
coil: 110
|
||||||
```
|
```
|
||||||
@ -42,6 +44,11 @@ coils:
|
|||||||
description: Name of the sensor.
|
description: Name of the sensor.
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
hub:
|
||||||
|
description: The name of the hub.
|
||||||
|
required: false
|
||||||
|
default: default
|
||||||
|
type: string
|
||||||
slave:
|
slave:
|
||||||
description: The number of the slave (Optional for TCP and UDP Modbus).
|
description: The number of the slave (Optional for TCP and UDP Modbus).
|
||||||
required: true
|
required: true
|
||||||
@ -64,9 +71,11 @@ binary_sensor:
|
|||||||
scan_interval: 10
|
scan_interval: 10
|
||||||
coils:
|
coils:
|
||||||
- name: Sensor1
|
- name: Sensor1
|
||||||
|
hub: hub1
|
||||||
slave: 1
|
slave: 1
|
||||||
coil: 100
|
coil: 100
|
||||||
- name: Sensor2
|
- name: Sensor2
|
||||||
|
hub: hub1
|
||||||
slave: 1
|
slave: 1
|
||||||
coil: 110
|
coil: 110
|
||||||
```
|
```
|
||||||
|
@ -35,6 +35,11 @@ name:
|
|||||||
description: Displayed name of the A/C unit.
|
description: Displayed name of the A/C unit.
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
|
hub:
|
||||||
|
description: The name of the hub where this slave is located.
|
||||||
|
required: false
|
||||||
|
default: default
|
||||||
|
type: string
|
||||||
{% endconfiguration %}
|
{% endconfiguration %}
|
||||||
|
|
||||||
<p class='note'>
|
<p class='note'>
|
||||||
@ -61,4 +66,4 @@ climate:
|
|||||||
- platform: flexit
|
- platform: flexit
|
||||||
name: Main A/C
|
name: Main A/C
|
||||||
slave: 21
|
slave: 21
|
||||||
```
|
```
|
||||||
|
@ -25,6 +25,7 @@ To use your Modbus thermostat in your installation, add the following to your `c
|
|||||||
climate:
|
climate:
|
||||||
- platform: modbus
|
- platform: modbus
|
||||||
name: Watlow F4T
|
name: Watlow F4T
|
||||||
|
hub: hub1
|
||||||
slave: 1
|
slave: 1
|
||||||
target_temp_register: 2782
|
target_temp_register: 2782
|
||||||
current_temp_register: 27586
|
current_temp_register: 27586
|
||||||
@ -35,6 +36,11 @@ name:
|
|||||||
description: Name of the device
|
description: Name of the device
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
hub:
|
||||||
|
description: The name of the hub.
|
||||||
|
required: false
|
||||||
|
default: default
|
||||||
|
type: string
|
||||||
slave:
|
slave:
|
||||||
description: The number of the slave (Optional for tcp and upd Modbus, use 1).
|
description: The number of the slave (Optional for tcp and upd Modbus, use 1).
|
||||||
required: true
|
required: true
|
||||||
|
@ -28,6 +28,7 @@ For a network connection, add the following to your `configuration.yaml` file:
|
|||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry for a TCP connection
|
# Example configuration.yaml entry for a TCP connection
|
||||||
modbus:
|
modbus:
|
||||||
|
name: hub1
|
||||||
type: tcp
|
type: tcp
|
||||||
host: IP_ADDRESS
|
host: IP_ADDRESS
|
||||||
port: 2020
|
port: 2020
|
||||||
@ -46,6 +47,11 @@ port:
|
|||||||
description: The network port for the communication.
|
description: The network port for the communication.
|
||||||
required: true
|
required: true
|
||||||
type: integer
|
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:
|
timeout:
|
||||||
description: Timeout for slave response in seconds.
|
description: Timeout for slave response in seconds.
|
||||||
required: false
|
required: false
|
||||||
@ -60,6 +66,7 @@ For a serial connection, add the following to your `configuration.yaml` file:
|
|||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry for a serial connection
|
# Example configuration.yaml entry for a serial connection
|
||||||
modbus:
|
modbus:
|
||||||
|
name: hub1
|
||||||
type: serial
|
type: serial
|
||||||
method: rtu
|
method: rtu
|
||||||
port: /dev/ttyUSB0
|
port: /dev/ttyUSB0
|
||||||
@ -98,6 +105,11 @@ parity:
|
|||||||
description: "The parity for the serial connection; can be `E`, `O` or `N`."
|
description: "The parity for the serial connection; can be `E`, `O` or `N`."
|
||||||
required: true
|
required: true
|
||||||
type: string
|
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:
|
timeout:
|
||||||
description: Timeout for slave response in seconds.
|
description: Timeout for slave response in seconds.
|
||||||
required: false
|
required: false
|
||||||
@ -105,17 +117,36 @@ timeout:
|
|||||||
type: integer
|
type: integer
|
||||||
{% endconfiguration %}
|
{% 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 %}
|
### {% linkable_title Services %}
|
||||||
|
|
||||||
|
|
||||||
| Service | Description |
|
| 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 %}
|
#### {% linkable_title Service Data Attributes %}
|
||||||
|
|
||||||
| Attribute | Description |
|
| Attribute | Description |
|
||||||
| --------- | ----------- |
|
| --------- | ----------- |
|
||||||
|
| hub | Hub name (defaults to 'default' when omitted) |
|
||||||
| unit | Slave address (set to 255 you talk to Modbus via TCP) |
|
| unit | Slave address (set to 255 you talk to Modbus via TCP) |
|
||||||
| address | Address of the Register (e.g., 138) |
|
| 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]` |
|
| value | An array of 16-bit values. Might need reverse ordering. E.g., to set 0x0004 you might need to set `[4,0]` |
|
||||||
|
@ -26,15 +26,18 @@ sensor:
|
|||||||
platform: modbus
|
platform: modbus
|
||||||
registers:
|
registers:
|
||||||
- name: Sensor1
|
- name: Sensor1
|
||||||
|
hub: hub1
|
||||||
unit_of_measurement: °C
|
unit_of_measurement: °C
|
||||||
slave: 1
|
slave: 1
|
||||||
register: 100
|
register: 100
|
||||||
- name: Sensor2
|
- name: Sensor2
|
||||||
|
hub: hub1
|
||||||
unit_of_measurement: mg
|
unit_of_measurement: mg
|
||||||
slave: 1
|
slave: 1
|
||||||
register: 110
|
register: 110
|
||||||
count: 2
|
count: 2
|
||||||
- name: Sensor3
|
- name: Sensor3
|
||||||
|
hub: hub1
|
||||||
unit_of_measurement: °C
|
unit_of_measurement: °C
|
||||||
slave: 1
|
slave: 1
|
||||||
register: 120
|
register: 120
|
||||||
@ -55,6 +58,11 @@ registers:
|
|||||||
description: Name of the sensor.
|
description: Name of the sensor.
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
hub:
|
||||||
|
description: The name of the hub.
|
||||||
|
required: false
|
||||||
|
default: default
|
||||||
|
type: string
|
||||||
slave:
|
slave:
|
||||||
description: The number of the slave (Optional for tcp and upd Modbus).
|
description: The number of the slave (Optional for tcp and upd Modbus).
|
||||||
required: true
|
required: true
|
||||||
@ -118,6 +126,7 @@ sensor:
|
|||||||
scan_interval: 10
|
scan_interval: 10
|
||||||
registers:
|
registers:
|
||||||
- name: Room_1
|
- name: Room_1
|
||||||
|
hub: hub1
|
||||||
slave: 10
|
slave: 10
|
||||||
register: 0
|
register: 0
|
||||||
register_type: holding
|
register_type: holding
|
||||||
|
@ -26,6 +26,7 @@ switch:
|
|||||||
slave: 1
|
slave: 1
|
||||||
coils:
|
coils:
|
||||||
- name: Switch1
|
- name: Switch1
|
||||||
|
hub: hub1
|
||||||
slave: 1
|
slave: 1
|
||||||
coil: 13
|
coil: 13
|
||||||
- name: Switch2
|
- name: Switch2
|
||||||
@ -33,6 +34,7 @@ switch:
|
|||||||
coil: 14
|
coil: 14
|
||||||
registers:
|
registers:
|
||||||
- name: Register1
|
- name: Register1
|
||||||
|
hub: hub1
|
||||||
slave: 1
|
slave: 1
|
||||||
register: 11
|
register: 11
|
||||||
command_on: 1
|
command_on: 1
|
||||||
@ -45,6 +47,11 @@ coils:
|
|||||||
required: false
|
required: false
|
||||||
type: map
|
type: map
|
||||||
keys:
|
keys:
|
||||||
|
hub:
|
||||||
|
description: The name of the hub.
|
||||||
|
required: false
|
||||||
|
default: default
|
||||||
|
type: string
|
||||||
slave:
|
slave:
|
||||||
description: The number of the slave (can be omitted for tcp and udp Modbus).
|
description: The number of the slave (can be omitted for tcp and udp Modbus).
|
||||||
required: true
|
required: true
|
||||||
@ -62,6 +69,11 @@ register:
|
|||||||
required: false
|
required: false
|
||||||
type: map
|
type: map
|
||||||
keys:
|
keys:
|
||||||
|
hub_name:
|
||||||
|
description: The hub to use.
|
||||||
|
required: false
|
||||||
|
default: default
|
||||||
|
type: string
|
||||||
slave:
|
slave:
|
||||||
description: The number of the slave (can be omitted for tcp and udp Modbus).
|
description: The number of the slave (can be omitted for tcp and udp Modbus).
|
||||||
required: true
|
required: true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user