Convert HEX) to Decimal

Need to covert EnergyToday (HEX) to Decimal. What is the best way to do this?


Pass the XML through an XML node to create a JS object then you could access the object properties in a function node & convert their values to numbers using parseInt.

Thanks thats the part I can get right, need to add the fn node after the change node but the code is killing me.

What's your function code?

msg.payload = parseInt("0x"+msg.payload);

this works but changes Preformatted text00BB to 187 where I want 1.87

Can add the calulator node and divide by 100 but there must be a better way?

00bb is 187

However, you want a different value, divide by 100 or use the scale node.

msg.payload = parseInt("0x"+msg.payload) / 10.0;
return msg;

However from my original suggestion above, I would have done this....

DATA > XML NODE (convert data to js object) > FUNCTION NODE (convert all values in one place)

Thanks will revise as per your advice....