A simple way to create a poor man's Homegate is to use Expect/Tcl scripts... for Windows users, download the binaries from http://bmrc.berkeley.edu/people/chaffee/expectnt.html ... then you can automate commands to C-Gate by writing the appropriate scripts... for example the following switches off my desk lights by connecting to my c-gate service running on my linux server (bart)... # define c-gate server parameters set hostname "bart" set port "20023" # define cgate v2.3.25 (build 2057) telnet response set cgate_prompt "build 2057" spawn telnet $hostname $port expect -re "$cgate_prompt" { # send c-gate command - turn off lights exp_send "off 254/56/63\r" } expect "200 OK:" exp_send "exit\r" exp_send_user "Light Switched OFF" ... if you save the above as a file (say light_off.tcl), then pass into Expect on the command line you can automate the execution eg. create a Windows desktop icon to the runtime (tclsh80.exe) and pass in the path to the expect script eg. on my system this is - "C:\Program Files\Expect-5.21\bin\tclsh80.exe" "C:\Program Files\Expect-5.21\light_off.tcl" Choose your favorite icon, and away you go. ... another example, to set lights to 50% over 2 sec, with a bit of error handling... set hostname "bart" set port "20023" set cgate_prompt "build 2057" spawn telnet $hostname $port expect -re "$cgate_prompt" { exp_send "ramp 254/56/63 50% 2s\r" exp_send_user "sent c-gate command\n" } eof { exp_send_user "could not connect to $hostname\n" } expect "200 OK:" exp_send "exit\r" exp_send_user "Light Switched On 50%"
Thanks ramon Exactly the idea I need to inspire me. I might try this in python and add on a web UI to it and away we go....
Just in case anyone was wondering the same, I have a basic python script working using the telnetlib module: Code: #!/usr/bin/python import telnetlib host = "cgatehost" port = "20023" telnet = telnetlib.Telnet(host,port) stuff = telnet.read_until("\n") print stuff telnet.write("project list\n") stuff = telnet.read_until("\n") print stuff telnet.close() Something to get people started.