diff --git a/plugins/homekit/package-lock.json b/plugins/homekit/package-lock.json index e4e53ccf7..c63f0dc14 100644 --- a/plugins/homekit/package-lock.json +++ b/plugins/homekit/package-lock.json @@ -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", diff --git a/plugins/homekit/package.json b/plugins/homekit/package.json index f7bc7730e..07c1442ae 100644 --- a/plugins/homekit/package.json +++ b/plugins/homekit/package.json @@ -40,5 +40,5 @@ "@types/qrcode": "^1.4.1", "@types/url-parse": "^1.4.3" }, - "version": "0.0.130" + "version": "0.0.131" } diff --git a/plugins/homekit/src/types/camera.ts b/plugins/homekit/src/types/camera.ts index 16ba8a1ed..9644276a4 100644 --- a/plugins/homekit/src/types/camera.ts +++ b/plugins/homekit/src/types/camera.ts @@ -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); }