I have my projector (Epson 3020) up-and-running with the Runco plugin. However, I also want to be able to poll the status of the projector. With the Runco, the command “op status ?” is sent to receive the current projector status. With the Epson the command is “pwr?” to do the same thing. I have used iTest from Global Cache to verify the response I get to “pwr?”, and it works fine. However, the response is formatted a bit differently that the Runco’s. The author of the plugin used the trim and split functions to pull out the code, and that wasn’t working. Instead, I decided to use the “includes” parameter to simply check for the value to see if the projector was on (01 in my case). I tested the code in a javascript editor and it worked as expected. However, when I incorporate it into the plugin and tie the value to a label the label displays “Unknown”. The code should constrain the values to simply “On” or “Off”, so I’m a bit confused. Here’s my code:
flushReceiveBuffer();
socket.send("pwr?\r");
sleep(250); // sleep briefly just to make sure we get the whole response
response = socket.receive({ timeout: 500 });
responseVal=response.includes('01');
switch(responseVal) {
case false: // cooling down, off
powerStatus = "Off";
break;
case true: // displaying
powerStatus = "On";
break;
default:
// unknown/unhandled status (or an error), default to off
powerStatus = "Off";
break;
}
Seems like any error or unhandled status should set the value of powerStatus to “Off”, but it is showing “Unknown” instead. Any help would be appreciated!