Jaro
10-28-2008, 05:35 PM
Hi,
I was looking for a way to control my X10 devices by keyboard, using mControl. Because I was trying for a quick (and dirty?) solution (and have no experience with the SDK), I decided to take the mControl mobile web-interface and create a script to control the devices using an URL.
This resulted in the following to scripts (attached to this post), which should be put in the root of the mControl webserver:
URLE.aspx: This script accepts a querystring for executing a command or a macro (it creates a SOAP envelope based on the querystring and submits this to mControl for execution).
and
URLI.aspx: This script displays all possible querystrings for your installation (change 'var server = "localhost:29990"; on line 22' in the script to the IP of your installation to create URLs that can be used on any client in your network).
Illustration. To turn device with ID 0 On, the following URL is generated by URLI.aspx and used to invoke URLE.aspx:
http://localhost:29990/URLE.aspx?type=AutomationCommand&devid=0&str=On
Finally, by using a combination of HotkeyP, hstart and wget, I was able to create keyboard shortcuts for controlling my devices. To achieve this, the following should be configured in HotkeyP for any key that you would like to assign to a device command (i.e. turn device 0 on, assuming hstart.exe and wget.exe are installed in C:\tools\):
Command:
C:\tools\hstart.exe
Parameters:
/NOCONSOLE "C:\tools\wget.exe --spider http://localhost:29990/URLE.aspx?type=AutomationCommand&devid=0&str=On"
Window "Minimized" and "Enable multiple instances" activated.
Reason for using hstart is to prevent wget getting the focus and interfering with Media Center, this way wget will run in the background. Reason for using --spider is to prevent wget generating any output (on drive), it will just call the URL.
I hope this is useful. I hope I didn't reinvent the wheel...
-- Jaro
PS. You can also use URLI.aspx to send commands, but in this case some client side javascript processing is required, wget will not do this. My apologies for the lack of comments in the code, I didn't find the time to clean it up. All I did was strip the mControl scripts to end up with the pieces I needed for my purpose.
I was looking for a way to control my X10 devices by keyboard, using mControl. Because I was trying for a quick (and dirty?) solution (and have no experience with the SDK), I decided to take the mControl mobile web-interface and create a script to control the devices using an URL.
This resulted in the following to scripts (attached to this post), which should be put in the root of the mControl webserver:
URLE.aspx: This script accepts a querystring for executing a command or a macro (it creates a SOAP envelope based on the querystring and submits this to mControl for execution).
and
URLI.aspx: This script displays all possible querystrings for your installation (change 'var server = "localhost:29990"; on line 22' in the script to the IP of your installation to create URLs that can be used on any client in your network).
Illustration. To turn device with ID 0 On, the following URL is generated by URLI.aspx and used to invoke URLE.aspx:
http://localhost:29990/URLE.aspx?type=AutomationCommand&devid=0&str=On
Finally, by using a combination of HotkeyP, hstart and wget, I was able to create keyboard shortcuts for controlling my devices. To achieve this, the following should be configured in HotkeyP for any key that you would like to assign to a device command (i.e. turn device 0 on, assuming hstart.exe and wget.exe are installed in C:\tools\):
Command:
C:\tools\hstart.exe
Parameters:
/NOCONSOLE "C:\tools\wget.exe --spider http://localhost:29990/URLE.aspx?type=AutomationCommand&devid=0&str=On"
Window "Minimized" and "Enable multiple instances" activated.
Reason for using hstart is to prevent wget getting the focus and interfering with Media Center, this way wget will run in the background. Reason for using --spider is to prevent wget generating any output (on drive), it will just call the URL.
I hope this is useful. I hope I didn't reinvent the wheel...
-- Jaro
PS. You can also use URLI.aspx to send commands, but in this case some client side javascript processing is required, wget will not do this. My apologies for the lack of comments in the code, I didn't find the time to clean it up. All I did was strip the mControl scripts to end up with the pieces I needed for my purpose.