Five Things You Didn't Know You Could Do with Perl - ' Controlling Your Home ' (
Page 6 of 6 )
Controlling Your Home
Up to now we've looked at solutions that use the power of the modules available through CPAN to help us write specific scripts. It is the power of the Perl module system that gives Perl, and our scripts, a lot of their appeal.
Now let's look at a complete application. MisterHouse integrates with the X10 system to help control, manage and monitor your home. X10 is a system that uses the cabling of your house or office electricity supply to communicate information. By using the power cables and special plugs and sockets, you can both communicate information and control components in your house.
ADVERTISEMENT
For example, you can use a special socket to control the power to any item with a plug, like a lamp or radio. Other devices include remote controls and infra-red sensors (as used in alarms) to monitor the status of different rooms. You can combine these — for example, to switch on the light when the sensor identifies your presence — or connect it all up to a computer interface to the system, letting your computer monitor the sensors and control the remote switches.
This is where MisterHouse comes in. MisterHouse is an application that interfaces to the X10 system. It provides a simple status application, which you can see in the figure below - that also allows you to interact and directly control and monitor different components in your X10 system. The interface is through either a Tk-based application or through a web interface, which you can see in the screenshot below, taken from the Web site.
The real flexibility and power of MisterHouse comes from being written in Perl. It means we can write our own controls and reactions to events just by writing some Perl code. For example, you could create a simple instruction to start the dishwasher automatically at 10pm each night using:
$dishwasher = new X10_Item('B1');
set $dishwasher ON if time_now '10:00 PM';
Read more about scripting languages! Start with The State of the Scripting Universe. Then, explore each language in more detail, by learning Five Things You Didn't Know You Could Do...