I was reading the modbus manual to configure multiple modbus slaves with identical sensors. Just couldn’t find what I was looking for.
My request is about the following:
In this example Slave 1, Slave 2 until Slave N are of the same types of slaves with identical sensors. Think of power meters, for example measurements of energy consumption/return of the Solar Panels, Heat pump and Air conditioning.
Like on image:
The three modbus devices in this example will have different device addresses on the same bus, which are connected using modbus. But the way it is configured (as far as I understand now), I would need to repeat these sensor entries for all three modbus device, containing a lot of redundant configuration. See below. Here you can see that only the:
name
slave
unique_id
are different. All other parts are redundant configuration.
modbus:
- name: SDM
type: serial
baudrate: 115200
bytesize: 8
method: rtu
parity: E
port: /dev/ttyUSB0
stopbits: 1
timeout: 1
delay: 1
retry_on_empty: true
close_comm_on_error: false
retries: 3
sensors:
- name: "PV Phase 1 line to neutral volts"
scan_interval: 5
slave: 1
address: 0
input_type: input
count: 2
precision: 2
data_type: float32
unit_of_measurement: V
device_class: voltage
state_class: measurement
unique_id: "PV Phase 1 line to neutral volts"
- name: "Heat pump outside Phase 1 line to neutral volts"
scan_interval: 5
slave: 2
address: 0
input_type: input
count: 2
precision: 2
data_type: float32
unit_of_measurement: V
device_class: voltage
state_class: measurement
unique_id: "Heat pump outside Phase 1 line to neutral volts"
- name: "Heat pump inside Phase 1 line to neutral volts"
scan_interval: 5
slave: 3
address: 0
input_type: input
count: 2
precision: 2
data_type: float32
unit_of_measurement: V
device_class: voltage
state_class: measurement
unique_id: "Heat pump inside Phase 1 line to neutral volts"
I couldn’t find a way to define multiple modbus slaves with identical sensors in a smart way. The goal would be to define the modbus slave address once and create the sensors for the slaves also ones.
Perhaps that is already possible with current configuration options in a different or smarter way. I just couldn’t find it in the documentation, hence my request.
Pretty sure other users are running into this as well. Could someone give me hints or tips or or even better some examples to read to achieve this? If not already possible, this would be a nice addition to the modbus integration in HA.
Thank you very much in advance!
PS This may not be 100% the right place to ask. If so please direct to the correct place. Then I will delete this request.
I will try this practice. If I read the syntax, this is already a very good step in the direction I would like it to go in. It would be even nicer if name and unique_id also could be use repeatedly.
modbus:
- name: SDM
type: serial
baudrate: 115200
bytesize: 8
method: rtu
parity: E
port: /dev/ttyUSB0
stopbits: 1
timeout: 1
delay: 1
retry_on_empty: true
close_comm_on_error: false
retries: 3
sensors:
- name: {VARIABLE} "Phase 1 line to neutral volts"
scan_interval: 5
slave: 1
address: 0
input_type: input
count: 2
precision: 2
data_type: float32
unit_of_measurement: V
device_class: voltage
state_class: measurement
unique_id: {VARIABLE} "Phase 1 line to neutral volts"
- name: {VARIABLE} "Phase 1 line to neutral volts"
scan_interval: 5
slave: 2
address: 0
input_type: input
count: 2
precision: 2
data_type: float32
unit_of_measurement: V
device_class: voltage
state_class: measurement
unique_id: {VARIABLE} "Phase 1 line to neutral volts"
- name: {VARIABLE} "Phase 1 line to neutral volts"
scan_interval: 5
slave: 3
address: 0
input_type: input
count: 2
precision: 2
data_type: float32
unit_of_measurement: V
device_class: voltage
state_class: measurement
unique_id: {VARIABLE} "Phase 1 line to neutral volts"
- name: {VARIABLE} "Phase 1 current"
scan_interval: 5
slave: 1
address: 6
input_type: input
count: 2
precision: 2
data_type: float32
unit_of_measurement: A
device_class: current
state_class: measurement
unique_id: {VARIABLE} "Phase 1 current"
- name: {VARIABLE} "Phase 2 current"
scan_interval: 5
slave: 1
address: 8
input_type: input
count: 2
precision: 2
data_type: float32
unit_of_measurement: A
device_class: current
state_class: measurement
unique_id: {VARIABLE} "Phase 1 current"
- name: {VARIABLE} "Phase 3 current"
scan_interval: 5
slave: 1
address: 10
input_type: input
count: 2
precision: 2
data_type: float32
unit_of_measurement: A
device_class: current
state_class: measurement
unique_id: {VARIABLE} "Phase 1 current"
Haha, I’m trusting you and working on my config. First part is already working. The term nikito7 used was just confusing and thought he may have meant a different method.
Thank you all for the help! If it works well, will share my result so that others may also learn from it as I did today.
Not shure if I’m right here but since I’m new to HA (switched from OH) I won’t open a new topic already.
I’ve a similar setup exept my energy-meters (6 SDM120 und one SDM630) are connected thue a single RTU (RS485) to TCP Device.
So if I try to do this setup: