I have a modbus sensor that reports temperature as an integer which has to be divided by 10 to get degrees C
My locale uses deg F so I would like to convert the value reported by the sensor to Deg F before it gets passed on to the item.
I tried a JS transform
JS(| parseFloat(modbus:data:a4c516c727:52c183bf22:number) * 0.18 + 32)
but I don’t see any change. What should I use as the argument to be passed on to the JS function?
Can someone point me to the correct way of doing this?
The binding docs show how to use scaling to report the sensor value as received, importantly with the unit °C appended.
To make use of a value with a unit, you will need a Quantity type target i.e. make your Item a Number:Temperature type.
Finally, the default unit for such Items may be automatically assigned by your locale, or if you wish, by setting metadata for your individual Item.
Conversion from supplied units to desired units is carried out automatically.
Thank you, my problem was that I set the wrong register to read and was reading humidity as a signed integer instead of the temperature data as a signed integer.
Now with the correct data and the gain function correction everything works as it should