I have problems in understanding what causes ghost values/outliers (?) reported from my custom made sensor.
First of all, I have many temperature sensors, constantly reporting temperatures over MQTT. In HA/Node Red, I use a standard “MQTT In”-node for receivement.
filter temp diff > 1 °C
-node:
const oldMeanTempC = parseFloat(context.get("oldMeanTempC")) || 0;
const currentMeanTempC = parseFloat(msg.payload);
context.set("oldMeanTempC", currentMeanTempC);
const tempDiffTooBig = (currentTempC, previousTemp) => {
const MAX_TEMP_DIFFERENCE_C = 1;
const tooBig = Math.abs(currentTempC - previousTemp) > MAX_TEMP_DIFFERENCE_C;
node.status({ fill: "yellow", shape: "dot", text: `Math.abs(${currentTempC}-${previousTemp}) > ${MAX_TEMP_DIFFERENCE_C} -> ${tooBig}`});
return tooBig;
}
if (tempDiffTooBig(currentMeanTempC, oldMeanTempC)) {
node.status({ fill: "red", shape: "dot", text: `outlier temp value (${msg.payload} °C)` });
return null;
}
node.status({ fill: "green", shape: "dot", text: `${msg.payload} °C` });
return msg;
What on earth may cause all those strange bottom peaks in my first illustration? As you can see, I first calculate mean value based on 10 previous value, then I even actively discard values (return null;
) if a value difference is > 1 from earlier reported.
What can I do to get rid of these outliers?