Announcement

Collapse
No announcement yet.

GTCP issues

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    GTCP issues

    I am following nearly verbatim the code prescribed in the help page to run a script remotely....

    http://www.homeseer.com/support/home...r_remotely.htm

    I have two HS servers-- I want to load the values of certain devices from one onto the other. I've had little luck with XAP over a WAN.

    I tried all versions (script, vb, vbnet); I can get it to work initially-- but in all cases I get the message "Unable to connect to Homseer: Error in the register channel: The channel 'gtcp' is already registered. I even get this connecting locally.

    My scripting reference from settings.ini.
    ScriptingReferences=System.xml;System.xml.dll,HomeSeer2.appl ication;HomeSeer2.dll,Scheduler.hsapplication;scheduler.dll

    My latest incarnation is: I invoke this from an event....
    -----------------------------------------
    Imports HomeSeer2

    Public hsinterface As HomeSeer2.application
    Public hsapp As Scheduler.hsapplication

    Sub Main(ByVal Parms As Object)
    Try
    hsinterface = nothing
    hsapp = nothing

    hsinterface = New HomeSeer2.application
    hsinterface.SetHost("localhost")
    'hsinterface.disconnect()

    Dim rval As String = hsinterface.Connect("", "")

    If rval <> "" Then
    MsgBox("Unable to connect to HomeSeer: " & rval)
    Exit Sub
    Else
    MsgBox("Connected")
    End If

    hsapp = hsinterface.GetHSRef
    hsapp.speak("Hello from my application")

    Catch ex As Exception
    MsgBox(ex.Message)
    End Try
    End Sub
    ----------------------------------------
    HS3 Pro Edition 3.0.0.435 (Windows Server 8.1 on ESXi box)

    Plug-Ins Enabled:
    Z-Wave:,RaspberryIO:,AirplaySpeak:,Ecobee:,
    weatherXML:,JowiHue:,APCUPSD:,PHLocation:,Chromecast:,EasyTr igger:

    #2
    I've got that error message before when i've tried to connect and the previous connection was still live. Which I think is what you are getting - it works initially and then won't thereafter. I think you can re-connect when you get the message in the log to the effect remote connection from <ip address> has disconnected or similar...i'm not sure how to actually force a disconnection.

    When are you running that event with a script? If you are doing it more than once after loading HS then I can see why you are getting the message.

    Is there a .disconnect option? I can't remember myself, i'll load up visual basic and have a try.

    Comment


      #3
      I've just checked and there is (not sure i've seen these functions documented before so sorry if this is stuff you know)

      These are the options available to you;

      hsinterface.Connect()
      hsinterface.Disconnect()
      hsinterface.EventCallBack()
      hsinterface.GetHSRef()
      hsinterface.InitializeLifetimeService()
      hsinterface.name()
      hsinterface.RegisterEventCB()
      hsinterface.SetHost()
      hsinterface.Speak()
      So it may be worth at the end of your application trying to disconnect it, then hopefully when you try to run it again it will reconnect...

      Comment


        #4
        Originally posted by mrhappy View Post
        I've got that error message before when i've tried to connect and the previous connection was still live. Which I think is what you are getting - it works initially and then won't thereafter. I think you can re-connect when you get the message in the log to the effect remote connection from <ip address> has disconnected or similar...i'm not sure how to actually force a disconnection.

        When are you running that event with a script? If you are doing it more than once after loading HS then I can see why you are getting the message.

        Is there a .disconnect option? I can't remember myself, i'll load up visual basic and have a try.
        My idea was to run the script every 1-2 minutes and pull down the values/strings from the devices and copy them locally. I want to be able to see them within my HSTouch project. So I would not run it with a script-- but invoke it from HS. Right now I am just doing in manually.

        I did try a .disconnect-- but that doesn't do much. I also tried setting all the variables to "nothing" initially. If I reboot HS it works again. Not ideal.

        What I want is perfect for XAP-- but over a WAN I am having issues.

        Thanks for your help.
        HS3 Pro Edition 3.0.0.435 (Windows Server 8.1 on ESXi box)

        Plug-Ins Enabled:
        Z-Wave:,RaspberryIO:,AirplaySpeak:,Ecobee:,
        weatherXML:,JowiHue:,APCUPSD:,PHLocation:,Chromecast:,EasyTr igger:

        Comment


          #5
          I'm all out of ideas then sorry - got no experience of xAP either, would it be possible to connect when HS loads (perhaps in the startup.vb) and then get the device values periodically? Not sure exactly how to go about this as I get confused with public name spaces, but if you had the connect in a sub routine, then another sub to pull the values (which was called via a timed event) then would this work?

          Failing that what about the using .net.sockets class? You could then send data backwards and forwards relatively easily...

          Comment


            #6
            Did you try the xAP XServer to package the xAP traffic for WAN? http://mi4.biz/modules.php?name=Down...op=MostPopular

            Based upon what it looks like you are doing it may be easy to just post a web page with current status of all the devices that you want on HS touch. In essence your remote HS will serve this web page and your local HS will script with GetURL.

            Comment


              #7
              Originally posted by Michael McSharry View Post
              Did you try the xAP XServer to package the xAP traffic for WAN? http://mi4.biz/modules.php?name=Down...op=MostPopular

              Based upon what it looks like you are doing it may be easy to just post a web page with current status of all the devices that you want on HS touch. In essence your remote HS will serve this web page and your local HS will script with GetURL.
              I tried to run xserver-- but it says there is a xseverclient that I cannot find anywhere. I tried running 2 versions of Xserver- but did not have any luck.

              The documentation doesn't seem to exist.

              I thought about the gerurl method as well. I use this to fetch data from my webcontrol boards.. Would you recommend a put all the devices I want in a custom webpage? How would I go about doing that?
              HS3 Pro Edition 3.0.0.435 (Windows Server 8.1 on ESXi box)

              Plug-Ins Enabled:
              Z-Wave:,RaspberryIO:,AirplaySpeak:,Ecobee:,
              weatherXML:,JowiHue:,APCUPSD:,PHLocation:,Chromecast:,EasyTr igger:

              Comment


                #8
                Have an event run on status change of any of the devices you want to monitor remotely.

                Have that event generate a current status xml file. Your remote HS server runs an event every 65 seconds (1.1 minute) to gather the latest data, and update local devices.

                You could do it with a simple script or with something more elaborate and more robust.

                Have you considered a message queue from the remote HS server to the one with HSTouch server? Perhaps that could retrieve the data via the WAN, update the local HS server, and everybody would be happy.
                huggy_d1

                Automating made easy

                Comment


                  #9
                  Originally posted by huggy_d1 View Post
                  Have an event run on status change of any of the devices you want to monitor remotely.

                  Have that event generate a current status xml file. Your remote HS server runs an event every 65 seconds (1.1 minute) to gather the latest data, and update local devices.

                  You could do it with a simple script or with something more elaborate and more robust.

                  Have you considered a message queue from the remote HS server to the one with HSTouch server? Perhaps that could retrieve the data via the WAN, update the local HS server, and everybody would be happy.
                  I like the XML idea... I imagine I would write to it the html directory so the remote server can access it that way... seems well within my coding bounds...

                  Not sure what you mean by message queue?
                  HS3 Pro Edition 3.0.0.435 (Windows Server 8.1 on ESXi box)

                  Plug-Ins Enabled:
                  Z-Wave:,RaspberryIO:,AirplaySpeak:,Ecobee:,
                  weatherXML:,JowiHue:,APCUPSD:,PHLocation:,Chromecast:,EasyTr igger:

                  Comment


                    #10
                    This wiki page may help http://en.wikipedia.org/wiki/Microsoft_Message_Queuing

                    It's more complicated than the xml and is overkill for what you want right now.

                    xml is easy to code for, easy to troubleshoot, opens in a browser, works easily with geturl, and once received, can be saved to an xml object.

                    That said, I'd probably go with simple raw text, maybe csv style. If you have to search it or want the flexibility to change the remote server's code without changing your local server's code, xml is well suited for that.
                    huggy_d1

                    Automating made easy

                    Comment


                      #11
                      On the remote create an asp/aspx file in the \HTML folder that contains something like the following. I used just an example of value and string for device A1. You would likely want to generalize this in some form of loop. The {} are used in the example since the less than and greater than symbols will be gobbled up in the posting. The syntax is not complete and not accurate so consider this psuedo-code to illustrate an approach.

                      Code:
                      sub main()
                          response.ContentType = "text/html"
                          response.send "{HTML}{BODY}|"
                          response.send "A1_String=" & hs.DeviceString("A1") & "|"
                          response.send "A1_Value=" & cstr(hs.DeviceValue("A1") & "|"
                          response.send "{/BODY}{HTML}
                      end sub
                      On the local computer run a periodic script that requests data in the asp file of the remote. This will cause the remote's file to be run and populate the returned data with current values. "Scrape" the page that was returned. If you wanted to be more of a purist then use XML in the transmission rather than the custom page encoding.

                      Code:
                      sub main()
                          s = hs.GetURL("http://remoteIP:HSPort/example.asp")
                          arrS = split(s,"|")
                          for iProperty = 1 to ubound(arrS) -1
                              arrItem = split(arrS(iProperty),"=")
                              arrDevice = split(arrItem(0),"_")
                              if arrDevice(1) = "String" then
                                  hs.SetDeviceString arrDevice(0), arrItem(1)
                             elseif arrDevice(1) = "Value" then
                                  hs.SetDeviceValue arrDevice(0), arrItem(1)
                             end if
                          next
                      end sub

                      Comment


                        #12
                        I like the idea of the active server page--- it will refresh the content when I need it; so I won't need to update the page whenever I have a change. I like the idea of XML as well-- why not use both?

                        I have the remote stuff written-- what I actually did was use the asp to create a "XML" like page. My hope is that on the server I can use the XML parsing capabilities to pull down the values I want. When I wrote the Google Latitude script-- I used this stuff- so hopefuly I can reuse it. If I look at the source-- it looks like something I can use. (can I use spaces in XML tags?)


                        Maybe I could even use the tags in the XML like asp page to create the devices automagically-- so if something changes remotely-- it will change on other end as well.

                        That is a battle for tomorrow.

                        I really appreciate your guys help.



                        Code:
                        <?xml version="1.0" encoding="ISO-8859-1"?>
                        <%
                           Set objEnum = hs.GetDeviceEnumerator
                        
                           Do While Not objEnum.Finished
                             Set objD = objEnum.GetNext
                        
                             response.send "<" & objD.location & objD.name & ">" & vbcrlf
                             response.send vbtab & "<value>" & hs.DeviceValue(objD.hc & objD.dc) & "</value>" & vbcrlf
                             response.send vbtab & "<string>" & hs.DeviceString(objD.hc & objD.dc) & "</string>" & vbcrlf
                             response.send "</" & objD.location & objD.name & ">" & vbcrlf
                           Loop
                        %>
                        HS3 Pro Edition 3.0.0.435 (Windows Server 8.1 on ESXi box)

                        Plug-Ins Enabled:
                        Z-Wave:,RaspberryIO:,AirplaySpeak:,Ecobee:,
                        weatherXML:,JowiHue:,APCUPSD:,PHLocation:,Chromecast:,EasyTr igger:

                        Comment


                          #13
                          Thanks-- everything came out awesome. I think the scripts will be useful to other so I will post them.
                          HS3 Pro Edition 3.0.0.435 (Windows Server 8.1 on ESXi box)

                          Plug-Ins Enabled:
                          Z-Wave:,RaspberryIO:,AirplaySpeak:,Ecobee:,
                          weatherXML:,JowiHue:,APCUPSD:,PHLocation:,Chromecast:,EasyTr igger:

                          Comment


                            #14
                            Originally posted by wpiman View Post
                            Thanks-- everything came out awesome. I think the scripts will be useful to other so I will post them.
                            I look forward to seeing them.

                            Maybe you can package it up into a plug-in for client/server cross-communications and make a few $'s for the effort too. I have seen a handful of folks looking for a way to integrate systems.
                            huggy_d1

                            Automating made easy

                            Comment

                            Working...
                            X