I am trying to improve my SolaX ModBus implementation by reading multiple registers at once.
According to the manual, if I read the holding registers 0 - 6 I get the 14char serial number. The manual also states the data format is uint16. I tried uint, but it didn’t work.
The following does work and results in the 14digit serial number.
sensor:
- platform: modbus
scan_interval: 2
registers:
# Holding Registers
- name: SolaX Serial Number
hub: SolaX
register: 0
count: 7
data_type: string
So I know fundamentally that read multiple registers does work!
A1A111A1111111
But I am trying to read multiple Input registers at once and I can’t figure it out?
I am trying to read register 3 - 7
- name: SolaX Group Test
hub: SolaX
register: 3
register_type: input
count: 5
I know I should be using a combination of
- name: SolaX Group Test
hub: SolaX
register: 3
register_type: input
count: 5
data_type: custom
structure: what goes here though?
But I can’t figure out the structure?
Each register value should be a 2byte chunk (16bit / 1 word) so how do I split them into chunks?
If I read each register individualy I get something like the following:
Register 3: 1207
Register 4: 1233
Register 5: 2010
Register 6: 2020
Register 7: 5001
If I read them as a string I get random stuff like
q l((~
The doumentation is quite vague to a non programmer!
If data_type is custom specify here a double quoted Python struct format string to unpack the value. See Python documentation for details. Ex: >i.
Where’s the Python documentation?