Difficulties sending http string to IP Switch in startup script
I have been trying to get my IP Switch to except commands from the startup script. So far I have been unsuccessful. If it if I drop the following into a browser I can successfully control this device. As an example, if I want to turn on relay 10 and 11 and turn relay 2 off I would send the following command:
http://192.168.10.95/current_state.x...11=1&Output2=0
To turn on relay switch 1:
http://192.168.10.95/current_state.x...dmin&Output1=1
I tried to alter the NBPowerOn function in the startup script (original function below). It looked like a great place to start, but my efforts failed. I get no syntax errors with my mofication, but nothing happens.
function NBPowerOn(switchNumber, switchName)
{
// --- user config ---
var IP = "192.168.1.100";
var USER = "admin";
var PASS = "admin";
// -------------------
var cmdline = "$A3 " + switchNumber + " 1";
var http = new ActiveXObject("MSXML2.XMLHTTP");
http.open("GET", "http://" + IP + "/cmd.cgi?" + encodeURI(cmdline), false, USER, PASS);
http.send();
if(http.status == 200) {
Console.PrintLine("...powered on " + switchName);
Console.PrintLine(" " + http.responseText);
} else {
throw "** Power on failed for " + switchName + " " + http.status + " " + http.statusText;
}
}
The hardware is an ethernet relay board, and seems to be fairly feature rich. It's been running continually for the last three months in my dome. I hope to leverage the ability of this device to measure humidity and temperature and have it shut everything off during those days of high fire danger or high heat. I really do not wish to have stuff running at +40C.
http://denkovi.com/internet-ethernet...p4-io-snmp-web
Terry