FIX: Prevent light sensor values from going out of bounds

This commit is contained in:
S'pht'Kr
2015-09-11 05:43:33 +02:00
parent 3c35311c4a
commit 3da6fcb510

View File

@@ -584,7 +584,10 @@ ZWayServerAccessory.prototype = {
if(vdev.metrics.scaleTitle === "%"){
// Completely unscientific guess, based on test-fit data and Wikipedia real-world lux values.
// This will probably change!
return 0.0005 * (vdev.metrics.level^3.6);
var lux = 0.0005 * (vdev.metrics.level^3.6);
if(lux < cx.minimumValue) return cx.minimumValue;
if(lux > cx.maximumValue) return cx.maximumValue;
return lux;
} else {
return vdev.metrics.level;
}