Websockets

Einklappen
X
 
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge
  • K.Clemens
    Smart Home'r
    • 28.08.2015
    • 92

    #1

    Websockets

    Hi,

    Anybody an idea how to setup a websocket connection?

    Following code does not work.. Been working on it already for 2 evenings:
    $.get("http://ipminiserverort/jdev/sys/getkey?" + Math.random()).success(function (a) {
    var salt = a.LL.value;
    function toHex(str) {
    var hex = '';
    for(var i=0;i<str.length;i++) {
    hex += ''+str.charCodeAt(i).toString(16);
    }
    return hex;
    }
    var hex = toHex (a.LL.value);


    var credentials = "admin:admin";
    var shaObj = new jsSHA(credentials, "ASCII");
    var hash = shaObj.getHMAC(hex, "HEX", "HEX");

    var host = "ws://ipminiserverort/ws/";
    var socket = new WebSocket(host, hash);

    socket.onopen = function(evt) { onOpen(evt) };
    socket.onclose = function(evt) { onClose(evt) };
    socket.onmessage = function(evt) { onMessage(evt) };
    socket.onerror = function(evt) { onError(evt) };
    });
    Zuletzt geändert von K.Clemens; 09.09.2015, 21:22.
  • K.Clemens
    Smart Home'r
    • 28.08.2015
    • 92

    #2
    nobody with any experience?

    Kommentar

    • Gast

      #3
      nope sorry, did you check the documentation at loxone? i see you've changed the password in your post, good, i wanted to tell you but then forgot about it

      Kommentar

      • K.Clemens
        Smart Home'r
        • 28.08.2015
        • 92

        #4
        I've read the documentation so many times I know it by hart . Have to say that I'm really getting frustrated about the fact loxone's support is below all levels about this...

        Kommentar

        • beeper
          Smart Home'r
          • 31.08.2015
          • 47

          #5
          Hi,
          at http://forum.loxone.com/enen/softwar...-easy-way.html you can find an php script to start a websocket connection. I have not tested the script but maybe it helps.
          At http://forum.loxone.com/enen/softwar...ple-print.html you can find a c# example.

          Kommentar

          • K.Clemens
            Smart Home'r
            • 28.08.2015
            • 92

            #6
            Beeper, I've read the posts on the old loxone forum multiple times. At this point I'm just stuck. Have requested for help several times already at Loxone. Can't do anything else than wait for the documentation of the new api.

            Kommentar

            • beeper
              Smart Home'r
              • 31.08.2015
              • 47

              #7
              The German Loxone Webpage has also this http://www.loxone.com/dede/service/d...ionslogik.html page. You can find a short Javascript to connect to the websocket port. The Script uses the last cookie instead of the base64 encoded username. Maybe it could help.
              But i have a similar problem connecting to the websocket port from my Windows Phone (C#) too. My problem is that the WebSocket Object in C# is working but the Phone Framework uses a different one and this don't work in the same way. I think Loxone must update there documentation to help us.
              In honest opinion a different approach without websocket would also be nice. I mean using a url without websocket should give us the status of all object.

              If i find some additional infos i will give you an update.
              Volker

              Kommentar

              • beeper
                Smart Home'r
                • 31.08.2015
                • 47

                #8
                Found an additional link. I am not sure if it helps. https://groups.google.com/forum/#!to...on/4xbO-Z3hf3o

                Kommentar

                • K.Clemens
                  Smart Home'r
                  • 28.08.2015
                  • 92

                  #9
                  Thanks for the info. Furthermore, any idea how to send json data via javascript? What I would like to do the most is get the responses of the miniserver via javascript and get that result in a php variable for processing. Indeed, loxone has to update there info.

                  Kommentar

                  • Gast

                    #10
                    Hi,

                    a while ago i communicated with somebody at loxone to help me setup the connection. That works great, but i don't know the structure of the messages to for example enable a scene on a lightning controller. Does anybody know how to do this?

                    If the connecting is still a problem i'm more than willing to share my code for that.

                    Regards,

                    Tom

                    Kommentar

                    • K.Clemens
                      Smart Home'r
                      • 28.08.2015
                      • 92

                      #11
                      Doesn't every scene gets an UUID? If so, than it would be a simple on/off command as a pushbutton, I guess.

                      edit: If possible you may always share your code for connection and status update of pushbuttons.

                      Kommentar

                      • Gast

                        #12
                        Zitat von K.Clemens
                        Doesn't every scene gets an UUID? If so, than it would be a simple on/off command as a pushbutton, I guess.

                        I've tried that but with no success. How should the command look like?

                        jdev/sps/io/<UUID>/????

                        Kommentar

                        • K.Clemens
                          Smart Home'r
                          • 28.08.2015
                          • 92

                          #13
                          • off, on, Scene name or value 0 – x (0=off, 1, 2, 3, ... = light scene)
                          • e.g.: dev/sps/io/[uuid]/[scene name or number]

                          Kommentar

                          • Gast

                            #14
                            Okay, that seems to work :-)

                            Thanks for your quick help.

                            Kommentar

                            • K.Clemens
                              Smart Home'r
                              • 28.08.2015
                              • 92

                              #15
                              No problem. Can you share your code?

                              May I ask why you are using websockets?

                              Kommentar

                              Lädt...