Hi all, here is a working config for modbus PT100 temp 6 -channel sensors hub. I`m finally make it to read all data registers at once, using slave_count feature:
template:
- sensor:
- name: ReverseWaterTemp
device_class: temperature
unit_of_measurement: °C
state: >
{{ states('sensor.watertemp') }}
- name: MixedWaterTemp
device_class: temperature
unit_of_measurement: °C
state: >
{{ states('sensor.watertemp_1') }}
- name: PelletWaterTemp
device_class: temperature
unit_of_measurement: °C
state: >
{{ states('sensor.watertemp_2') }}
- name: ForwardWaterTemp
device_class: temperature
unit_of_measurement: °C
state: >
{{ states('sensor.watertemp_3') }}
modbus:
- name: EE10
type: tcp
host: some_ip
port: 502
delay: 1
message_wait_milliseconds: 100
timeout: 2
sensors:
- name: WaterTemp
unit_of_measurement: °C
slave: 1
count: 12
slave_count: 5
address: 64
data_type: float32
device_class: temperature
state_class: measurement
precision: 1
scan_interval: 5
The result is here (-100 means no PT100 sensor connected):
It shows that device_class and state_class was not inherited for automaticaly generated sensors. May be it
s not a very big issue, but i
don`t know if it affects on history data
So ok - this method could be used for getting multiple registers of one type (input or holding) and data type (int, float32, etc) with one transaction.
But i have 3-phase power meter with modbus, which have 22 registers, and not all of them have continuous addresses, and whey should have different units_of_measurment and device_class. So now i`m getting all this registers one by one, which is not very smart i think )
My idea is maybe it`s possible to combine in one config data request configuration (like custom structure with first address and length) and certain register description (like a reading template for requested data).
For example:
modbus:
-name: hub_name
....
devices:
-name: power_meter
slave: 1
-data_request:
name: some_registers
register: 0
register_type: input
data_type: custom
structure: ">10d"
sensors:
- name: Modbus_Grid_Voltage_A
address: 0
input_type: input
unit_of_measurement: V
device_class: voltage
state_class: measurement
precision: 2
data_type: float32
name: another_part_of_registers
register: 20
register_type: holding
data_type: custom
structure: ">2h"
....... etc
From my opinion it could make configuration much clear and prevent lots of single register requests