Skip to content

Commit

Permalink
amcrest: httpsAgent usage fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Sep 18, 2023
1 parent 4001fc9 commit b497718
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 28 deletions.
4 changes: 2 additions & 2 deletions plugins/amcrest/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/amcrest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scrypted/amcrest",
"version": "0.0.125",
"version": "0.0.127",
"description": "Amcrest Plugin for Scrypted",
"author": "Scrypted",
"license": "Apache",
Expand Down
47 changes: 22 additions & 25 deletions plugins/amcrest/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration,
for (const element of deviceParameters) {
try {
const response = await this.getClient().digestAuth.request({
httpsAgent: amcrestHttpsAgent,
url: `http://${this.getHttpAddress()}/cgi-bin/magicBox.cgi?action=${element.action}`
});

Expand Down Expand Up @@ -147,6 +148,7 @@ class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration,
return;

const response = await this.getClient().digestAuth.request({
httpsAgent: amcrestHttpsAgent,
url: `http://${this.getHttpAddress()}/cgi-bin/configManager.cgi?action=setConfig&${params}`
});
this.console.log('reconfigure result', response.data);
Expand Down Expand Up @@ -190,14 +192,11 @@ class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration,
|| event === AmcrestEvent.PhoneCallDetectStart
|| event === AmcrestEvent.AlarmIPCStart
|| event === AmcrestEvent.DahuaTalkInvite) {
if (event === AmcrestEvent.DahuaTalkInvite && payload && multipleCallIds)
{
if (payload.includes(callerId))
{
if (event === AmcrestEvent.DahuaTalkInvite && payload && multipleCallIds) {
if (payload.includes(callerId)) {
this.binaryState = true;
}
} else
{
} else {
this.binaryState = true;
}
}
Expand Down Expand Up @@ -259,25 +258,23 @@ class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration,

if (!twoWayAudio)
twoWayAudio = isDoorbell ? 'Amcrest' : 'None';


if (doorbellType == DAHUA_DOORBELL_TYPE)
{


if (doorbellType == DAHUA_DOORBELL_TYPE) {
ret.push(
{
title: 'Multiple Call Buttons',
key: 'multipleCallIds',
description: 'Some Dahua Doorbells integrate multiple Call Buttons for apartment buildings.',
type: 'boolean',
value: (this.storage.getItem('multipleCallIds') === 'true').toString(),
}
{
title: 'Multiple Call Buttons',
key: 'multipleCallIds',
description: 'Some Dahua Doorbells integrate multiple Call Buttons for apartment buildings.',
type: 'boolean',
value: (this.storage.getItem('multipleCallIds') === 'true').toString(),
}
);
}

const multipleCallIds = this.storage.getItem('multipleCallIds');

if (multipleCallIds)
{
if (multipleCallIds) {
ret.push(
{
title: 'Caller ID',
Expand All @@ -288,7 +285,7 @@ class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration,
}
)
}


ret.push(
{
Expand All @@ -309,11 +306,11 @@ class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration,
);

return ret;

}




async takeSmartCameraPicture(option?: PictureOptions): Promise<MediaObject> {
return this.createMediaObject(await this.getClient().jpegSnapshot(), 'image/jpeg');
Expand Down Expand Up @@ -490,7 +487,7 @@ class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration,
this.videoStreamOptions = undefined;

super.putSetting(key, value);

this.updateDevice();
this.updateDeviceInfo();
}
Expand Down

0 comments on commit b497718

Please sign in to comment.