amcrest: ad110 doorbell fix

This commit is contained in:
Koushik Dutta
2022-04-06 12:10:54 -07:00
parent 224ccc7b96
commit c6e41dcaf5
6 changed files with 183 additions and 7 deletions

60
plugins/amcrest/ad110.md Normal file
View File

@@ -0,0 +1,60 @@
# Amcrest Doorbell 110
Below is the doorbell event from an AD110:
```
event --myboundary
Content-Type: text/plain
Content-Length:135
Code=NTPAdjustTime;action=Pulse;index=0;data={
"Address" : "200.160.0.8",
"Before" : "2022-04-06 20:07:56",
"result" : true
}
event --myboundary
Content-Type: text/plain
Content-Length:148
Code=_DoTalkAction_;action=Pulse;index=0;data={
"Action" : "Invite",
"CallID" : "20220406200813@670064@192.168.x.x”,
"CallSrcMask" : 4
}
event --myboundary
Content-Type: text/plain
Content-Length:68
Code=CallNoAnswered;action=Start;index=0;data={
"CallID" : "8"
}
[HomeKit]: snapshot requested for reason: 1
[HomeKit]: snapshot requested for reason: 1
[HomeKit]: snapshot requested for reason: 1
event --myboundary
Content-Type: text/plain
Content-Length:39
Code=CallNoAnswered;action=Stop;index=0
event --myboundary
Content-Type: text/plain
Content-Length:185
Code=_DoTalkAction_;action=Pulse;index=0;data={
"Action" : "Hangup",
"CallID" : "20220406200813@670064@192.168.x.x”,
"CallSrcMask" : 4,
"HangupReason" : "HangupByPhone"
}
```

106
plugins/amcrest/ad410.md Normal file
View File

@@ -0,0 +1,106 @@
# Amcrest Doorbell 410
Below is the doorbell event from an AD410:
```
event --myboundary
Content-Type: text/plain
Content-Length:41
Code=_CallRemoveMask;action=Start;index=0
event --myboundary
Content-Type: text/plain
Content-Length:36
Code=AlarmLocal;action=Start;index=0
event --myboundary
Content-Type: text/plain
Content-Length:148
Code=_DoTalkAction_;action=Pulse;index=0;data={
"Action" : "Invite",
"CallID" : "20220406135211@095697@192.168.10.20",
"CallSrcMask" : 4
}
event --myboundary
Content-Type: text/plain
Content-Length:68
Code=CallNoAnswered;action=Start;index=0;data={
"CallID" : "4"
}
event --myboundary
Content-Type: text/plain
Content-Length:41
Code=PhoneCallDetect;action=Start;index=0
event --myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0
event --myboundary
Content-Type: text/plain
Content-Length:185
Code=_DoTalkAction_;action=Pulse;index=0;data={
"Action" : "Hangup",
"CallID" : "20220406135211@095697@192.168.10.20",
"CallSrcMask" : 4,
"HangupReason" : "HangupByPhone"
}
event --myboundary
Content-Type: text/plain
Content-Length:35
Code=AlarmLocal;action=Stop;index=0
event --myboundary
Content-Type: text/plain
Content-Length:39
Code=CallNoAnswered;action=Stop;index=0
event --myboundary
Content-Type: text/plain
Content-Length:95
Code=VideoMotion;action=Stop;index=0;data={
"Id" : [ 0 ],
"RegionName" : [ "Region1" ]
}
event --myboundary
Content-Type: text/plain
Content-Length:40
Code=PhoneCallDetect;action=Stop;index=0
event --myboundary
Content-Type: text/plain
Content-Length:40
Code=_CallRemoveMask;action=Stop;index=0
```

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/amcrest",
"version": "0.0.94",
"version": "0.0.95",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/amcrest",
"version": "0.0.94",
"version": "0.0.95",
"license": "Apache",
"dependencies": {
"@koush/axios-digest-auth": "^0.8.5",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/amcrest",
"version": "0.0.94",
"version": "0.0.95",
"description": "Amcrest Plugin for Scrypted",
"author": "Scrypted",
"license": "Apache",

View File

@@ -74,7 +74,7 @@ export class AmcrestCameraClient {
// this.console?.log('event', data);
for (const event of Object.values(AmcrestEvent)) {
if (data.indexOf(event) !== -1) {
stream.emit('event', event, index);
stream.emit('event', event, index, data);
}
}
});

View File

@@ -137,7 +137,7 @@ class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration,
if (this.storage.getItem('debug'))
this.console.log('event', data.toString());
});
events.on('event', (event: AmcrestEvent, index: string) => {
events.on('event', (event: AmcrestEvent, index: string, payload: string) => {
const channelNumber = this.getRtspChannel();
if (channelNumber) {
const idx = parseInt(index) + 1;
@@ -158,14 +158,24 @@ class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration,
}
else if (event === AmcrestEvent.TalkInvite
|| event === AmcrestEvent.PhoneCallDetectStart
|| event === AmcrestEvent.AlarmIPCStart || event === AmcrestEvent.DahuaTalkInvite) {
|| event === AmcrestEvent.AlarmIPCStart
|| event === AmcrestEvent.DahuaTalkInvite) {
this.binaryState = true;
}
else if (event === AmcrestEvent.TalkHangup
|| event === AmcrestEvent.PhoneCallDetectStop
|| event === AmcrestEvent.AlarmIPCStop || event === AmcrestEvent.DahuaTalkHangup) {
|| event === AmcrestEvent.AlarmIPCStop
|| event === AmcrestEvent.DahuaTalkHangup) {
this.binaryState = false;
}
else if (event === AmcrestEvent.TalkPulse && doorbellType === AMCREST_DOORBELL_TYPE) {
if (payload.includes('Invite')) {
this.binaryState = true;
}
else if (payload.includes('Hangup')) {
this.binaryState = false;
}
}
else if (event === AmcrestEvent.DahuaTalkPulse && doorbellType === DAHUA_DOORBELL_TYPE) {
clearTimeout(pulseTimeout);
pulseTimeout = setTimeout(() => this.binaryState = false, 3000);