I have a project were im reading alot of modbus values.
This numbers comes inn as value with 4 number were you need to devide it by 100 to get the right number (1000= 10,00 celsius)
For this i have been using Javascript Transformation as suggested on forum and modbus driver. I have used the Javascript transformation on items file like this.
Number V3601Utetemp "Temperatur utetemp [JS(devideTemp.js):%s]" <temperature> { modbus="input:23" }
This works for basic UI, but for logging and habpanel this does not work.
This should probably be in the driver, but how do i do that?
.js
(function(i){
return (i / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '°C';
})(input)
In this case it still shows the same value just that it removed the “%”.
Was thinking that it was ignoring the :transformation=JS(devideTemp.js)" part of it
The presentation is about what you put in the Item’s label, you took out the part telling it to display C
Try
Number V3601Utetemp "Temperatur utetemp [%.2f °C]" ....
That’s where you first had your transform, it altered the display value but not the Item actual value.
Applying the transform to the modbus binding instead will work on the number before it gets put into the Item,
I would guess your transform is actually failing - should be able to see that in your log? - because the transform is trying to put a string with a comma and ‘°C’ into a purely Number Item.