I have recently followed this tutorial: Reading data from Huawei inverter SUN 2000 (3KTL-10KTL) via modbus RTU and successfully adopted it to my inverter type.
As per “Solar Inverter Modbus Interface Definitions”, version 2 (https://support.huawei.com/enterprise/en/doc/EDOC1100113918), which is applicable to my inverter version, there are “string” type modbus registers.
How to read and display these kind of registers using modbus binding?
Thank you in advance.
At Modbus protocol level, there are only 16-bit registers. (well, and binary)
Of course, product designers can assign meanings to those, as bytes or integers or ASCII codes or floating point, and group as 64-bit numbers etc. But these are just ways to interpret 16-bit registers.
The openHAB Modbus binding incorporates many convenient methods to handle the most common ways to use registers - 32-bit floats etc.
It does not offer handlers for all of the different possibilities, that would be practically infinite.
You can always handle an interpretation in openHAB, because you can always get the raw 16-bit registers and process them yourself in a rule or transformation.
But so far as I could see, there aren’t any character-coded registers in that doc?
Thank you Rossko57.
I will try with 16-bit registers.
There is nothing about character-coded registers in document - I will ask Huawei support if they can provide anything.
Yes, that’s my point. You seem to be looking for an imaginary issue. Which of the registers that you read from Huawei do you think is encoded as characters?
In solar pwer systems, the word “string” is also used to denote a chain of PV panels. Is there terminology confusion?
So, you want to read the machine serial number? Can’t imagine why, but okay. Probably not every ten seconds or so.
There’s more than one way to do it. I think I would take a simple but long-winded route.
There’s 10 registers to unpack. We don’t know if Huawei pack one or two characters into a register, or what character code they use. Let’s assume two ASCII characters to a register.
I would create twenty Data Things, each pair of Things would pick the high and low byte of a register.
Link to twenty Number Items, that’ll be our ASCII source in one-byte chunks.
A rule can trigger from one of the Number Items updating; you’d probably want a short delay at the beginning to allow all twenty to complete an update after a Modbus poll.
You’d need a string variable for the finished work, which the rule sets empty at the start.
The rule should take each of the ASCII numeric Items in turn, convert to a single character, and append to the string.
When complete, postUpdate to a String type Item.
Thanks for the tips
I am just curious how to deal with this type of data.
It’s quite rare to find this type of character string encoding in Modbus registers. I have seen it as in this case, where you can get an essentially fixed string representing a device model number, or firmware version, or suchlike; but that isn’t really the kind of thing openHAB users need to know on a daily basis.
The binding could be enhanced with a convenience method to decode a block of registers into string.
There’s no consistent encoding, so in practice it would probably be a set of methods, say byte-packed ASCII, unicode, word packed ASCII, unicode. Then there’s fixed count, or look for an end of string marker like LF, NUL or EOF, or even an embedded character count in first byte or word.
There’s quite a bit of complexity really, it’s been talked of before but no real use-case found.
Maybe the binding could implement a halfway-house approach, just “stream” a fixed length block of registers as “hex bytes” to a string, leaving the user to finesse the decode. A transform could actually do that, if the binding takes on the task of assembling registers into a continuous “block”, which is the hard part at the moment.
The fact that no-one has so far published a rule based setup for even one method suggests no great demand.
Frankly it’s usually about something you read only once ever, and it’s quicker to use a Modbus utility with pencil and paper to “read” it
Do you know by chance where I can get information about the modbus mapping of the PV inverter SUN2000-185KTL ?
Thanks in advance