Issue #1
I had a break-through!
The Modbus-Thing input must be transformed to an integer.
You have to make a Read Transform of
JS( | parseInt(input))
in the Modbus-Thing configuration. I did that before in other Modbus-Things but forgot about it.
After that, everything miraculously works as expected. Otherwise the input will be a float and this obviously breaks internals in the Channels and Links. Now I can have multiple working links to the Number Channel and the String Channel works as well including usage of a map in the State Description in all variants!
Issue #2
Formatting of the output still puzzles me a little. Hereâs my configuration which still uses a float value of the Modbus-Thing.
Thing Number Channel Link. Value shows as 0x0402
:
Link with Standard Profile. Value shows as 0x0402
:
Item. Value shows as 0x0402
:
State Description. Map is obviously ignored but pattern works:
Diagram. Value shown as raw integer 1026
:
Main UI. Value shown as 0x0402
:
Items list. Value shown as 1026.0
:
The map in the State Description of the UI configuration is ignored, I guess because the value is a float and the map uses the ârawâ value.
The items list and diagrams show the raw value without a Pattern of the State Description. I assume Rules and Scripts will use that value also?
Using a single String Item linked to the Number Channel
In the Number Channel I unlinked the Number Item and linked to a single String Item. At first I got no output at all. The Thing to Item Transformation was not used at all, even with a constant output like | âSomethingâ
. Here I realised I hat to explicitly convert to an integer in the Modbus-Thing Read Transform, which I had left alone before and the input was transformed to a float value by default. This explains why it showed up as 1026.0
in the item list before with the Number Item.
I put in a Modbus-Thing Read Transform of
JS( | parseInt(input))
and then the Thing to Item Transformation would be executed.
Thanks to @jimtng the transformation
| '0x' + parseInt(input).toString(16).padStart(4, '0')

works, while
| String.format(â0x%04Xâ, parseInt(input))

does not.
Now the map in the State Description like
0x0402=Ok
=Undefined
works as well
.
Using a String Item and a Number Item linked to the Number Channel
Now I was curious if a second Number Item beneath the String Item would work as well, and it did
. The String Item shows as 1026
as expected and the Thing to Item Transformation to convert to hex display works as well as does the map in the State Description.
Using a String Item linked to the String Channel
After the Modbus-Thing Read Transform to integer this works as well as expected. I used the Thing to Item Transformation to format into hex display. I can now use the map in the State Description with the hex format values.
Thank you again @JustinG, @jimtng and @rlkoshak for your help!