Filter inappropriate illumination values for Aqara P1 presence sensor
@@ -3,7 +3,7 @@ const tholdoffset = R.item('config/tholdoffset').val;
const lux = (Attr.val - 65536);
let ll = 0;
-if (lux > 0 && lux < 0xffff) {
+if (lux > 0 && lux < 65520) {
ll = Math.round(10000 * Math.log10(lux) + 1);
}
@@ -11,4 +11,4 @@ R.item('state/lightlevel').val = ll;
R.item('state/dark').val = ll <= tholddark;
R.item('state/daylight').val = ll >= tholddark + tholdoffset;
-Item.val = lux;
\ No newline at end of file
+Item.val = lux < 65520 ? lux : 0;
