Hi,
I have 3 Eastron SDM630 power meters, which are connected using Modbus (RTU). I currently have this setup like this:
modbus:
name: hub1
type: serial
baudrate: 9600
bytesize: 8
method: rtu
parity: N
port: /dev/ttyUSB1
stopbits: 1
sensors: !include SDM_meters.yaml
SDM_meters.yaml
#slave1
- name: sdm630_garage_total_active_energy
address: 342
input_type: input
count: 2
slave: 1
precision: 2
data_type: float32
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
- name: sdm630_garage_total_system_power
address: 52
input_type: input
count: 2
slave: 1
precision: 2
data_type: float32
unit_of_measurement: W
device_class: energy
state_class: measurement
But in the way it is configured, i would need to repeat these sensor entries for all thee SDM630’s, containing a lot of redundant configuration.
Ideally, i would like something like this:
sensors: !include SDM_meters.yaml name=garage slave=1
- name: sdm630_{{ NAME }}_total_system_power
address: 52
input_type: input
count: 2
slave: {{ SLAVE }}
precision: 2
data_type: float32
unit_of_measurement: W
device_class: energy
state_class: measurement
But I have no idea how to accomplish that. Is there a way to define the modbus registers to read only once and have the slave number be part of some variable or something?
My goal is to only define the modbus values once, and just create the sensors for each slave attached to the modbus bus.