Set default occupancy timeout to 60 seconds. #27

This commit is contained in:
Koenkk
2018-05-15 18:00:06 +02:00
parent ff61f24b74
commit 17aba009af
+3 -3
View File
@@ -21,6 +21,8 @@ const QBKG03LM = {
3: 'l2',
};
const occupancyTimeout = 60; // In seconds
const toPercentage = (value, min, max) => {
if (value > max) {
value = max;
@@ -177,8 +179,6 @@ const parsers = [
convert: (msg, publish) => {
// The occupancy sensor only sends a message when motion detected.
// Therefore we need to publish the no_motion detected by ourselves.
// no_motion is triggered after 3 minutes of no motion.
const noMotionTimeout = 3; // in minutes
const deviceID = msg.endpoints[0].device.ieeeAddr;
// Stop existing timer because motion is detected and set a new one.
@@ -190,7 +190,7 @@ const parsers = [
store[deviceID] = setTimeout(() => {
publish({occupancy: false})
store[deviceID] = null;
}, noMotionTimeout * 60 * 1000);
}, occupancyTimeout * 1000);
return {occupancy: true};
}
},