Technically you should be able to do the whole formula in one line, but you’re absolutely right that breaking it down into variables makes long formulas a lot easier to work with. The standard + - * /
and Math.pow()
function should be all you need here.
I may have gotten the H4 and H5 from your formula backwards, but here’s a quick attempt at what it could look like:
// create shorter references for message properties
temp = msg.payload[0].HeatTreatTemperature;
time = msg.payload[0].HeatTreatTimeInSeconds;
a = (temp-820.7)/(0.0239*time); // part of the numerator
b = (temp-820.7)/(0.0239*time); // part of the denominator
numerator = 3.792 * Math.pow(2.71828, a); // plug in "a"
denominator = 1621.5 + Math.pow(2.71828, b); // plug in "b"
msg.payload = numerator/denominator;
return msg;