diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5cd0a69 Binary files /dev/null and b/.DS_Store differ diff --git a/src/actions.js b/src/actions.js index 5d6a707..aadaf27 100644 --- a/src/actions.js +++ b/src/actions.js @@ -45,6 +45,7 @@ const focusdefinition = { var cmd = ""; var param = ""; +var fw = []; const CHOICES_IRIS = []; for (let i = 0; i < 100; ++i) { CHOICES_IRIS.push({ @@ -83,7 +84,43 @@ async function sendPTZ(self, action, direction) { //} const urllib = new HttpClient(); - console.log("debug", `Action send: ${url} `+util.inspect (self.config.authtext)); + console.log("debug", `Action send: ${url} `); + + + urllib + .request(url, self.urlliboptions + ) + .then((result) => { + // console.log("debug", `Action result: `+ util.inspect (result)); + + self.getCameraPosition(); + self.checkFeedbacks(); + + }) + .catch ((err) => { + console.log("debug", `Action failed: ${url} + ${err}`); + }) + } +} +async function sendPTZConfig(self, action, direction) { + self.log("debug", "Sending PTZConfig " + action + ":" + direction); + if (action) { + const url = + + self.config.host + + ":" + + self.config.httpPort + + "/axis-cgi/com/ptzconfig.cgi?" + + action + + "=" + + direction + + "&camera=1"; + //if (self.config.debug) { + // self.log("debug", `Sending PTZ : ${url}`); + //} + const urllib = new HttpClient(); + + console.log("debug", `Action send: ${url} `); urllib @@ -597,11 +634,18 @@ seriesActions.ptSpeed = true; cmd = "setserverpresetno"; param = action.options.val; //self.ptzMove(param, cmd, opt.speed) - - await sendPTZ(self, cmd, param); + fw = self.FirmwareVersion.split(".") + self.log("debug", "fw: " + fw + " > 10: "+ (parseInt(fw[0]) > 10)); + if (parseInt(fw[0]) > 10){ + self.log("debug", "firmware > 10"); + await sendPTZConfig(self, cmd, param); + } else { + self.log("debug", "firmware <= 10"); + await sendPTZ(self, cmd, param); + } self.getCameraPosition(); self.checkFeedbacks(); - await sendPTZ(self, "M" + action.options.val); + }, }; } diff --git a/src/index.js b/src/index.js index e04425b..a87ca77 100644 --- a/src/index.js +++ b/src/index.js @@ -62,6 +62,11 @@ class axisPTZInstance extends InstanceBase { switch (String(chunks[i].split("=")[0])) { case "root.Brand.ProdShortName": attarr["CameraType"] = val; + this.CameraType = val; + break; + case "root.Properties.Firmware.Version": + attarr["FirmwareVersion"] = val; + this.FirmwareVersion = val; break; case "root.PTZ.Limit.L1.MaxFocus": attarr["MaxFocus"] = Number(val); @@ -161,6 +166,8 @@ class axisPTZInstance extends InstanceBase { async init(config) { this.config = config; this.urlliboptions = {} + this.CameraType = "Axis" + this.FirmwareVersion = "" if (Number(this.config.authmethod) == 1) { this.urlliboptions = { diff --git a/src/presets.js b/src/presets.js index 670404c..602c50a 100644 --- a/src/presets.js +++ b/src/presets.js @@ -757,7 +757,7 @@ export function getPresetDefinitions(self) { // ########################### seriesActions.preset = true; if (seriesActions.preset) { - for (let save = 0; save < 100; save++) { + for (let save = 1; save < 100; save++) { presets[`save-preset-${save}`] = { type: "button", category: "Save Preset", @@ -840,7 +840,7 @@ export function getPresetDefinitions(self) { }; } - for (let recall = 0; recall < 100; recall++) { + for (let recall = 1; recall < 100; recall++) { presets[`recall-preset-${recall}`] = { type: "button", category: "Recall Preset", diff --git a/src/variables.js b/src/variables.js index 931c355..1b1e44a 100644 --- a/src/variables.js +++ b/src/variables.js @@ -13,6 +13,7 @@ export function setVariables() { // console.log(self.data.modelTCP); // console.log(self.data.series); variables.push({ variableId: "CameraType", name: "Camera Type" }); + variables.push({ variableId: "FirmwareVersion", name: "Firmware Version" }); variables.push({ variableId: "autofocus", name: "AutoFocus" }); variables.push({ variableId: "MaxPan", name: "MaxPan" }); variables.push({ variableId: "MinPan", name: "MinPan" }); @@ -42,6 +43,7 @@ export function checkVariables(self) { self.setVariableValues({ series: self.data.series, model: self.data.model, + FirmwareVersion: self.data.FirmwareVersion, name: self.data.name, version: self.data.version, error: self.data.error,