Some assistance required with a simple Insteon application 2010-09-23T18:01:46+00:00

HOME Forums Gateways EZSrve Some assistance required with a simple Insteon application

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • Anonymous
    Post count: 6
    #40280 |

    Hey folks – I’ve been scanning through these messages for the last few days, but I’m afraid I’m not 100% sure how to proceed, and was hoping that some of the experts here could point me in the right direction.

    I am busy developing a custom app which has some simple insteon connectivity – basically, the client wants to be able to
    a) turn on and off devices
    b) view the current status of devices
    c) change the schedule on these devices

    Now, my problem is as follows : not having immediate access to the clients site, I was furnished with a test Insteon EZServe and a custom switch to test with. I have got everything up and running in the SimpleHomeNet browser app, and am able to turn the switch on and off (which works correctly). However, I have one problem here – the switch is detected as type “OTHER”, and it seems I am unable to change it to anything else. As such, I don’t seem to be able to create any actions on this particular switch, as the list of attributes is empty when I try to create one.

    This is not necessarily a problem, as the requirement from the client is just to be able to do the above three things – however, I now have no idea what xml file I need to read from to see the status of the device, as well as not knowing how to change the status.

    To make a long story short:
    I’m able to communicate with the Insteon EZServe through C#, but I’m unable to figure out what command will cause the switch to turn on and off in the above scenario. Also, my assumption based on the API documents is that “Actions” is the place I need to go to set up schedules for the different scenes – is that correct?

    Sorry for all the probably newbie questions, but I feel like I’m running into a dead end at the moment, and was hoping that somebody here could assist. I’m afraid I don’t know too much information about the switch, since it was just provided to me by the client, but I can probably find out more information if that would help.

    Anonymous
    Post count: 1001

    The following is a sample command to turn an Insteon device ON.

    The following is a sample command to Query an Insteon device

    The following is a sample command to turn an Insteon device OFF

    These assume the โ€œswitchโ€ has the capabilities of most common Insteon devices.

    Without knowing the functional capability of the โ€œswitchโ€ Actions cannot present the options appropriate to the device type. If it functions as a SwitchLinc for example it can be defined as a SwitchLinc.

    Anonymous
    Post count: 6

    Thanks so much for that – I’ll try it out now and get back to you ๐Ÿ™‚

    Anonymous
    Post count: 6

    Hey folks

    Another question from me (and a big thanks to grif for helping me with the last one – working perfectly now, so much obliged)

    OK – like I said in my last post, I was working with a test switch which was running on my local network with IP address 192.168.10.71 going through the default port of 8002 (apparently)

    However, now I’m trying to roll out the finished product to the client, and they have furnished me with the public IP of their Insteon EZServe switch. I know that the IP address/port is correct, as I am able to browse to it and control it via http in the SimpleHomeNet application. However, when i try to connect to it in my application, it seems that it is just not making a connection. My connect method is shown below (I don’t want to include the actual IP address for obvious reasons, but the port that it is using is 81 if that makes a difference).

    I hope this is not too technical, and this is the correct place to post this, but I was hoping that somebody would have some insight as to why this connect method would work correctly for my local switch, but not one over a public IP – it might have something to do with authentication, which didn’t seem to be required to form a connection to the EZServe switch on the local network.

    public void Connect()
    {
    ezsrveIPAddress = IPAddress.Parse(ConfigurationSettings.AppSettings[“AHAUS.ControlCenter.SwitchIP”].ToString());
    ezsrvePort = int.Parse(ConfigurationSettings.AppSettings[“AHAUS.ControlCenter.SwitchPort”].ToString());
    ezsrveTcpClient = new TcpClient(ezsrveIPAddress.ToString(), ezsrvePort);
    ezsrveTcpClient.ReceiveTimeout = 2000;
    ezsrveStream = ezsrveTcpClient.GetStream();

    isConnected = true;
    }

    Hope somebody can help me out, and once again, thanks for your time.

    Anonymous
    Post count: 1001

    Normally I would be thinking firewall when the local network works but accessing over the WAN does not. However, you indicate that the SHN Utility is able to connect to the EZSrve over the WAN so that seems to eliminate that. Have you verified the actual field values before opening the connection over the WAN? What exception (full text) is being thrown?

    Anonymous
    Post count: 6

    Hey Grif

    Please forgive the lateness of getting back to you – I wanted to run a few more tests to make sure that I could give you as much information as I can.

    OK – here’s where I stand now – the exception thrown is actually not thrown on the Connect method, but rather in the method that I try to read from the EZServeStream. The exception is as follows:

    System.Net.Sockets.SocketException : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

    I have tried the same program running both from my home network, and the more secured network at the office and it always seems to give the same exception. The line of code that is throwing the exception is this:

    byte[] results = new byte[8000];
    try
    {
    int len = ezsrveStream.Read(results, 0, 8000);

    The final line of the sample causes the exception. Before this, i have used ezsrveStream.Write to send an XML request for the Devices file, so I’mm fairly sure the Insteon switch is there – it just seems to be unable to read from it. I also have everything wrapped in an

    if (ezsrveStream.CanRead)

    block, which does return true.

    So – I guess my problem is that I’m not sure if the error is in my code, or if it is with the configuration of the EZSrve at the clients location – hopefully this gives a few more details as to the nature of my problem – if you need more code samples, or more information let me know and I’ll be happy to provide what I can.

    Thanks again for all your help so far.

    Anonymous
    Post count: 1001

    Sounds like the Read is timing out. Can’t say I’ve ever tried reading a remote stream with a 2 second timeout. I would suggest some other approach as expecting data to flow over a remote connection in 2 seconds is always going to be problematic I think.

    Anonymous
    Post count: 6

    Sigh – didn’t even notice that the timeout was set so low ๐Ÿ™

    Ok – I increased the timeout value to 20 seconds (just temporarily) – now what seems to be happening is that it is running the read command, but returning nothing, even though the xml file being sent should be valid as it works on my test switch.

    the xml file i’m using to query the devices looks like this:
    “”

    Once again, thanks for all the help so far. Any idea what could be causing the switch to not respond to this command – could it be that the initial Write is not actually writing the xml request to the EZServe or something like that – as you can probably tell, I’m very new to all this stuff, so it’s a little daunting ๐Ÿ™

    Anonymous
    Post count: 1001

    I would try the GetRevision command first to see if you can communicate with the EZServe. This command works for both V1 and V2 EZServes. The format of the response is different depending on whether a V1 or V2 EZServe but the command itself has the same format on both V1 and V2. It will also answer the first question, what revision level is the EZServe running. The next question is how large is the device configuration. A 20 second timeout may not be enough to get a large devices file over the internet. I copied the posted command, removed the escape characters, and successfully executed the command against my local EZServe.

    Anonymous
    Post count: 6

    Just tried it with the GetRevision command, and had exactly the same result – the read command returned absolutely nothing. In my debugger, I can see that the command been written to the EZServe is correct, but whether or not that “Write” actually occurs is not apparent, and I don’t know how to verify that – the problem definitely appears to be in this function:

    public string GetXMLResults(string XMLInput)
    {
    if (ezsrveStream != null)
    {
    ezsrveStream.Close();
    }

    Connect();

    byte[] data = System.Text.Encoding.ASCII.GetBytes(XMLInput);
    ezsrveStream.Write(data, 0, data.Length);
    string XMLString = "";

    if (ezsrveStream.CanRead)
    {
    // Receive the result
    byte[] results = new byte[8000];
    try
    {
    int len = ezsrveStream.Read(results, 0, 8000);

    if (len > 0)
    {
    foreach (byte b in results)
    {
    if (b.ToString() != "0")
    {
    XMLString += (char)b;
    }
    }
    }

    }
    catch (Exception ex)
    {
    //Response.Write("GetXMLResults:" + ex.Message);
    }
    }
    else
    {
    //Response.Write("Unable to read Network Stream");
    }

    return XMLString;
    }

    a little messy, but worked fine with the other switch – the read operation returns a len of 0, and thereafter it exits the function – sigh ๐Ÿ™

    Anonymous
    Post count: 1001

    If the location where the EZSrve is installed has access to a computer on the local LAN you can run a Telnet debug trace. The telnet trace entries below are from an application that is connecting to the EZSrve, issuing a GetRevision request, reading the response and then disconnecting.

    The telnet commands would look like this ,,,,,

    telnet
    set logfile c:temptelnet.txt (optional if telnet trace file is desired)
    open 192.168.2.3 10001

    At the login prompt enter case sensitive information ….

    EZServe
    Simplehomenet

    assuming the password is the default. Of course the IP address would be that assigned to the EZSrve. Do not forget to specify the port number of 10001. There are network tools such as WireShark which can monitor IP traffic.

    Welcome to SimpleHomeNet Debug Mode

    login: EZServe
    Password: *************
    Debug Mode started for EZServe
    09/28/2010 17.15.29: ezbridgesocket: new connection from 192.168.2.5 on socket 37
    09/28/2010 17.15.29: ezbridge_socket.c – We got a message: No of bytes rcvd 30
    09/28/2010 17.15.29: Structure Memory Reset!
    09/28/2010 17.15.29: Structure Memory Reset!
    09/28/2010 17.15.29: Handler.c – Returning message handler
    09/28/2010 17.15.29: ezbridgesocket: socket 37 hung up

    Things such as how the firewall/router at the customer sight are also important. You mentioned the 8002 port number was changed. This involves setting up port forwarding in the router. You have a challenge trying to debug a new network program to a remote location for sure.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.