diff --git a/index.js b/index.js index af9ab40..6c1e710 100755 --- a/index.js +++ b/index.js @@ -159,11 +159,26 @@ app.post("/stopprojector", (req, res) => { res.json({ status: 'ok' }); }); +function projectorNumberToText(number) { + switch (status1) { + case '01': + return 'On'; + case '02': + return 'Starting/Stopping'; + case '03': + return 'Starting/Stopping'; + case '04': + return 'Off'; + default: + return 'Unknown'; + } +} + app.get("/projectorstatus", async (req, res) => { const res1 = await fetch('http://192.168.1.93/api/v01/control/escvp21?cmd=PWR?'); - const status1 = await res1.text(); + const status1 = projectorNumberToText(await res1.text()); const res2 = await fetch('http://192.168.1.67/api/v01/control/escvp21?cmd=PWR?'); - const status2 = await res2.text(); + const status2 = projectorNumberToText(await res2.text()); res.json({ status1, status2 }); }); diff --git a/public/index.html b/public/index.html index 259e1e4..3aa865e 100755 --- a/public/index.html +++ b/public/index.html @@ -29,48 +29,66 @@ +