Hi, I am trying to make OEE calculations with the help of node red. In this function i'm trying to calculate the availability parameter (A).
I am trying to write a function to give me the availability value, but no matter what I do, the output is NaN. It is simple math but Im new using node-red and Javascript.
Square brackets in Javascript are used to build arrays, not for grouping expressions. Try changing the first-pair of brackets to parentheses, and just eliminate the extra second-pair of brackets:
But you must ensure that ALL of your variables are defined, or the answer will be NaN (not a number). A common way to do that in Javascript is to use the 'or' operator || to set a default if there is a missing flow value, like so:
var setup = flow.get("HoraSetup") || 0;
This line effectively does nothing, and should be eliminated -- unless you plan on doing something with that value? At a minimum, it should be declared as a var, not just left as a bare name.