@camstack/addon-provider-amcrest 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +18 -11
- package/dist/addon.mjs +18 -11
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -26534,17 +26534,21 @@ var AmcrestCgiClient = class AmcrestCgiClient {
|
|
|
26534
26534
|
} catch {
|
|
26535
26535
|
return [];
|
|
26536
26536
|
}
|
|
26537
|
-
const out = /* @__PURE__ */ new Map();
|
|
26538
26537
|
const ch = channel - 1;
|
|
26538
|
+
const names = /* @__PURE__ */ new Map();
|
|
26539
|
+
const enabled = /* @__PURE__ */ new Set();
|
|
26539
26540
|
for (const [key, value] of t) {
|
|
26540
|
-
const
|
|
26541
|
-
if (
|
|
26542
|
-
|
|
26543
|
-
|
|
26541
|
+
const nameMatch = new RegExp(`^PtzPreset\\[${ch}\\]\\[(\\d+)\\]\\.Name$`).exec(key);
|
|
26542
|
+
if (nameMatch) {
|
|
26543
|
+
names.set(Number.parseInt(nameMatch[1], 10), value);
|
|
26544
|
+
continue;
|
|
26545
|
+
}
|
|
26546
|
+
const enableMatch = new RegExp(`^PtzPreset\\[${ch}\\]\\[(\\d+)\\]\\.Enable$`).exec(key);
|
|
26547
|
+
if (enableMatch && value.trim().toLowerCase() === "true") enabled.add(Number.parseInt(enableMatch[1], 10));
|
|
26544
26548
|
}
|
|
26545
|
-
return [...
|
|
26546
|
-
id,
|
|
26547
|
-
name:
|
|
26549
|
+
return [...enabled].toSorted((a, b) => a - b).map((idx) => ({
|
|
26550
|
+
id: idx + 1,
|
|
26551
|
+
name: names.get(idx) || `Preset ${idx + 1}`
|
|
26548
26552
|
}));
|
|
26549
26553
|
}
|
|
26550
26554
|
};
|
|
@@ -27178,9 +27182,12 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
|
|
|
27178
27182
|
},
|
|
27179
27183
|
savePreset: async ({ deviceId, presetId, name }) => {
|
|
27180
27184
|
if (deviceId !== this.id) return;
|
|
27181
|
-
const
|
|
27182
|
-
|
|
27183
|
-
await this.
|
|
27185
|
+
const client = this.ensureClient();
|
|
27186
|
+
const requested = Number.parseInt(presetId, 10);
|
|
27187
|
+
const used = new Set((await client.getPtzPresets(this.channel)).map((p) => p.id));
|
|
27188
|
+
let slot = Number.isFinite(requested) && requested >= 1 && !used.has(requested) ? requested : 1;
|
|
27189
|
+
while (used.has(slot)) slot += 1;
|
|
27190
|
+
await client.ptzSetPreset(this.channel, slot);
|
|
27184
27191
|
},
|
|
27185
27192
|
deletePreset: async ({ deviceId, presetId }) => {
|
|
27186
27193
|
if (deviceId !== this.id) return;
|
package/dist/addon.mjs
CHANGED
|
@@ -26535,17 +26535,21 @@ var AmcrestCgiClient = class AmcrestCgiClient {
|
|
|
26535
26535
|
} catch {
|
|
26536
26536
|
return [];
|
|
26537
26537
|
}
|
|
26538
|
-
const out = /* @__PURE__ */ new Map();
|
|
26539
26538
|
const ch = channel - 1;
|
|
26539
|
+
const names = /* @__PURE__ */ new Map();
|
|
26540
|
+
const enabled = /* @__PURE__ */ new Set();
|
|
26540
26541
|
for (const [key, value] of t) {
|
|
26541
|
-
const
|
|
26542
|
-
if (
|
|
26543
|
-
|
|
26544
|
-
|
|
26542
|
+
const nameMatch = new RegExp(`^PtzPreset\\[${ch}\\]\\[(\\d+)\\]\\.Name$`).exec(key);
|
|
26543
|
+
if (nameMatch) {
|
|
26544
|
+
names.set(Number.parseInt(nameMatch[1], 10), value);
|
|
26545
|
+
continue;
|
|
26546
|
+
}
|
|
26547
|
+
const enableMatch = new RegExp(`^PtzPreset\\[${ch}\\]\\[(\\d+)\\]\\.Enable$`).exec(key);
|
|
26548
|
+
if (enableMatch && value.trim().toLowerCase() === "true") enabled.add(Number.parseInt(enableMatch[1], 10));
|
|
26545
26549
|
}
|
|
26546
|
-
return [...
|
|
26547
|
-
id,
|
|
26548
|
-
name:
|
|
26550
|
+
return [...enabled].toSorted((a, b) => a - b).map((idx) => ({
|
|
26551
|
+
id: idx + 1,
|
|
26552
|
+
name: names.get(idx) || `Preset ${idx + 1}`
|
|
26549
26553
|
}));
|
|
26550
26554
|
}
|
|
26551
26555
|
};
|
|
@@ -27179,9 +27183,12 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
|
|
|
27179
27183
|
},
|
|
27180
27184
|
savePreset: async ({ deviceId, presetId, name }) => {
|
|
27181
27185
|
if (deviceId !== this.id) return;
|
|
27182
|
-
const
|
|
27183
|
-
|
|
27184
|
-
await this.
|
|
27186
|
+
const client = this.ensureClient();
|
|
27187
|
+
const requested = Number.parseInt(presetId, 10);
|
|
27188
|
+
const used = new Set((await client.getPtzPresets(this.channel)).map((p) => p.id));
|
|
27189
|
+
let slot = Number.isFinite(requested) && requested >= 1 && !used.has(requested) ? requested : 1;
|
|
27190
|
+
while (used.has(slot)) slot += 1;
|
|
27191
|
+
await client.ptzSetPreset(this.channel, slot);
|
|
27185
27192
|
},
|
|
27186
27193
|
deletePreset: async ({ deviceId, presetId }) => {
|
|
27187
27194
|
if (deviceId !== this.id) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-amcrest",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Amcrest/Dahua camera device provider addon for CamStack — Dahua CGI over HTTP(S) with digest auth (snapshot, RTSP catalog, PTZ, image/day-night config)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|