homekit: fix object detection denoising

This commit is contained in:
Koushik Dutta
2021-12-06 14:33:59 -08:00
parent 83ed7e899c
commit 95722dfcd2
3 changed files with 9 additions and 8 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/homekit",
"version": "0.0.130",
"version": "0.0.131",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/homekit",
"version": "0.0.130",
"version": "0.0.131",
"dependencies": {
"hap-nodejs": "file:../../external/HAP-NodeJS",
"lodash": "^4.17.21",

View File

@@ -40,5 +40,5 @@
"@types/qrcode": "^1.4.1",
"@types/url-parse": "^1.4.3"
},
"version": "0.0.130"
"version": "0.0.131"
}

View File

@@ -577,6 +577,7 @@ addSupportedType({
const resetSensorTimeout = () => {
clearTimeout(timeout);
timeout = setTimeout(() => {
contactState = Characteristic.ContactSensorState.CONTACT_DETECTED;
sensor.updateCharacteristic(Characteristic.ContactSensorState, contactState);
}, (parseInt(storage.getItem('objectDetectionContactSensorTimeout')) || defaultObjectDetectionContactSensorTimeout) * 1000)
}
@@ -589,14 +590,12 @@ addSupportedType({
if (!isPerson) {
if (!ed.detections)
return contactState;
const objects = ed.detections.map(d => d.className);
if (objects.includes(ojs)) {
contactState = Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
resetSensorTimeout();
}
else {
contactState = Characteristic.ContactSensorState.CONTACT_DETECTED;
}
return contactState;
}
@@ -605,8 +604,10 @@ addSupportedType({
return contactState;
const people = ed.people.map(d => 'Person: ' + d.label);
contactState = people.includes(ojs) ? Characteristic.ContactSensorState.CONTACT_NOT_DETECTED : Characteristic.ContactSensorState.CONTACT_DETECTED;
if (people.includes(ojs)) {
contactState = Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
resetSensorTimeout();
}
return contactState;
}, true);
}