I purchased a Tuya WIFI dimmer what I could connect to OH via Tuya_Mqtt and Mosquito.
Issue is that the Tuya dimmer brightness is adjustable in a range of 1-1000. Dimmer Things / Items in OH can play in scale 0-100 range so I could play with the brightness in 0-10% range.
Is there a way to extend it?
(if I initiate the Item as Number than it works well of course)
Sure. The whole idea of Items is to represent many and various devices as idealized standard models. Leave the Dimmer Item alone, and instead do a transformation scaling in the binding channel.
That’s just maths. (As you point out, although this is “scaling”, the SCALE transform is not the one for this job.)
We can do any maths in a javascript transform.
I think you’d need two JS scripts here,one to multiply by 10 on the way out, one to divide by ten on the way in.
Similar examples in modbus binding docs -
In the MQTT channel, you’d be looking to use transformationPattern (for inbound) and transformationPatternOut
and the JS transformation (multiply10 is the same):
divide10.js
(function(inputData) {
// on read: the polled number as string
// on write: openHAB command as string
var DIVIDE_BY = 10;
return Math.round(parseFloat(inputData) / DIVIDE_BY);
})(input)