Page 1 of 1

Help with Python Script...

Posted: Tue Oct 26, 2010 6:19 am
by Livin
Hoping someone can help me with a problem closing a connection to an app. My 'disconnect' statement does not seem to work - even when I don't actually close the target app.

EG log... "Error: Error in register channel: The channel 'gtcp' is already registered."

code...

Code: Select all

import eg
import win32com.client
hsi = win32com.client.Dispatch("HomeSeer2.application")
connected = False
hostname = "localhost"
username = "admin"
password = "password"
print "Contacting Homeseer server " + hostname + " with user credentials from " + username
hsi.SetHost(hostname)
rval = hsi.Connect(username, password)
if rval == "":
    print "Connected to Homeseer server"
    connected = True
else:
    print "Error: " + rval
    hsi.Disconnect
    connected = False
if connected:
    hs = win32com.client.Dispatch("homeseer.application")
    hs.Shutdown()
    hsi.Disconnect

Re: Help with Python Script...

Posted: Tue Oct 26, 2010 1:16 pm
by krambriw
I can just confirm that I get the same problem, it works always the first time after a restart of EvenGhost.

BR Walter

Re: Help with Python Script...

Posted: Tue Oct 26, 2010 2:48 pm
by Livin
I've been working on a complete plugin for Homeseer. Since I travel for work, have a 1 yr old, and other crazy stuff, it is coming very slowly and I'm not good at python - which makes it worse. I used the code you posted as a base and adding a lot to enable dim levels, shutdown, events, etc.

Would you be interested in collaborating? I could use someone with python know-how as I have done all this and more in ASP (vbs) but my python is horrible.

let me know and I can send you the code and thought around how it will work - it will be very slick once it is done.

Re: Help with Python Script...

Posted: Wed Oct 27, 2010 4:01 pm
by krambriw
In this case, my problem is that I'm not a Homeseer user, I have a demo version installed, that's it and I do not see any further need myself for this (which would have been a good motivator I guess)

Besides, right now, I have a little too much as well, not with sw, but my father just passed away so there are a lot with funeral & other practical things to take care

I'm not saying I'm unwilling to help you but I can not commit myself. If you need help with code, I'm always willing to have a look but there are much more python skilled people around on this board. Best would be if we could find some other Homeseer users here

Regarding the problem you detected, "The channel 'gtcp' is already registered", this seems to be a problem related to Homeseer itself, also other developers get this error message from their code. I have so far not seen any solution described

Best regards, Walter

Re: Help with Python Script...

Posted: Wed Oct 27, 2010 4:13 pm
by stottle
krambriw wrote:my father just passed away
My condolences.

Brett

Re: Help with Python Script...

Posted: Thu Oct 28, 2010 11:21 am
by krambriw
Thanks Brett!
Best regards, Walter

Re: Help with Python Script...

Posted: Thu Oct 28, 2010 11:29 am
by krambriw
@Livin,
I don't think a script like that can work. What happens is similar to what is discussed here:
http://social.msdn.microsoft.com/Forums ... 90b988dbcf

"....invoked multiple times, hence it will try to configure remoting multiple times. One TCP port/channel can be configured only once for one application. Trying to configure a channel multiple times generates error...."

Re: Help with Python Script...

Posted: Thu Oct 28, 2010 2:33 pm
by Livin
the problem is that I cannot kill the channel when finished.

Re: Help with Python Script...

Posted: Thu Oct 28, 2010 4:20 pm
by krambriw
nobody can from the client side, the server, in this case homeseer is supposed to do this automatically when you disconnect (at least what I have found)

.net....

Re: Help with Python Script...

Posted: Thu Oct 28, 2010 5:50 pm
by Livin
gotcha... I'll post it in the HS forum.