The reading of the value works and I get something like “20 °C”. When I change value on the device, the item in openhab gets updated.
But, when I use the stepper on the item configuration page to change the value I get the following warning:
22:08:42.445,"WARN","org.openhab.binding.modbus.internal.profiles.ModbusGainOffsetProfile","Cannot apply gain ('0.1 °C') and pre-gain-offset ('100') to state ('21') (formula '21'/'0.1 °C' - '100') because types do not match (towardsItem=false): Cannot process command '21', unit should compatible with gain"
How do I get the stepper to return the value including the unit?
What do you see in events.log when you change the value using that widget?
The first thing I would try is add a “default stand-alone widget” and set the min, max, step and offset to a value with units. See if that makes a difference.
Also check your state description pattern. It shouldn’t matter but before OH 4 it did have influence.
The gain-offset profile has often been troublesome. In a pinch, a script transform could be used which we can make work with the UoM.
It is not allowed to enter units in the min, max, step and offset fields in the “default stand-alone widget”.
State description pattern
%.1f °C
Logs
18:52:25.706,"INFO","openhab.event.ItemCommandEvent","Item 'GenvexTemperaturSP_ValueasNumber' received command 21"
18:52:25.707,"WARN","org.openhab.binding.modbus.internal.profiles.ModbusGainOffsetProfile","Cannot apply gain ('0.1 °C') and pre-gain-offset ('100') to state ('21') (formula '21'/'0.1 °C' - '100') because types do not match (towardsItem=false): Cannot process command '21', unit should compatible with gain"
18:52:25.709,"INFO","openhab.event.ItemStatePredictedEvent","Item 'GenvexTemperaturSP_ValueasNumber' predicted to become 21"
18:52:25.711,"INFO","openhab.event.ItemStateChangedEvent","Item 'GenvexTemperaturSP_ValueasNumber' changed from 20.1 °C to 21 °C"
18:52:26.065,"INFO","openhab.event.ItemStateChangedEvent","Item 'GenvexTemperaturSP_ValueasNumber' changed from 21 °C to 20.1 °C"