How to open a webpage / place a http request?
-
Hi everyone,
thanks very much for MyController, this is such a great project!! I am diving into MySensors and started with HomeAssistant, but found everything quite hidden away. Now I am seeing the light (or at least it's dawning on me ) after switching to MyController!
I have a simple/beginner question: I built a MySensors node with two buttons, which I'd like to connect to Operations in MyController. My question is this:
I plan on controlling a Logitech Squeezebox Server. This works by simply calling a (local) web URL like "http://deepblack:9000/status.html?p0=pause" or alternatively do a JSON call.
The web page does not need to be downloaded or displayed; f. ex. it works if just running "curl http://deepblack:9000/status.html?p0=pause" in a shell and discarding the answer to /dev/null.What would be a way to just call this URL? I suppose this would best be accomplished with a JavaScript operation?
Thanks very much & best regards,
Joost
-
Found a possible and working solution:
var myImports = new JavaImporter(java.lang, java.util); with(myImports) { // your command to execute var command = "wget -O/dev/null -q http://deepblack:9000/status.html?p0=pause"; // execute your command mcApi.osCommandExecuter().executeLinuxCommand(command); }
Thanks for MyController, it's really great!
Joost -
@Joost Other way
mcApi.http().get("http://deepblack:9000/status.html?p0=pause")
-
Thanks very much for your reply with the streamlined version!
To be honest, I now had to settle for calling the actions like this
var command="echo 'b8:27:eb:b7:29:4a mixer volume -2' | nc -q0 192.168.1.2 9090" mcApi.osCommandExecuter().executeLinuxCommand(command);
Meaning, the command get's "netcat'ed" to the server - is there just by chance a comparable API call as well?
Thanks again very much for your work,
Joost