I have a data read out from a modbus endpoint. This data is scaled by 100 and represents 0..100%
. That is: if I read out 2345
, that refers to 23.45%
. This same modbus endpoint also outputs temperatures with much the same kind of scaling.
Here are example item definitions I have. First the temperature one, which works much the way I would expect:
Number:Temperature Some_Temperature "Yep, it is some temperature" (InAGroup) {
channel = "modbus:data:thing:poller:temperature:number"[
profile="modbus:gainOffset", gain="0.01 °C", pre-gain-offset="0"
]
}
This item figures out that the unit for this item is °C
based on the unit specified in gain
, as documented in the modbus binding page.
However, when I write
Number:Dimensionless Some_Percentage "Yep, it is some percentage" (InAGroup) {
channel = "modbus:data:thing:poller:percentage:number"[
profile="modbus:gainOffset", gain="0.01 %", pre-gain-offset="0"
]
}
I’m now getting not 23.45%
(for modbus register of 2345
,) but rather 0.2345%
. The value has been scaled not by 0.01
, but rather by 0.0001
! On the other hand, either gain = "1 %"
or gain = "0.01"
produce the expected number (23.45
,) This in isolation wouldn’t be particularly hard to adapt to, except weird things happen when I also add the new unit = "%"
specification.
Number:Dimensionless Some_Percentage "Yep, it is some percentage" (InAGroup) {
unit = "%",
channel = "modbus:data:thing:poller:percentage:number"[
profile="modbus:gainOffset", gain="1 %", pre-gain-offset="0"
]
}
produces a different value (2345%
) than the options above, even though for the temperature item above adding unit = "°C"
results in no change whatsoever (since the thing was already providing Celsiuses).
Without having investigated much further it would seem to me that gainOffset
is interpreting the 1 %
as a… request to scale the value by 0.01
rather than a <gain> <unit>
like most other units appear to work. Is it just me not being able to wrap my head around this or is this a real bug?