Skip to content

Commit

Permalink
feat(main) add beamer pjlink info on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
smarthomeagentur committed Oct 17, 2024
1 parent c41b711 commit 2b7812c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 9 deletions.
1 change: 1 addition & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
jq \
htop \
nmap \
netcat \
snmp snmpd \
dbus && \
apt-get clean && rm -rf /var/lib/apt/lists/*
Expand Down
59 changes: 50 additions & 9 deletions app/hwcontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,67 @@ function pjlinkSet(ip, command) {
return;
}
console.log("[PJLINK] turned off: " + ip);
clearTimeout(timeout);
resolve(true);
return;
});
}
if (command == "status") {
projector.getPowerState(function (state) {
console.log("[PJLINK] return power state(" + ip + "): " + state);
clearTimeout(timeout);
resolve(state);
return;
const powerstate = await new Promise((resolve, reject) => {
projector.getPowerState(function (state) {
resolve(state);
});
});
const input = await new Promise((resolve, reject) => {
projector.getInput(function (state) {
resolve(state);
});
});
const name = await new Promise((resolve, reject) => {
projector.getName(function (state) {
resolve(state);
});
});
const manufacturer = await new Promise((resolve, reject) => {
projector.getName(function (state) {
resolve(state);
});
});
const model = await new Promise((resolve, reject) => {
projector.getName(function (state) {
resolve(state);
});
});
const info = await new Promise((resolve, reject) => {
projector.getInfo(function (state) {
resolve(state);
});
});

var stateArray = { powerstate, input, name, manufacturer, model, info };

console.log("[PJLINK] return state: " + stateArray);
clearTimeout(timeout);
resolve(stateArray);
return;
}
});
}

module.exports = {
init: function () {
beamerArray = BEAMER_IP.split(",");
console.log("[INIT] Beamer defined: " + beamerArray);
init: async function () {
if (beamerArray.length >= 1) {
beamerArray = BEAMER_IP.split(",");
console.log("[INIT] projector defined: " + beamerArray);
console.log("[INIT] PJLINK data:");
for (let index = 0; index < beamerArray.length; index++) {
const element = beamerArray[index];
//await sendSerialProjector("7E3030303020310D", element); //power on optoma
var status = await pjlinkSet(element, "status");
console.log(status);
}
} else {
console.log("[INIT] NO projector defined");
}
},

setScreenPower: async function (powerState, screenNumber = 0, ddc = false) {
Expand Down

0 comments on commit 2b7812c

Please sign in to comment.