Web Interface To X10 Commander

Forum to discuss X10 Commander iPhone/iPod/iPad/Android client for X10 Devices

Re: Web Interface To X10 Commander

Postby harry_s24 » Wed Feb 22, 2012 8:04 pm

Melloware, thanks for the prompt response and the tip. While I did not need to use the actual text, just the knowledge that a response does come back from the server helped me put code in there and achieve what I wanted to. For the benefit of anyone else who wants to do the same, only the portion of changed code is below:
[Edited to add some additional robustness with timeout function]

Code: Select all
     try {
            // Send HTTP GET without opening a window. - Changed from HEAD to GET in order to get the return value from server.
            var request = new XMLHttpRequest();
            request.open("GET", url, true, serverID, serverPassword);

            function ResendToBackupIfPossible() {
                request.abort();    // Clear the peding request to the dead PC.
               // resend to 8087 only if 8086 failed. If 8087 failed, we dont have any more places to send and so wont.
                if (url.indexOf("8086") > -1) {
                    // Check if its the 1st PC port and if so, replace it with the 2nd PC port
                    url = url.replace("8086", "8087");
            //        alert ("Resending to new URL: " + url);
                    // recurse back to resend. The check for 8086 ensures multiple recursions dont occur.
                     ajaxMethod(url);
                }
            }

            // Set the timeout to 5 seconds - based this on actual web experience. Change as needed
            var xmlHttpTimeout=setTimeout(ResendToBackupIfPossible,5000);

            request.onreadystatechange = function () {
                if (request.readyState==4) {
                    if (request.status==200) {
                         clearTimeout(xmlHttpTimeout);
                        //all is good; noting more to do.
                        return;
                    } else {
                        // check and resend if possible to backup PC
                        ResendToBackupIfPossible();
                    }
                }
            }
            request.send(null);
        }
       
harry_s24
 
Posts: 2
Joined: Tue Feb 21, 2012 7:09 pm

Re: Web Interface To X10 Commander

Postby Tom Tom » Tue Jun 05, 2012 11:34 am

Hello.

Thanks a lot for the informations above....Anyway I think too that there is too much detailed informations and the man can lost in the jungle of the details ...
I will to study now the interface designs so I will back here with my questions or answers at soon.
Tom Tom
 
Posts: 3
Joined: Mon Jun 04, 2012 4:33 pm

Re: Web Interface To X10 Commander

Postby syniast » Wed Oct 24, 2012 4:20 am

Hey harry_s24 Where does the code go in the Web X10der for this new addition? I'd love to try it.

I've got the Web X10der hosted and working great on my machine for a bit now and I gotta say it's pretty perfect. I also use active home pro, so I setup a bunch of macros in that to get the all lights on\off working only for a specific house code. I have some pretty cool mood light setups (IE watch a movie, music and so on). The commander server and software work great, and my dyndns and apache server are also really fun. My friends are always really amazed when I give them my dyndns url and they can turn lights on and off using their own phones when they come over. It's also a lot of fun to freak people out when I go to the store if they aren't the ones whom already know I've got the hookup.

I recently made the switch and became an android guy after getting an IPad, figured I didn't need both that and the IPhone and i've experimented with nfc stickers which are also super cool in conjunction with x10.

I do have one issue, but not really so much of a problem more of an annoyance. When I send a command using the X10 Web X10der I get the following error.
[Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "http://192.168.1.101/ Line: 114"]
the command still gets sent and goes through, the light\lights go on and off fine. It's just kinda annoying and looks ugly. This seems to happen on PC in ie, firefox and not in chrome. I'm not so great with code, so if anyone has any thoughts let me know. Seems line 114 is
request.send(null);
and I am not sure what the problem is.

The possibilities with X10 seem so endless, I've thought about the voice automation stuff for a bit now, and I also think I might want to tackle automating my blinds into the x10. Does anyone know how it works as far as a media center companion? I see options for it in the active home pro software, but I can't imagine it being that good as the AHP is such a clunky and ugly tool. Right now I have a computer connected to hdmi in my living room, it would be cool if I could send a mood command that dimmed the lights whatever % and also turned on music in one go.
Thanks!

EDIT:
Fixed my issue, I just needed to add my dyndns url into the trusted sites in IE on whichever machine I am using to control the lights. I had the IP of my x10 server already in trusted sites, but I had forgotten to switch it over when I went the route of making it accessible remotely. :D
syniast
 
Posts: 1
Joined: Wed Oct 24, 2012 4:02 am

Re: Web Interface To X10 Commander

Postby Melloware » Mon Nov 26, 2012 6:24 am

I don't know if you guys have seen this post as well..

viewtopic.php?f=13&t=10027
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11037
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: New improved web interface to X10 Commander

Postby cbertuch » Sat Jan 05, 2013 6:13 pm

Melloware wrote:I really appreciate the hard work that went into this! I have made this thread a sticky thread so people can always find it.

HI LOGGING IN FOR THE FIRST TIME.
CBERTUCH
cbertuch
 
Posts: 1
Joined: Thu Jan 03, 2013 8:45 am

Re: Web Interface To X10 Commander

Postby apstrojny22 » Fri Oct 25, 2013 9:31 pm

Where do you select the port or is it expecting the X10 Commander Server to be on 6003 the default... Do you code the Password in there anywhere... Sorry for the dumb questions... Andy
apstrojny22
 
Posts: 2
Joined: Fri Oct 25, 2013 9:14 pm

Re: Web Interface To X10 Commander

Postby apstrojny22 » Fri Oct 25, 2013 11:33 pm

Quick question why is not there a line to edit the server password in as we setup in the Android app and the x10 server setup?
Andy
apstrojny22
 
Posts: 2
Joined: Fri Oct 25, 2013 9:14 pm

Re: Web Interface To X10 Commander

Postby geopara » Wed Nov 06, 2013 8:55 pm

Help!

Trying to get X10 commander to work over the web. I registered a free dns account, I got a domain name that I then added to free dns, I did port forwarding for 6003 and the IP address of the pc that software is on, then went to dyn.com and set up account there. I have no idea how to tie all this together. I have studied this link, https://www.assembla.com/wiki/show/mell ... Edge_Guide, for over an hour but I have no clue as to how everything falls into place, or what I enter into settings on my iphone. Does anyone have step by step instructions on how to get this to work?

Thanks in advance for your help1
geopara
 
Posts: 3
Joined: Wed Nov 06, 2013 8:27 pm

Re: Web Interface To X10 Commander

Postby Melloware » Thu Nov 07, 2013 7:17 am

These are the step by step instructions if you blow up the picture...

https://www.assembla.com/wiki/show/mell ... Edge_Guide

after you get your DynDNS address just enter in the iPhone app...

Image

If it still doesn't work then something is not set up properly.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11037
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Web Interface To X10 Commander

Postby geopara » Thu Nov 07, 2013 8:38 am

Isnt the Dyndns the last step in order to create an alias? According to that chart the phone has connected to 3G prior to even doing that step. I havent gotten to that point. I am not sure where the domain I created earlier in the process comes into play. xxxxx.net has been created and added to freedns. I also added xxxxx.net to Dyndns as a zone, is that correct?
geopara
 
Posts: 3
Joined: Wed Nov 06, 2013 8:27 pm

Re: Web Interface To X10 Commander

Postby Melloware » Thu Nov 07, 2013 12:38 pm

I would say if you aren't familiar with networking concepts this might be a little tough for you and impossible for me to explain over the instructions provided.

Do you have any tech savvy friend's who could help you?
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11037
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Web Interface To X10 Commander

Postby geopara » Thu Nov 07, 2013 7:30 pm

Ok I did some tweaking and got my iphone to work with 3G using the IP address on my router. I created an account on dyndns, what services do I want? I dont care if I have to pay for something, I just dont want to buy stuff that wont work. I have Verizon Fios router and in the settings it has dynamic dns, where you choose dyndns as the provider and put in your log in info. What do I put as host name? Is that something I pay for on Dyndns?
geopara
 
Posts: 3
Joined: Wed Nov 06, 2013 8:27 pm

Re: Web Interface To X10 Commander

Postby Melloware » Fri Nov 08, 2013 6:29 am

geopara wrote:Ok I did some tweaking and got my iphone to work with 3G using the IP address on my router. I created an account on dyndns, what services do I want? I dont care if I have to pay for something, I just dont want to buy stuff that wont work. I have Verizon Fios router and in the settings it has dynamic dns, where you choose dyndns as the provider and put in your log in info. What do I put as host name? Is that something I pay for on Dyndns?


I don;t think so I have the free DynDNS Service and your router will just update DynDns whenever your IP Address changes.

That way "geopara.podzone.net" or whatever dyndns URL you picked will always be mapped to the IP of your Verizon Router.

So now you can use "geopara.podzone.net" in X10 Commander settings instead of typing in a hard coded IP Address that could change whenever Verizon decides to change their mind.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11037
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Web Interface To X10 Commander

Postby edgararroyo » Thu May 22, 2014 8:15 pm

Here is my modified X10der.

1. It uses bootstrap to make it responsive desigin (looks good on all devices and it adds a line separator to avoid pressing wrong module function)
2. Added spacer which has "  " so you can set it to blank to make button smaller for mobile device.
3. Added MACRO (with just "RUN" button)
4. In addition to "status" I added an alert when a command has run
5. Added "prompt" before running command (OK & CANCEL)

Code: Select all
    <html>
    <head>
    <title>Web X10der</title>

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">

    <!-- Latest compiled and minified JavaScript -->
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

    <!-- version 2.0a  9/6/2010 -->
    <script type="text/JavaScript" language="JavaScript">
    <!--
    // XXX: This script is known not to work with the Opera Mini mobile browser.
    var version = "2.0";
    // Some constants to make the code a little more readable.
    var NODIM = 0, DIM = 1, MACRO = 2, PLC = 0, RF = 1;

    // ********************** START EDITING HERE ***************************

    // Host name or IP address of the machine running the X10 Commander server
    // You MUST edit this.
    var server = "192.168.25.3";

    // You MUST edit the devices array to match your setup.
    //
    // Devices array contains 4 entries per device.
    // 1. Device address (house code & unit number)
    // 2. Device name to display
    // 3. Device dimability - NODIM or DIM
    // 4. X10 transmission method - PLC (power line) or RF (radio frequency)
    var devices = new Array(
        "A1",   "Master Bedroom - Light",      DIM,   PLC,
        "A2",   "Master Bedroom - Fan",         DIM,   PLC,
        "A3",   "Master Bedroom - Receiver",   NODIM,   PLC,
        "A4",   "Master Bedroom - TV",         NODIM,   PLC,
        "A5",   "Xaviers Room - Light",         DIM,   PLC,
        "A6",   "Xaviers Room - TV",         NODIM,   PLC,
        "A7",   "Living Room - Light",         DIM,   PLC,
        "A8",   "Living Room - Fan",         DIM,   PLC,
        "A9",   "Living Room - Receiver",      NODIM,   PLC,
        "A10",   "Living Room - TV",            NODIM,   PLC,
        "A11",   "Dinning Room - Light",         DIM,   PLC,
        "A12",   "Dinning Room - Fan",         DIM,   PLC,
        "A13",   "Bathroom - Light",            DIM,   PLC,
        "A14",   "Front - Light",            DIM,   PLC,
        "A16",   "Garage - Light",            DIM,   PLC,
        "C16",   "Garage - Water Heater",      NODIM,   PLC,
        "B1",   "Hallway - Light",            DIM,   PLC,
        "B2",   "Kitchen - Light",            DIM,   PLC,
        "B3",   "Computer Room - Light",      DIM,   PLC,
        "B4",   "Back - Light",               NODIM,   PLC,
        "B6",   "Side - Light 1",            NODIM,   PLC,
        "B8",   "Side - Light 2",            NODIM,   PLC,
        "P1",   "All Lights On",            MACRO,   PLC,
        "P2",   "All Lights Off",            MACRO,   PLC,
        "P3",   "All Fans On",               MACRO,   PLC,
        "P4",   "All Fans Off",               MACRO,   PLC,
        "P5",   "All TVs On",               MACRO,   PLC,
        "P6",   "All TVs Off",               MACRO,   PLC,
        // Devices array ends with a special token so we do not have to worry about
        // that last trailing comma when items get rearranged. Do not change it.
        "END"
    );

    // Some global flags to customize script behavior.
    // You don't have to change them unless you don't like the standard behavior.
    //
    // Personalize the page heading any way you like by changing myHeading
    var myHeading = "X10 Controls for My House";
    // Set showServer to false to omit showing the server name or address on page
    var showServer = false;
    // Set button spacer
    //var spacer = "&nbsp;&nbsp;";
    var spacer = "";
   // Set shortButtons to true to omit Dim/Bright percentages from button labels (good for mobile devices)
    var shortButtons = true;
    // Set percentage to dim BY with Dim buttons. Default of 50 seems good.
    // Understand that "DIM 25" means to dim by 25%, not dim to 25%.
    var dimPercent = 50;
    // Set percentage to brighten TO with Bright buttons. Default of 100 seems good.
    // Understand that "BRIGHT 75" means to brighten to 75%, not brighten by 75%.
    var brightPercent = 100;
    // Set showCodes to true to show device X10 addresses & transmit methods as well as names on page
    var showCodes = false;
    // Set showStatus to false to disable browser status line updating
    var showStatus = true;
    // Set promptStatus to false to disable prompt
    var promptStatus = true;
    // Set alertStatus to false to disable alert status
    var alertStatus = true;
    // Set showHovertext to false to not show hovertext.
    // Some broswers put this in the status line, distractingly, instead of as hovertext.
    var showHovertext = true;

    // Some global flags to control how the HTTP command is sent.
    // Change these if you have problems with the standard configuration.
    //
    // Set useAjax to false only if it consistently fails.
    var useAjax = true;
    // Sometimes an exception will be thrown but the command will succeed anyway.
    // If this happens all the time, you can change allowFallback and allowErrorAlert
    // to false.
    var allowFallback = true; // set to false to disable fallback to window.open() if AJAX throws an exception
    var allowErrorAlert = true; // set to false if you get error pop-ups and don't want to see them

    // If you are running this via the http: protocol, and your HTTP server needs
    // a user ID and password for authentication, set them here. Just leave them
    // empty unless you get authentication errors or prompts from your HTTP server.
    // XXX: this is untested. Kindly report authentication problems to the author.
    var serverID = "";
    var serverPassword = "";

    // Set debug to true to show debug output in a popup window. Not for general use.
    var debug = false;

    // ********************** STOP EDITING HERE ****************************
    // *********************** THIS MEANS YOU! *****************************

    // Connect to the X10 Commander server by opening a window.
    // The AJAX method should be preferred.
    function windowMethod(url, closeIt) {
        if (closeIt) {
            var w = window.open(url, "X10Window",
              "dependent,height=1,width=1,location=no,menubar=no,scrollbars=no,status=no,toolbar=no");
            // Immediately close the window.
            w.close();
        }
        else {
          window.open(url, "X10Window",
            "dependent,height=100,width=700,location=yes,menubar=no,scrollbars=no,status=yes,toolbar=no");
        }
    }

    // Connect to the X10 Commander server via AJAX.
    function ajaxMethod(url) {
        try {
            // Send HTTP HEAD without opening a window.
            var request = new XMLHttpRequest();
            request.open("HEAD", url, true, serverID, serverPassword);
            request.send(null);
        }
        catch (e) {
            // Request threw an exception. This does not necessarily mean it failed.
            var err = e; // bring error into scope so it can be examined in debugger
            if (allowErrorAlert) {
                // Show the error message.
                var errString;
                if (typeof(err) == "string") {
                    errString = err;
                }
                else {
                    errString = err.toString();
                    if (errString == null || errString == "" || errString == "[object Error]")
                        errString = err.name + ": " + err.message;
                }
                if (err.message.match(/Access is denied/))
                    // Probably an IE security error.
                    errString += "\nMake sure the server " + location.hostname +
                      " is in your local intranet or other trusted zone.";
                else if (err.message.match(/Security violation/))
                    // Probably an Opera security error.
                    errString +=
                      "\n\nSet \"useAjax\" to \"false\" in the Web X10der script source code \
    because it will always fail with your browser (probably Opera).";
                alert(errString);
            }
            if (allowFallback)
                // Revert to using a browser window to send the command.
                windowMethod(url, true);
        }
    }

    // Turn a device on or off, or brighten or dim it.
    function setDevice(deviceNum, state, transmitMethod) {
        // if (debug) alert("setDevice(" + deviceNum + ", " + state + ", " + transmitMethod + ");");
        // Do not change the 8086 or the funny characters in the url string.
        // X10 Commander server requires them as is.
        var url = "http://" + server + ":8086/?x10command=DEVICE~send" +
            transmitMethod + "~\"" + devices[deviceNum] + " " + state + "\"";
        // Kludge: append timestamp to URL to force IE to open it every time.
        // Other browsers don't seem to need this.
        var today = new Date;
        url += "&time=" + today.getTime();
      // Status/Alert message
      var msg = devices[deviceNum+1] + " set to " + state + " via " + transmitMethod.toUpperCase();
      // Set macro message if running a macro
      if (devices[deviceNum+2] == MACRO)
         msg = "Run macro " + devices[deviceNum+1] + " via " + transmitMethod.toUpperCase();
      var run = true;
      if (promptStatus)
         var run = confirm(msg + "?");
      if (run)
      {
         if (debug)
            // Open a window, leaving it open to show the command sent and the response received.
            windowMethod(url, false);
         else if (useAjax)
            // Use the AJAX method.
            ajaxMethod(url);
         else
            // Use the window.open() method.
            windowMethod(url, true);
         if (showStatus)
            window.status = msg
         if (alertStatus)
            alert(msg);
      }
    }

    // Function to generate the HTML for the page full of buttons.
    function generate() {
        var s; // string accumulator
        // Write some text.
      document.writeln("<meta name='viewport' content='width=device-width, user-scalable=no'>");
        if (myHeading != null && myHeading != "") document.writeln("<h3>&nbsp;" + myHeading + "</h3>");
        if (showServer) document.writeln("<h5>&nbsp;&nbsp;Server: " + server + "</h5>");
        // Write a table, one row per X10 device.
        document.writeln("<br /><table class='table'>");
        for (var i = 0; devices[i] != "END"; i += 4) {
            var lcMethod, ucMethod; // lowercase & uppercase transmission methods
            if (devices[i+3] == RF) { lcMethod = "\"rf\""; ucMethod = "RF"; }
            else { lcMethod = "\"plc\""; ucMethod = "PLC"; }
            // Show the device name.
            document.write("<tr><td style='font-size:14px;'><strong>" + devices[i+1] + "</strong></td>");
            // Show the device address if user wants to see it.
            if (showCodes)
                document.write("<td>(" + devices[i] + " " + ucMethod + ")</td>");
            // Add Off and On buttons, or Run if MACRO
         if (devices[i+2] == MACRO) {
            s = "<td colspan='4'><button type='button'";
            if (showHovertext) s += " title='" + devices[i] + " RUN " + ucMethod + "'";
            s += " onClick='setDevice(" + i + ", \"ON\", " + lcMethod +
              ");'>" + spacer + "RUN" + spacer + "</button></td>"
            document.write(s);
         }
         else {
            s = "<td><button type='button'";
            if (showHovertext) s += " title='" + devices[i] + " ON " + ucMethod + "'";
            s += " onClick='setDevice(" + i + ", \"ON\", " + lcMethod +
              ");'>" + spacer + "ON" + spacer + "</button></td>"
            document.write(s);
            s = "<td><button type='button'";
            if (showHovertext) s += " title='" + devices[i] + " OFF " + ucMethod + "'";
            s += " onClick='setDevice(" + i + ", \"OFF\", " + lcMethod +
              ");'>" + spacer + "OFF" + spacer + "</button></td>"
            document.write(s);
            // If device is dimmable...
            if (devices[i+2] == DIM) {
               // ... add Dim button...
               s = "<td><button type='button'";
               if (showHovertext)
                  s += "title='" + devices[i] + " DIM " + dimPercent + " " + ucMethod + "'";
               s += " onClick='setDevice(" + i + ", \"DIM " + dimPercent + "\", " +
                 lcMethod + ");'>" + spacer + "DIM";
               if (! shortButtons) s += " " + dimPercent + "%";
               s += spacer + "</button></td>";
               document.write(s);
               // ... and Bright button
               s = "<td><button type='button'";
               if (showHovertext)
                  s += "title='" + devices[i] + " BRIGHT " + brightPercent + " " + ucMethod + "'";
               s += " onClick='setDevice(" + i + ", \"BRIGHT " + brightPercent + "\", " +
                 lcMethod + ");'>" + spacer + "BRIGHT";
               if (! shortButtons) s += " " + brightPercent + "%";
               s += spacer + "</button></td>";
               document.write(s);
            }
            else
               document.write("<td colspan='2'></td>");
            }
            document.writeln("</tr>");
        }
        document.write("<tr><td colspan='");
        if (showCodes)
            document.write("6");
        else
            document.write("5");
        document.writeln("'></td></tr></table>");
        if (showStatus)
            window.status = "Thanks for using Web X10der v" + version;
    }

    // -->
    </script>
    </head>

    <body>
    <script type="text/JavaScript" language="JavaScript">
    <!--
    generate();
    // -->
    </script>
    <noscript>
    <h3>You must have JavaScript enabled to use this page.</h3>
    </noscript>
    <!-- vim: set tabstop=4 shiftwidth=4 expandtab lines=44 columns=120: -->
    </body>
    </html>
edgararroyo
 
Posts: 2
Joined: Thu May 22, 2014 8:04 pm

Re: Web Interface To X10 Commander

Postby Marlan45 » Sat Oct 18, 2014 2:04 pm

Hello,

I am using IIS as a web server on a windows 8 computer. Everything is working properly on my local network when using my ipad or any computer. The problems start when I am on the public side (3g) and trying to use my ipad. The web page comes up but I am having the same problems then discussed in the original post. The x10 devices are not triggered on or off.

I am using port 8091 in IIs and I am forwarding this port to my local pc running x10 commander server. I am also forwarding 8086 to my local x10 commander server.

I could not used port 8086 in IIs. re: giving me an error/conflict.

My x10 commander server is running on port 6004 and all is working properly with the x10 commander ios app.

Any ideas why I can't trigger devices on and off when opening up the web page using my public host name on my ipad connected to 3g?

Thank you.
Marlan45
 
Posts: 3
Joined: Sat Dec 08, 2012 10:55 am

PreviousNext

Return to X10 Commander

Who is online

Users browsing this forum: No registered users and 2 guests

cron