I try to publish on a screen my electricity production but with the sensor that i use, i have on the screen a too big number with 2 decimals, for example 1835,48 W. I would like to split the decimals to show on the screen only 1835 W. I don't know how to do.. Does anybody know how i have to edit my script ?
var value = msg.payload;
var unit = msg.data.attributes.unit_of_measurement; //msg.payload = price;
msg.payload = {
// "text": value + ' W',
"text": value + ' ' + unit,
"icon": 42453,
"duration": 4,
"repeat": 1,
"pushIcon": 3
};
I'm sure there are different ways of doing this but this is the way I do it. I add this line right before the return msg;
msg.payload = Math.trunc(msg.payload);