X10 Community Forum

🖥️ActiveHome Pro => SDK => Topic started by: queequeeg on February 16, 2011, 07:09:18 PM

Title: Anyone got a simple python script?
Post by: queequeeg on February 16, 2011, 07:09:18 PM
I am trying to learn python, and I would love to get my hands on a simple python script. I am currently using just devices and just need something i can dim, turn on, or turn off.

If not can someone give me a advice on what language that a beginner could learn?
Title: Re: Anyone got a simple python script?
Post by: Tuicemen on February 16, 2011, 07:23:00 PM
If not can someone give me a advice on what language that a beginner could learn?
I'd recommend VB.net express, It's  free from Microsoft.
 >!
Title: Re: Anyone got a simple python script?
Post by: jaraco on March 01, 2011, 05:41:23 AM
I am trying to learn python, and I would love to get my hands on a simple python script. I am currently using just devices and just need something i can dim, turn on, or turn off.

The best way to do this currently is to use the COM interfaces, supplied by the SDK. Assuming you have the SDK installed properly, and also 32-bit Python with the pywin32 extensions, you should be able to start sending commands to your device with something like the following:

Code: [Select]
from win32com.client import Dispatch
ah = Dispatch('X10.ActiveHome')
ah.SendAction("sendrf", "a1 on")

That should get you started. Just look for other COM interface examples - they should work similarly in Python as in VB or other languages.

You might also find that some people have chosen to call the ahcmd.exe as a subprocess in order to get things to work. In Python, you can do this:

Code: [Select]
import subprocess
subprocess.check_call(['ahcmd', 'sendrf', 'A1', 'on'])

Hope that helps!
Title: Re: Anyone got a simple python script?
Post by: EL34 on March 18, 2011, 04:19:11 PM
I 2nd Tuices post

I used to try and do all my X10 programming with perl

Then I switched to VB2008 express (free)
The world of windows programming opened up and the X10 stuff was way easier to do.

VB2010 express is available now.
My advice is to bite the bullet and get into VB.net programming.