From 5f8ac6988e6abaacffbab46e1985bc6652ce641b Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Sat, 16 Oct 2021 16:01:00 -0700 Subject: [PATCH] amcrest: doorbell pulse fix --- plugins/amcrest/package-lock.json | 25 ++++++++++++++----------- plugins/amcrest/package.json | 5 ++++- plugins/amcrest/src/amcrest-api.ts | 1 + plugins/amcrest/src/main.ts | 7 +++++++ 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/plugins/amcrest/package-lock.json b/plugins/amcrest/package-lock.json index 68104d0ac..3d6da696c 100644 --- a/plugins/amcrest/package-lock.json +++ b/plugins/amcrest/package-lock.json @@ -1,23 +1,26 @@ { "name": "@scrypted/amcrest", - "version": "0.0.56", + "version": "0.0.57", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/amcrest", - "version": "0.0.56", + "version": "0.0.57", "license": "Apache", "dependencies": { "@koush/axios-digest-auth": "^0.7.2", "@scrypted/sdk": "file:../../sdk", "@types/multiparty": "^0.0.33", "multiparty": "^4.2.2" + }, + "devDependencies": { + "@types/node": "^16.11.0" } }, "../../sdk": { "name": "@scrypted/sdk", - "version": "0.0.79", + "version": "0.0.81", "license": "ISC", "dependencies": { "@babel/core": "^7.2.2", @@ -30,7 +33,7 @@ "@babel/preset-typescript": "^7.15.0", "@types/node": "^16.6.1", "adm-zip": "^0.4.13", - "axios": "^0.21.1", + "axios": "^0.21.4", "babel-loader": "^8.0.4", "babel-plugin-const-enum": "^1.1.0", "babel-plugin-minify-dead-code-elimination": "^0.5.1", @@ -91,9 +94,9 @@ } }, "node_modules/@types/node": { - "version": "16.7.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.10.tgz", - "integrity": "sha512-S63Dlv4zIPb8x6MMTgDq5WWRJQe56iBEY0O3SOFA9JrRienkOVDXSXBjjJw6HTNQYSE2JI6GMCR6LVbIMHJVvA==" + "version": "16.11.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.0.tgz", + "integrity": "sha512-8MLkBIYQMuhRBQzGN9875bYsOhPnf/0rgXGo66S2FemHkhbn9qtsz9ywV1iCG+vbjigE4WUNVvw37Dx+L0qsPg==" }, "node_modules/axios": { "version": "0.21.1", @@ -245,7 +248,7 @@ "@babel/preset-typescript": "^7.15.0", "@types/node": "^16.6.1", "adm-zip": "^0.4.13", - "axios": "^0.21.1", + "axios": "^0.21.4", "babel-loader": "^8.0.4", "babel-plugin-const-enum": "^1.1.0", "babel-plugin-minify-dead-code-elimination": "^0.5.1", @@ -281,9 +284,9 @@ } }, "@types/node": { - "version": "16.7.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.10.tgz", - "integrity": "sha512-S63Dlv4zIPb8x6MMTgDq5WWRJQe56iBEY0O3SOFA9JrRienkOVDXSXBjjJw6HTNQYSE2JI6GMCR6LVbIMHJVvA==" + "version": "16.11.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.0.tgz", + "integrity": "sha512-8MLkBIYQMuhRBQzGN9875bYsOhPnf/0rgXGo66S2FemHkhbn9qtsz9ywV1iCG+vbjigE4WUNVvw37Dx+L0qsPg==" }, "axios": { "version": "0.21.1", diff --git a/plugins/amcrest/package.json b/plugins/amcrest/package.json index fb34bf3d1..54614da97 100644 --- a/plugins/amcrest/package.json +++ b/plugins/amcrest/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/amcrest", - "version": "0.0.56", + "version": "0.0.57", "description": "Amcrest Plugin for Scrypted", "author": "Scrypted", "license": "Apache", @@ -33,5 +33,8 @@ "@scrypted/sdk": "file:../../sdk", "@types/multiparty": "^0.0.33", "multiparty": "^4.2.2" + }, + "devDependencies": { + "@types/node": "^16.11.0" } } diff --git a/plugins/amcrest/src/amcrest-api.ts b/plugins/amcrest/src/amcrest-api.ts index 23470dbfa..650b53e6b 100644 --- a/plugins/amcrest/src/amcrest-api.ts +++ b/plugins/amcrest/src/amcrest-api.ts @@ -9,6 +9,7 @@ export enum AmcrestEvent { AudioStop = "Code=AudioMutation;action=Stop", TalkInvite = "Code=_DoTalkAction_;action=Invite", TalkHangup = "Code=_DoTalkAction_;action=Hangup", + TalkPulse = "Code=_DoTalkAction_;action=Pulse", AlarmIPCStart = "Code=AlarmIPC;action=Start", AlarmIPCStop = "Code=AlarmIPC;action=Stop", PhoneCallDetectStart = "Code=PhoneCallDetect;action=Start", diff --git a/plugins/amcrest/src/main.ts b/plugins/amcrest/src/main.ts index c9e63e65c..cedcc82ad 100644 --- a/plugins/amcrest/src/main.ts +++ b/plugins/amcrest/src/main.ts @@ -34,6 +34,8 @@ class AmcrestCamera extends RtspSmartCamera implements Camera, Intercom { events.destroy(); }; + let pulseTimeout: NodeJS.Timeout; + events.on('close', () => ret.emit('error', new Error('close'))); events.on('error', e => ret.emit('error', e)); events.on('event', (event: AmcrestEvent) => { @@ -59,6 +61,11 @@ class AmcrestCamera extends RtspSmartCamera implements Camera, Intercom { || event === AmcrestEvent.AlarmIPCStop) { this.binaryState = false; } + else if (event === AmcrestEvent.TalkPulse) { + clearTimeout(pulseTimeout); + pulseTimeout = setTimeout(() => this.binaryState = false, 30000); + this.binaryState = true; + } }) } catch (e) {