iobroker.agent-dvr 0.4.3 → 0.5.1
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/README.de.md +116 -12
- package/README.md +110 -12
- package/admin/assets/{index-DSBe1npE.js → index-D01Axkcs.js} +19 -19
- package/admin/assets/index-D7mDAij8.js +685 -0
- package/admin/assets/{index-_IaWp3oU.js → index-D867V7Ib.js} +1 -1
- package/admin/assets/{index-CNOz09VA.js → index-OlM-izPi.js} +1 -1
- package/admin/assets/{index-Dqw9GB72.js → index-q6fPDLUP.js} +1 -1
- package/admin/i18n/de.json +14 -5
- package/admin/i18n/en.json +14 -5
- package/admin/i18n/es.json +14 -5
- package/admin/i18n/fr.json +14 -5
- package/admin/i18n/it.json +14 -5
- package/admin/i18n/nl.json +14 -5
- package/admin/i18n/pl.json +14 -5
- package/admin/i18n/pt.json +14 -5
- package/admin/i18n/ru.json +14 -5
- package/admin/i18n/uk.json +14 -5
- package/admin/i18n/zh-cn.json +14 -5
- package/admin/index_m.html +1 -1
- package/build/main.js +196 -53
- package/build/main.js.map +3 -3
- package/io-package.json +256 -254
- package/lib/web.js +249 -6
- package/package.json +1 -1
- package/www/index.html +1336 -126
- package/admin/assets/index-B13Ujb6j.js +0 -685
- package/admin/assets/index-Bez3QfoS.js +0 -685
- package/admin/assets/index-D7I0OIPq.js +0 -685
- package/admin/assets/index-DFh6AKdK.js +0 -685
- package/admin/assets/index-t1B1rnou.js +0 -685
package/build/main.js
CHANGED
|
@@ -295,6 +295,7 @@ class AgentDvr extends utils.Adapter {
|
|
|
295
295
|
ensuredFolders = /* @__PURE__ */ new Set();
|
|
296
296
|
registry = /* @__PURE__ */ new Map();
|
|
297
297
|
ptzActive = /* @__PURE__ */ new Map();
|
|
298
|
+
ptzPresetNames = /* @__PURE__ */ new Map();
|
|
298
299
|
widgetSig = {};
|
|
299
300
|
profileSig = "";
|
|
300
301
|
lastCamNames = [];
|
|
@@ -562,13 +563,16 @@ class AgentDvr extends utils.Adapter {
|
|
|
562
563
|
}
|
|
563
564
|
}
|
|
564
565
|
}
|
|
565
|
-
async writeLeaf(id, val) {
|
|
566
|
+
async writeLeaf(id, val, unit) {
|
|
566
567
|
const t = typeof val;
|
|
567
568
|
let common;
|
|
568
569
|
if (t === "boolean") {
|
|
569
570
|
common = { name: id.split(".").pop() || id, type: "boolean", role: "indicator", read: true, write: false };
|
|
570
571
|
} else if (t === "number") {
|
|
571
572
|
common = { name: id.split(".").pop() || id, type: "number", role: "value", read: true, write: false };
|
|
573
|
+
if (unit) {
|
|
574
|
+
common.unit = unit;
|
|
575
|
+
}
|
|
572
576
|
} else {
|
|
573
577
|
const role = typeof val === "string" && /^https?:\/\//i.test(val) ? "text.url" : "text";
|
|
574
578
|
common = { name: id.split(".").pop() || id, type: "string", role, read: true, write: false };
|
|
@@ -810,6 +814,7 @@ class AgentDvr extends utils.Adapter {
|
|
|
810
814
|
await this.ensureButton(cid, `PTZ ${p.id}`, { kind: "ptz", oid: d.oid, dir: p.dir });
|
|
811
815
|
}
|
|
812
816
|
}
|
|
817
|
+
await this.buildPtzPresets(d, fid);
|
|
813
818
|
}
|
|
814
819
|
if (d.ot === 2) {
|
|
815
820
|
const sfx = { kind: "levelCmd", path: "/command/setSensitivity", oid: d.oid, ot: d.ot };
|
|
@@ -874,7 +879,43 @@ class AgentDvr extends utils.Adapter {
|
|
|
874
879
|
await this.fetchSnapshotB64(d.oid, snapId);
|
|
875
880
|
}
|
|
876
881
|
}
|
|
882
|
+
if (!this.ensuredFolders.has(`${fid}._widgetMigrated`)) {
|
|
883
|
+
this.ensuredFolders.add(`${fid}._widgetMigrated`);
|
|
884
|
+
await this.delObjectAsync(`${fid}.widget`).catch(() => void 0);
|
|
885
|
+
}
|
|
877
886
|
await this.updateCameraEvents(d, fid);
|
|
887
|
+
if (this.config.enableWidget && d.ot === 2) {
|
|
888
|
+
await this.updateLiveWidget(d, fid);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
// ---- PTZ presets ----
|
|
892
|
+
async buildPtzPresets(d, fid) {
|
|
893
|
+
var _a;
|
|
894
|
+
const selectorId = `${fid}.control.ptz.preset`;
|
|
895
|
+
if (!this.ptzPresetNames.has(d.oid)) {
|
|
896
|
+
const res = await this.apiGet(`/command/ptzpresets?oid=${d.oid}&ot=2`);
|
|
897
|
+
const json = asJson(res.data);
|
|
898
|
+
const raw = json && Array.isArray(json.presets) ? json.presets : [];
|
|
899
|
+
const names2 = raw.map((p) => {
|
|
900
|
+
var _a2, _b;
|
|
901
|
+
return toStr((_b = (_a2 = p.name) != null ? _a2 : p.token) != null ? _b : "");
|
|
902
|
+
}).filter(Boolean);
|
|
903
|
+
this.ptzPresetNames.set(d.oid, names2);
|
|
904
|
+
}
|
|
905
|
+
const names = (_a = this.ptzPresetNames.get(d.oid)) != null ? _a : [];
|
|
906
|
+
if (!names.length) {
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
const states = {};
|
|
910
|
+
names.forEach((n, i) => {
|
|
911
|
+
states[i] = n;
|
|
912
|
+
});
|
|
913
|
+
await this.ensureSelector(
|
|
914
|
+
selectorId,
|
|
915
|
+
"Preset",
|
|
916
|
+
{ kind: "ptzPreset", oid: d.oid, ot: d.ot, presetNames: names },
|
|
917
|
+
states
|
|
918
|
+
);
|
|
878
919
|
}
|
|
879
920
|
// ---- event formatting ----
|
|
880
921
|
fmtEvent(ev, oid) {
|
|
@@ -887,13 +928,14 @@ class AgentDvr extends utils.Adapter {
|
|
|
887
928
|
const dur = e.d != null ? String(e.d) : "";
|
|
888
929
|
const tag = (_b = e.tg) != null ? _b : "";
|
|
889
930
|
const ms = (parseFloat(String((_c = e.c) != null ? _c : 0)) - 621355968e9) / 1e4;
|
|
931
|
+
const ts = Number.isFinite(ms) ? Math.round(ms) : 0;
|
|
890
932
|
const dt = new Date(ms);
|
|
891
933
|
const two = (n) => String(n).padStart(2, "0");
|
|
892
934
|
const date = `${two(dt.getDate())}.${two(dt.getMonth() + 1)}.`;
|
|
893
935
|
const time = `${two(dt.getHours())}:${two(dt.getMinutes())}`;
|
|
894
936
|
const thumb = `${this.baseUrl}/fileThumb.jpg?oid=${oid}&fn=${encodeURIComponent(jpg)}`;
|
|
895
937
|
const video = `${this.baseUrl}/streamFile.cgi?oid=${oid}&ot=2&fn=${encodeURIComponent(fn)}`;
|
|
896
|
-
return { fn, sizeMB, dur, tag, date, time, thumb, video };
|
|
938
|
+
return { fn, sizeMB, dur, tag, date, time, thumb, video, ts };
|
|
897
939
|
}
|
|
898
940
|
// ---- gallery HTML builders ----
|
|
899
941
|
effectiveMinCol() {
|
|
@@ -1029,9 +1071,50 @@ class AgentDvr extends utils.Adapter {
|
|
|
1029
1071
|
const grid = tiles ? `<div class="advgrid">${tiles}</div>` : `<div class="advempty">No cameras</div>`;
|
|
1030
1072
|
return `<style>${galleryCss(minCol, maxW)}</style>${grid}`;
|
|
1031
1073
|
}
|
|
1074
|
+
buildSingleCamLiveHtml(d) {
|
|
1075
|
+
const minCol = this.config.widgetMinCol || 150;
|
|
1076
|
+
const maxW = this.config.widgetMaxModalWidth || 900;
|
|
1077
|
+
const PAUSE_ATTR = ` onchange="if(!this.checked){var m=this.nextElementSibling.nextElementSibling,v=m&&m.querySelector('video');if(v){v.pause();}}"`;
|
|
1078
|
+
const oid = d.oid;
|
|
1079
|
+
const id = `advlive${sanitize(oid)}`;
|
|
1080
|
+
const grab = `${this.baseUrl}/grab.jpg?oid=${oid}&ot=2&maintainAR=1`;
|
|
1081
|
+
const webm = `${this.baseUrl}/video.webm?oid=${oid}&ot=2`;
|
|
1082
|
+
const name = escHtml(d.name || `Camera ${oid}`);
|
|
1083
|
+
const arRaw = this.camAspect[oid] || this.config.widgetLiveAspect || "";
|
|
1084
|
+
const ar = arRaw ? String(arRaw).replace("/", " / ") : "";
|
|
1085
|
+
const fix = ar ? " advimgfix" : "";
|
|
1086
|
+
const arStyle = ar ? ` style="aspect-ratio:${ar}"` : "";
|
|
1087
|
+
const inner = `<span class="advimg${fix}"${arStyle}><img src="${grab}" loading="lazy" alt=""><span class="advtag" style="top:5px;left:5px">● ${escHtml(this.wt.live)}</span><span class="advplay"></span></span><span class="advcap">${name}</span>`;
|
|
1088
|
+
const tile = `<input class="advlb" type="checkbox" id="${id}"${PAUSE_ATTR}><label class="advcell advthumb" for="${id}">${inner}</label><div class="advmodal"><label class="advbackdrop" for="${id}"></label><div class="advbox"><label class="advclose" for="${id}">✕</label><video class="advvideo" controls preload="none" playsinline src="${webm}"></video><div class="advinfo">${name} · Live</div></div></div>`;
|
|
1089
|
+
return `<style>${galleryCss(minCol, maxW)}</style><div class="advgrid">${tile}</div>`;
|
|
1090
|
+
}
|
|
1091
|
+
async updateLiveWidget(d, fid) {
|
|
1092
|
+
const wId = `${fid}.widget_live`;
|
|
1093
|
+
if (!this.ensuredFolders.has(wId)) {
|
|
1094
|
+
await this.ensurePath(wId);
|
|
1095
|
+
await this.setObjectNotExistsAsync(wId, {
|
|
1096
|
+
type: "state",
|
|
1097
|
+
common: {
|
|
1098
|
+
name: "HTML live widget",
|
|
1099
|
+
type: "string",
|
|
1100
|
+
role: "html",
|
|
1101
|
+
read: true,
|
|
1102
|
+
write: false,
|
|
1103
|
+
def: ""
|
|
1104
|
+
},
|
|
1105
|
+
native: {}
|
|
1106
|
+
});
|
|
1107
|
+
this.ensuredFolders.add(wId);
|
|
1108
|
+
}
|
|
1109
|
+
const sig = `${d.name}|${this.camAspect[d.oid] || ""}`;
|
|
1110
|
+
if (this.widgetSig[wId] !== sig) {
|
|
1111
|
+
await this.setStateAsync(wId, { val: this.buildSingleCamLiveHtml(d), ack: true });
|
|
1112
|
+
this.widgetSig[wId] = sig;
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1032
1115
|
// ---- event data points ----
|
|
1033
1116
|
async writeEventDps(d, fid, events) {
|
|
1034
|
-
var _a, _b, _c, _d;
|
|
1117
|
+
var _a, _b, _c, _d, _e;
|
|
1035
1118
|
const oid = d.oid;
|
|
1036
1119
|
await this.ensureFolder(`${fid}.events`, "Events", "channel");
|
|
1037
1120
|
await this.ensureFolder(`${fid}.events.last`, "Last event", "channel");
|
|
@@ -1064,43 +1147,24 @@ class AgentDvr extends utils.Adapter {
|
|
|
1064
1147
|
}
|
|
1065
1148
|
await this.setStateAsync(jsonId, {
|
|
1066
1149
|
val: JSON.stringify(
|
|
1067
|
-
events.slice(0, Math.max(1, this.config.
|
|
1150
|
+
events.slice(0, Math.max(1, (_b = this.config.dashMaxRec) != null ? _b : 200)).map((ev) => {
|
|
1068
1151
|
const p = this.fmtEvent(ev, oid);
|
|
1069
1152
|
return {
|
|
1153
|
+
fn: p.fn,
|
|
1070
1154
|
date: p.date,
|
|
1071
1155
|
time: p.time,
|
|
1072
1156
|
dur: p.dur,
|
|
1073
1157
|
size: p.sizeMB,
|
|
1074
1158
|
tag: p.tag,
|
|
1075
1159
|
thumb: p.thumb,
|
|
1076
|
-
video: p.video
|
|
1160
|
+
video: p.video,
|
|
1161
|
+
ts: p.ts
|
|
1077
1162
|
};
|
|
1078
1163
|
})
|
|
1079
1164
|
),
|
|
1080
1165
|
ack: true
|
|
1081
1166
|
});
|
|
1082
1167
|
await this.ensureFlag(`${fid}.events.new`, "New event");
|
|
1083
|
-
if (this.config.enablePush) {
|
|
1084
|
-
const pid = `${fid}.events.pushTrigger`;
|
|
1085
|
-
if (!this.ensuredFolders.has(pid)) {
|
|
1086
|
-
await this.ensurePath(pid);
|
|
1087
|
-
await this.setObjectNotExistsAsync(pid, {
|
|
1088
|
-
type: "state",
|
|
1089
|
-
common: {
|
|
1090
|
-
name: "Push trigger (AgentDVR action)",
|
|
1091
|
-
type: "string",
|
|
1092
|
-
role: "text",
|
|
1093
|
-
read: true,
|
|
1094
|
-
write: true,
|
|
1095
|
-
def: ""
|
|
1096
|
-
},
|
|
1097
|
-
native: {}
|
|
1098
|
-
});
|
|
1099
|
-
await this.setStateAsync(pid, { val: "", ack: true });
|
|
1100
|
-
this.ensuredFolders.add(pid);
|
|
1101
|
-
}
|
|
1102
|
-
this.registry.set(pid, { kind: "push", oid, fid });
|
|
1103
|
-
}
|
|
1104
1168
|
const ignore = (this.config.eventTagsIgnore || "detected").split(",").map((s) => s.trim().toLowerCase()).filter(Boolean);
|
|
1105
1169
|
const tokensOf = (s) => s.toLowerCase().split(/[,\s]+/).filter(Boolean);
|
|
1106
1170
|
for (const kw of (this.config.eventTags || "").split(",").map((s) => s.trim()).filter(Boolean)) {
|
|
@@ -1109,7 +1173,7 @@ class AgentDvr extends utils.Adapter {
|
|
|
1109
1173
|
if (this.config.eventTagsDynamic) {
|
|
1110
1174
|
const seen = /* @__PURE__ */ new Set();
|
|
1111
1175
|
for (const ev of events) {
|
|
1112
|
-
tokensOf((
|
|
1176
|
+
tokensOf((_c = ev.tg) != null ? _c : "").forEach((t) => seen.add(t));
|
|
1113
1177
|
}
|
|
1114
1178
|
for (const t of seen) {
|
|
1115
1179
|
if (ignore.includes(t)) {
|
|
@@ -1125,13 +1189,13 @@ class AgentDvr extends utils.Adapter {
|
|
|
1125
1189
|
const i = events.findIndex((e) => e.fn === prev);
|
|
1126
1190
|
newCount = i === -1 ? events.length : i;
|
|
1127
1191
|
}
|
|
1128
|
-
this.lastEventFn[oid] = (
|
|
1192
|
+
this.lastEventFn[oid] = (_d = events[0].fn) != null ? _d : "";
|
|
1129
1193
|
}
|
|
1130
1194
|
if (newCount > 0) {
|
|
1131
1195
|
await this.pulse(`${fid}.events.new`);
|
|
1132
1196
|
const tags = /* @__PURE__ */ new Set();
|
|
1133
1197
|
for (let i = 0; i < newCount && i < events.length; i++) {
|
|
1134
|
-
tokensOf((
|
|
1198
|
+
tokensOf((_e = events[i].tg) != null ? _e : "").forEach((t) => tags.add(t));
|
|
1135
1199
|
}
|
|
1136
1200
|
for (const t of tags) {
|
|
1137
1201
|
if (ignore.includes(t)) {
|
|
@@ -1168,13 +1232,13 @@ class AgentDvr extends utils.Adapter {
|
|
|
1168
1232
|
await this.writeEventDps(d, fid, events);
|
|
1169
1233
|
}
|
|
1170
1234
|
if (this.config.enableWidget) {
|
|
1171
|
-
const wId = `${fid}.
|
|
1235
|
+
const wId = `${fid}.widget_recordings`;
|
|
1172
1236
|
if (!this.ensuredFolders.has(wId)) {
|
|
1173
1237
|
await this.ensurePath(wId);
|
|
1174
1238
|
await this.setObjectNotExistsAsync(wId, {
|
|
1175
1239
|
type: "state",
|
|
1176
1240
|
common: {
|
|
1177
|
-
name: "HTML
|
|
1241
|
+
name: "HTML recordings widget",
|
|
1178
1242
|
type: "string",
|
|
1179
1243
|
role: "html",
|
|
1180
1244
|
read: true,
|
|
@@ -1198,22 +1262,6 @@ class AgentDvr extends utils.Adapter {
|
|
|
1198
1262
|
this.eventBusy[d.oid] = false;
|
|
1199
1263
|
}
|
|
1200
1264
|
}
|
|
1201
|
-
pushRefresh(oid) {
|
|
1202
|
-
const d = this.devById.get(oid);
|
|
1203
|
-
if (!d) {
|
|
1204
|
-
this.log.warn(`Push: camera ${oid} unknown (available after first poll)`);
|
|
1205
|
-
return;
|
|
1206
|
-
}
|
|
1207
|
-
const fid = this.deviceFolder(d);
|
|
1208
|
-
for (const ms of [0, 1500, 3500, 6e3]) {
|
|
1209
|
-
this.setTimeout(
|
|
1210
|
-
() => this.updateCameraEvents(d, fid).catch(
|
|
1211
|
-
(e) => this.log.warn(`Push refresh error: ${e.message}`)
|
|
1212
|
-
),
|
|
1213
|
-
ms
|
|
1214
|
-
);
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
1265
|
// ---- main poll ----
|
|
1218
1266
|
async poll() {
|
|
1219
1267
|
var _a, _b;
|
|
@@ -1251,10 +1299,94 @@ class AgentDvr extends utils.Adapter {
|
|
|
1251
1299
|
await this.pruneStaleDevices(activeFolders);
|
|
1252
1300
|
const stats = asJson((await this.apiGet("/command/getSystemStats")).data);
|
|
1253
1301
|
if (stats) {
|
|
1254
|
-
|
|
1302
|
+
const {
|
|
1303
|
+
disks: _disks,
|
|
1304
|
+
cpup,
|
|
1305
|
+
ramp,
|
|
1306
|
+
ramu,
|
|
1307
|
+
cpu_used,
|
|
1308
|
+
ram_free,
|
|
1309
|
+
disk_free: _disk_free,
|
|
1310
|
+
diskp,
|
|
1311
|
+
...statsRest
|
|
1312
|
+
} = stats;
|
|
1313
|
+
if (cpup !== void 0) {
|
|
1314
|
+
await this.writeLeaf("system.hardware.cpu.percent", cpup, "%");
|
|
1315
|
+
}
|
|
1316
|
+
await this.delObjectAsync("system.hardware.cpu.used").catch(() => {
|
|
1317
|
+
});
|
|
1318
|
+
if (ramp !== void 0) {
|
|
1319
|
+
await this.writeLeaf("system.hardware.ram.percent", ramp, "%");
|
|
1320
|
+
}
|
|
1321
|
+
if (ramu !== void 0) {
|
|
1322
|
+
await this.writeLeaf("system.hardware.ram.used", toStr(ramu));
|
|
1323
|
+
}
|
|
1324
|
+
if (ram_free !== void 0) {
|
|
1325
|
+
await this.writeLeaf("system.hardware.ram.free", toStr(ram_free));
|
|
1326
|
+
}
|
|
1327
|
+
if (Object.keys(statsRest).length) {
|
|
1328
|
+
await this.flattenWrite(
|
|
1329
|
+
{ ...statsRest, ...diskp !== void 0 && { disk_percent: diskp } },
|
|
1330
|
+
"system.stats",
|
|
1331
|
+
0
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
for (const old of [
|
|
1335
|
+
"cpup",
|
|
1336
|
+
"ramp",
|
|
1337
|
+
"ramu",
|
|
1338
|
+
"diskp",
|
|
1339
|
+
"cpu_used",
|
|
1340
|
+
"ram_free",
|
|
1341
|
+
"disk_free",
|
|
1342
|
+
"cpu_percent",
|
|
1343
|
+
"ram_percent",
|
|
1344
|
+
"ram_used",
|
|
1345
|
+
"disk_percent"
|
|
1346
|
+
]) {
|
|
1347
|
+
await this.delObjectAsync(`system.stats.${old}`).catch(() => {
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
for (const old of ["system.cpu", "system.ram", "system.drives", "system.disk_free_gb"]) {
|
|
1351
|
+
await this.delObjectAsync(old, { recursive: true }).catch(() => {
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1255
1354
|
const gb = parseSizeGb(stats.disk_free);
|
|
1256
1355
|
if (gb !== null) {
|
|
1257
|
-
await this.writeLeaf("system.disk_free_gb", gb);
|
|
1356
|
+
await this.writeLeaf("system.hardware.disk_free_gb", gb);
|
|
1357
|
+
}
|
|
1358
|
+
if (Array.isArray(stats.disks)) {
|
|
1359
|
+
const activeKeys = /* @__PURE__ */ new Set();
|
|
1360
|
+
for (const drv of stats.disks) {
|
|
1361
|
+
if (!drv || typeof drv !== "object") {
|
|
1362
|
+
continue;
|
|
1363
|
+
}
|
|
1364
|
+
const key = sanitize(toStr(drv.n).replace(/^\//, "") || "root") || "root";
|
|
1365
|
+
activeKeys.add(key);
|
|
1366
|
+
await this.writeLeaf(
|
|
1367
|
+
`system.hardware.drives.${key}.name`,
|
|
1368
|
+
toStr(drv.n) === "/" ? "/ Root" : toStr(drv.n)
|
|
1369
|
+
);
|
|
1370
|
+
await this.writeLeaf(`system.hardware.drives.${key}.free`, toStr(drv.d));
|
|
1371
|
+
await this.writeLeaf(`system.hardware.drives.${key}.used`, toStr(drv.u));
|
|
1372
|
+
await this.writeLeaf(
|
|
1373
|
+
`system.hardware.drives.${key}.percent`,
|
|
1374
|
+
typeof drv.p === "number" ? drv.p : 0,
|
|
1375
|
+
"%"
|
|
1376
|
+
);
|
|
1377
|
+
const fgb = parseSizeGb(drv.d);
|
|
1378
|
+
if (fgb !== null) {
|
|
1379
|
+
await this.writeLeaf(`system.hardware.drives.${key}.free_gb`, fgb);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
const allObjs = await this.getAdapterObjectsAsync();
|
|
1383
|
+
for (const fullId of Object.keys(allObjs)) {
|
|
1384
|
+
const rel = fullId.slice(this.namespace.length + 1);
|
|
1385
|
+
const m = rel.match(/^system\.hardware\.drives\.([^.]+)$/);
|
|
1386
|
+
if (m && !activeKeys.has(m[1])) {
|
|
1387
|
+
await this.delObjectAsync(rel, { recursive: true });
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1258
1390
|
}
|
|
1259
1391
|
}
|
|
1260
1392
|
const status = asJson((await this.apiGet("/command/getStatus")).data);
|
|
@@ -1369,6 +1501,7 @@ class AgentDvr extends utils.Adapter {
|
|
|
1369
1501
|
}
|
|
1370
1502
|
}
|
|
1371
1503
|
async runCommand(relId, entry, val) {
|
|
1504
|
+
var _a, _b;
|
|
1372
1505
|
if (entry.kind === "setProfile") {
|
|
1373
1506
|
const ind = typeof val === "number" ? val : parseInt(String(val != null ? val : ""), 10);
|
|
1374
1507
|
if (!isNaN(ind)) {
|
|
@@ -1405,10 +1538,20 @@ class AgentDvr extends utils.Adapter {
|
|
|
1405
1538
|
await this.setStateAsync(relId, { val: false, ack: true });
|
|
1406
1539
|
return;
|
|
1407
1540
|
}
|
|
1408
|
-
if (entry.kind === "
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1541
|
+
if (entry.kind === "ptzPreset") {
|
|
1542
|
+
const idx = typeof val === "number" ? val : parseInt(String(val != null ? val : ""), 10);
|
|
1543
|
+
const name = isNaN(idx) ? "" : (_b = ((_a = entry.presetNames) != null ? _a : [])[idx]) != null ? _b : "";
|
|
1544
|
+
if (!name) {
|
|
1545
|
+
return;
|
|
1546
|
+
}
|
|
1547
|
+
const url2 = `/command/ptzpreset?oid=${encodeURIComponent(String(entry.oid))}&ot=2&preset=${encodeURIComponent(name)}`;
|
|
1548
|
+
const cmdRes2 = await this.apiGet(url2);
|
|
1549
|
+
if (cmdRes2.ok) {
|
|
1550
|
+
this.log.debug(`PTZ preset \u2192 ${name}`);
|
|
1551
|
+
await this.setStateAsync(relId, { val: idx, ack: true });
|
|
1552
|
+
} else {
|
|
1553
|
+
this.log.warn(`PTZ preset failed (${url2}): ${cmdRes2.error}`);
|
|
1554
|
+
}
|
|
1412
1555
|
return;
|
|
1413
1556
|
}
|
|
1414
1557
|
if (entry.kind === "ptzHold") {
|