Make BaseModule ignore erroneous sensor values?
Posted: 17 May 2018 16:51
So I occasionally get absolutely crazy outputs from the sensors in my Z-wave network. For example, My bedroom has never reached 410 degrees
I went digging around, and found that the BaseModule module does have some code that seems related to dealing with these errors, but it is only supposed to print a message in the logs, with dropping the bad value being on the "to-do" list.
Is there any word on when this TODO will be done? I know it's a minor thing, but it drives me nuts, and BaseModule does not seem to have gotten any love in over a year.
This does not just happen with my Aeotec Multisensors, this also happens with the voltage readings from my Zooz power switches, and a couple of plug in power switches from monoprice. So this does not appear to be a device specific problem. These sorts of readings wind up triggering rules based on these sensors, which is less than ideal. It also completely screws up the auto scaling of my monitoring graphs. I went digging around, and found that the BaseModule module does have some code that seems related to dealing with these errors, but it is only supposed to print a message in the logs, with dropping the bad value being on the "to-do" list.
Code: Select all
// Warn on big level changes - TODO maybe deny too big changes
if (deviceType === 'sensorMultilevel') {
var diff = Math.abs(lastLevel-newLevel);
var probeType = vDev.get('metrics:probeType');
// Ignore diff for changes of more than 4 hours
if (modificationTime-lastUpdate > (4*60*60)) {
diff = 0;
}
if (
(probeType == 'luminosity' && (diff > 250 || newLevel > 1000 || newLevel < 0)) ||
(probeType == 'temperature' && (diff > 10 || newLevel > 50 || newLevel < -30)) ||
(probeType == 'humidity' && (diff > 20 || newLevel > 100 || newLevel < 5)) ||
(probeType == 'ultraviolet' && (diff > 4 || newLevel > 15 || newLevel < -1))
) {
self.error('Unlikely '+probeType+' level change from '+lastLevel+' to '+newLevel+' for '+vDev.id);
}
}