ring: fix busted ass ring polling/push

This commit is contained in:
Koushik Dutta
2023-05-24 17:58:51 -07:00
parent af02753cef
commit f730d13cbd
3 changed files with 21 additions and 6 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/ring",
"version": "0.0.109",
"version": "0.0.110",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@scrypted/ring",
"version": "0.0.109",
"version": "0.0.110",
"dependencies": {
"@koush/ring-client-api": "file:../../external/ring-client-api",
"@scrypted/common": "file:../../common",
@@ -49,7 +49,7 @@
},
"../../sdk": {
"name": "@scrypted/sdk",
"version": "0.2.86",
"version": "0.2.101",
"license": "ISC",
"dependencies": {
"@babel/preset-typescript": "^7.18.6",

View File

@@ -44,5 +44,5 @@
"got": "11.8.6",
"socket.io-client": "^2.5.0"
},
"version": "0.0.109"
"version": "0.0.110"
}

View File

@@ -101,14 +101,29 @@ export class RingCameraDevice extends ScryptedDeviceBase implements DeviceProvid
this.console.log(camera.name, 'onDoorbellPressed', e);
this.triggerBinaryState();
});
let motionTimeout: NodeJS.Timeout;
const resetTimeout = () => {
clearTimeout(motionTimeout);
motionTimeout = setTimeout(() => this.motionDetected = false, 30000);
};
camera.onMotionDetected?.subscribe(async motionDetected => {
if (motionDetected)
if (motionDetected) {
this.console.log(camera.name, 'onMotionDetected');
resetTimeout();
}
else {
clearTimeout(motionTimeout);
}
this.motionDetected = motionDetected;
});
camera.onMotionDetectedPolling?.subscribe(async motionDetected => {
if (motionDetected)
if (motionDetected) {
this.console.log(camera.name, 'onMotionDetected');
resetTimeout();
}
else {
clearTimeout(motionTimeout);
}
this.motionDetected = motionDetected;
});
camera.onBatteryLevel?.subscribe(async () => {