Using a two-button wireless remote
to control a dimmable lamp
Here's a simple tutorial which both solves a little problem,
and illustrates some of the features of XTension and AppleScript.
You have a room 'the office', that has no motion sensor and there is a lamp that you almost always want to be on when you're in the office, and you want to be able to dim or brighten it at will.
Let's say that you come into the office for the first time in the morning, and you press the ON button, and the "Office Lights" brighten up to say 80%. It's still pretty dark outside, so you press the OFF button and the "Office Lights" dim down to 70%, again and they dim to 60 etc.
With one of those little "two-button" wireless remotes, and some scripts in XTension, you can perform a cute little trick.
Within the next 15 minutes or so, and your eyes change, you press the ON or OFF buttons until the lights are set to your satisfaction .
You leave for the afternoon, ( and some other script notes that you are leaving without having turned off the "Office Lights" and does it for you ), returning at dark, and on entering the office, a simple push of the ON button will bring the "Office Lights" up to a pleasant level.
This example is certainly not the most 'intuitive' or even the 'cutest' way to do this, but it should show how to perform simple arithmetic with 'values' of database units, and the proper use of database units for just this kind of 'indirect' method of controlling something.
If you download and 'import' the 'plug-in', you won't have to
type all of this in, and the new database unit called
"xOffice Lights" will be created with its on/off scripts!
You will certainly want to change some values here to suit your personal taste.
This is a good place to say that the verbs "dim" and "brighten" are synonyms. XTension will always know whether to send a "dim" or "bri" command to the lamp, based on the last known value of the unit which is stored in the database.
And because of a regrettable 'slip' of the coding pencil, when you compile a script with "DIM" verbs, XTension will change all of them to: 'brighten'. Do not be worried, write what you want, but do know that ultimately there is no difference in the ultimate command that XTension sends.
Now, here's the OFF script for our unit "xOffice Lights":
You may want to do things differently according to the time of day and day of week?
And notice that the verbs Dim and Brighten are "Synonyms" !
Note that this 'plug-in' creates the new unit called "xOffice Lights". It is given an address, but it is not a 'dimmable' unit in itself.
The "Office Lights" are dimmable, and they have an X-10 address, but they are not 'simulated pre-set dim'.
There are so many ways that you could do this, and so many other kinds of things that you can do with 'macros' and 'pseudo units'.
Don't forget that as with the other tutorials, you will likely have to change the addresses and certainly some of the values to suit.
Something to think about is that this technique, of dimming/brightening rather than turning a lamp on or off, is that it really makes them last longer !
Copyright 2007, Sand Hill Engineering Inc. All rights reserved.
Last modified: July 1, 2007
Michael Ferguson, email@example.com