• header.categories
    • header.recent
    • header.tags
    • header.popular
    • register
    • login

    How to open a webpage / place a http request?

    scheduled pinned locked moved Scripts
    4 posts 2 posters 18.9k views 1 watching
    loading-more-posts
    • oldest-to-newest
    • newest-to-oldest
    • most-votes
    reply
    • reply-as-topic
    guest-login-reply
    deleted-message
    • J offline
      Joost
      global: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

      one-reply-to-this-post last-reply-time reply quote 1
      • J offline
        Joost
        global: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 one-reply-to-this-post last-reply-time reply quote 1
        • jkandasaJ offline
          jkandasa @Joost
          global:last-edited-by,

          @Joost Other way

          mcApi.http().get("http://deepblack:9000/status.html?p0=pause")
          
          one-reply-to-this-post last-reply-time reply quote 0
          • J offline
            Joost
            global: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

            one-reply-to-this-post last-reply-time reply quote 1
            • first-post
              last-post

            0

            online

            644

            users

            532

            topics

            3.4k

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