Use desktop shortcuts to control X10 devices - XPLProject

Contents

Introduction

In this article we will demonstrate how easily xPL-aware devices can be controlled through the use of desktop shortcuts. We will take the control of X10 devices as our example, however control of any xPL device is just as easy.

You should already have an xPLHal installation up and running, and be able to send X10 commands by right-clicking on X10 devices in the xPLHal Manager and switching them on and off. If you haven't got this far yet, we recommend you read the HowTo: Control X10 devices using xPLHal, as this guides you through the process of installing xPLHal and the xPL CM12 interface software.

Note however, that you don't actually need xPLHal for the operations described in this article to work - you will be sending xPL messages that the CM12 will intercept and act upon directly.

Basic Control of X10 devices with x10send.exe

For the first part of this article, we will use a simple command-line tool that was designed purely for sending X10 commands.

Download x10send.zip from http://www.xplproject.org.uk/files/x10send.zip (14KB)

Installing x10send.exe

Just unzip the x10send.zip file you downloaded and place the file x10send.exe into a folder of your choice. You may want to place the file on a network drive to make it easily accessible from any computer on your network.

Switching on an X10 device

In our examples, we will use the X10 address A1, however you can substitute it for a valid X10 address on your own system.

To switch on A1:

  • Right-click on x10send.exe and select Create Shortcut.
  • The shortcut will appear as "Shortcut to x10send.exe". Rename this to something more appropriate, like "Switch on A1".
  • Right-click on the newly created shortcut and select Properties.
  • On the Shortcut tab, click inside the Target field, where you will see the path to x10send.exe already present.
  • At the end of the path to x10send.exe, add the following text (leaving a space after the .exe and the start of the below text):
/device=a1 /command=on
You can change the device=a1 to whatever X10 address is appropriate for you.
  • Click OK.
  • Now try double-clicking on the shortcut. Your X10 device should switch on.

Switching off an X10 device

To switch off A1:

  • Make a copy of your shortcut that switches on A1, and rename it to something appropriate, such as "Switch off A1".
  • Right-click on the "Switch off A1" shortcut and select Properties.
  • On the Shortcut tab, in the Target box, change the portion of text that reads /command=on to /command=off
  • Click OK.
  • Double-click your shortcut, and the X10 device will switch off.

Dimming an X10 device

Note: You must have an X10 lamp module (LM12, LW10 etc) that supports dim and bright commands for this operation to work!

To dim A1 by 50%:

  • Make another copy of your "Switch on A1" shortcut, and call it "Dim A1".
  • View the properties of the shortcut, and on the Shortcut tab, in the Target box, change the portionn of text after x10send.exe to read as follows (inserting your own X10 address as appropriate):
/device=a1 /command=dim /level=50
  • Click OK.
  • First double-click on the shortcut to turn your device on.
  • Now try double-clicking on your dim shortcut, and the lamp should dim to 50%.

Advanced Control of X10 devices with xplsend.exe

The x10send.exe tool is great for sending basic X10 messages, as you don't need to know anything about what's really happening behind the scenes. However, if you want to expand your xPL system into more advanced features, we recommend you use a small command-line tool called xplsend.exe. This tool can send any kind of xPL message - not just X10 messages.

Download xplsend from http://johnb.xplproject.org.uk/downloads/xplsend/xplsend.zip (32KB)

Installing xplsend.exe

Just unzip the xplsend.zip file you downloaded and place the file xplsend.exe into a folder of your choice. You may want to place the file on a network drive to make it easily accessible from any computer on your network.

Using Extended/Professional X10 commands

If you are the owner of an LD11 lamp module, you are probably aware that it can be set to go directly to a specific brightness level, regardless of it's current setting. This is unlike most other X10 lamp modules which only support relative dim and bright commands from their current brightness level. xPL supports the full X10 command set, including transmission of extended X10 commands. Because the basic x10send.exe tool only supports simple on/off/dim/bright commands, we will demonstrate how you can use the generic xPL sender tool to send extended X10 messages.

To set A1 directly to half brightness:

  • Right-click on xplsend.exe and select Create Shortcut.
  • The shortcut will appear as "Shortcut to xplsend.exe". Rename this to something more appropriate, like "Set A1 to half brightness".
  • Right-click on the newly created shortcut and select Properties.
  • On the Shortcut tab, click inside the Target box, where you will see the path to xplsend.exe already present.
  • At the end of the path to xplsend.exe, add the following text:
xpl-cmnd * x10.basic command=extended\ndevice=a1\ndata1=31\ndata2=49
  • Click OK.
  • Double click on the shortcut, and your lamp module should gradually fade to half brightness - regardless of it's current setting.

The xPL message

Now lets explain a bit about what the xplsend.exe command-line parameters mean:

The first parameter, xpl-cmnd, is the type of xPL message, and indicates we want to issue a command.

The second parameter is the target of the message. Because we only have one X10 controller that is xPL-enabled (the CM12), we can set the target to *, which means the message will be processed by any device that can understand X10 messages. If your system contained both a CM12 and a HomeVision, and both were xPL-enabled and capable of reacting to X10 messages, you would need to specify which device should act on your message to prevent them both from attempting to act on your command at the same time.

The third parameter, x10.basic, is the schema. A schema is simply a description of what information the message contains, and in what format.

The last parameter is the body of the message. xPL messages contain one or more name=value pairs, each on their own line. For the purposes of this command-line utility, we use the \n characters to indicate we want a new line. So, in the example above, the xPL body will actually look like this:

   x10.basic
   {
   command=extended
   device=a1
   data1=31
   data2=49
   }

The first item specifies the X10 command to be transmitted - in this case it is the extended command.

Next we specify the X10 devices to which the command should apply. This can be a single device, or it can be a list of devices separated by commas.

The last two items, data1 and data2, refer to the two bytes of extended data that will be transmitted on the powerline. data1 should contain a value between 0 and 63, and will be the brightness level that the LD11 will adjust to. 0-62 will cause the module to change gradually to the desired level, whilst 63 will cause it to go straight to 100% brightness. The data2 byte is set to 49, which is the extended code for Leviton Dim, which is the type of dimming used in the LD11s. Do not change this value.

Conclusion

In this HowTo we have shown you how easily you can control your X10 devices using xPL.

There are already many xPL-enabled devices in addition to the CM12, including caller ID units, infra-red transmitters, text-to-speech applications, network MP3 players and many more. The readme.txt file included with the xplsend.zip package includes some further examples of how you can send different xPL messages using the command-line tool.

xPL is an open protocol, and many of the xPL applications, including all the ones described in this article, are available free of charge and released under the terms of the GNU General Public License.

xPLHal and it's associated applications are being actively developed, so if there's something you'd like xPLHal to be able to do, or you have a question about how to perform a particular task, just ask the development team by posting a message to the mailing list enabled xPL forums.

This page was last modified on 15 February 2008, at 14:26. This page has been accessed 8,231 times.