• Categories
    • Recent
    • Tags
    • Popular
    • Register
    • Login

    How to open a webpage / place a http request?

    Scheduled Pinned Locked Moved Scripts
    4 Posts 2 Posters 18.6k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      Joost
      last edited by

      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

      1 Reply Last reply Reply Quote 1
      • J Offline
        Joost
        last edited by jkandasa

        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

        jkandasaJ 1 Reply Last reply Reply Quote 1
        • jkandasaJ Offline
          jkandasa @Joost
          last edited by

          @Joost Other way

          mcApi.http().get("http://deepblack:9000/status.html?p0=pause")
          
          1 Reply Last reply Reply Quote 0
          • J Offline
            Joost
            last edited by

            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

            1 Reply Last reply Reply Quote 1
            • First post
              Last post

            0

            Online

            587

            Users

            529

            Topics

            3.4k

            Posts
            Copyright © 2015-2025 MyController.org | Contributors | Localization