Skip to content

Commit

Permalink
Merge pull request #24 from fbosman/main
Browse files Browse the repository at this point in the history
Axis release new Vapix with breaking changes
  • Loading branch information
fbosman authored Nov 14, 2024
2 parents 8abd227 + 4742615 commit 202c8ca
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 6 deletions.
Binary file added .DS_Store
Binary file not shown.
52 changes: 48 additions & 4 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);

},
};
}
Expand Down
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions src/presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 202c8ca

Please sign in to comment.