Beruflich Dokumente
Kultur Dokumente
Appliance Control
One of the most impressive features of an automated smart home is the ability of a computer to control your
lights or to operate the power socket attached to the kettle. Naturally, this requires the addition of hardware,
and the most prominent example here (with a good trade-off between cost, longevity, and flexibility) is called
X10.
X10 is a protocol that places specifically-formatted high frequency power bursts onto the mains power line.
Since the mains cables are connected to every light bulb and power socket in the house, a signal placed onto
the power line in one place is seen across the rest of the mains supply. Consequently, a special X10-enabled
power socket is able to watch for these power bursts and switch itself on or off, accordingly.
To place these X10 signals onto the mains requires a peripheral, such as the CM12U (see figure 1) which also
contains a serial plug (either RS232 or USB) that is inserted into your PC. To receive these signals you can
use either:
An appliance module that will turn a socket on or off. You simply plug this unit into the wall, your
appliance into the other side, and switch the wall socket on. The appliance (such as a kettle) is then
controlled by a remote X10 signal. One such unit is shown in Figure 2.
A light bulb attachment unit, as seen in Figure 3. It is placed in series with a conventional bayonet
light socket, and acts like an AND gate. It can only be controlled through remote X10 signals.
Or a special light switch that replaces your existing switch and will control the light to which it is
attached. This control is either by the switch itself, or remote X10 signals. This can also function as a
dimmer switch, and shown in Figure 4.
Appliance Control
Figure 1: This is the CM12U that transfers X10 signals between your computer and the power line
Figure 2: This listens for X10 signals and controls whatever appliance is plugged into it
Figure 3: Fitting directly into an existing light socket, this is the easiest way to add lighting control to
your home
Appliance Control
Figure 4: This replaces an existing light switch, and is the most effective way of controlling a light
Each of these devices is given an address. This comprises of a house code (A-F) and a unit code (1-16) for the
individual appliance. The house code is necessary because the mains voltage to your house is often fed from
the same supply as that of your neighbour, meaning your appliances would see their X10 signals and
vice-versa. It is possible to buy an X10 suppressor to stop your X10 signals leaking out, but the current take
up of X10 is not universal enough to be a problemunless you live in a block of flats inhabited by geeks, its
unlikely to be a problem in the near future.
A question of countries
NOTE: The mains voltage and frequency varies according to country, so specific devices are needed
depending on where you live. Check the vendor websites carefully. The codes given in this articles are for UK
devices.
Sending suitable X10 signals (through the CM12) requires software, and the current favourite is heyu. This is
not truly open source, but close enough for most purposes. It exists as a simple command line utility (with
configuration in /etc/heyu/x10.conf) that lets you control the lights with commands such as,
heyu turn bedroom_light on
and
heyu dim studio_light 2
These commands can be triggered from a web site, script, crontab, or command line. As an alternative to cron,
you can also upload a program containing a sequence of on/off messages directly into the CM12 as this allows
you to specify a set of timer events that will execute, even when the computer is off.
The CM12 gives more control over the lighting sequences in your house than a traditional timer switch, and
allows you to program more realistic scenarios. For example, you can program a sequence whereby the unit
switches the landing light on, waits one minute, turns the downstairs light off, waits one minute, and then
turns the upstairs light on. This subtlety gives the impression of someone walking up the stairs, and switching
the lights on and off as they go, which is the mark of a human, not a machine.
Since these commands can be placed in a bash script, its trivial to produce a make_a_cuppa script which
switches on the appliance module connected to the kettle (E5 at my home), waits until the kettle has boiled (3
minutes 35 seconds, for 1.5L of water, for example), then announces (via the speech synthesizer, Festival)
A question of countries
Cosmic Control
In addition to receiving signals, there are several X10 devices that can send them, such as the HR10e, in
Figure 5. This is an RF to X10 transmitter, which sends on, off and dimmer messages to the RF receiver
(Figure 6) and places an appropriate signal onto the mains power line. Normally, these messages would go
straight through to the appropriate X10 device, but with a GNU/Linux machine and a CM12 we can listen for
these signals and do something different.
Figure 5: An RF transmitter
The heyu software I described previously is capable of listening to all X10 messages on the power line, and
triggering a command whenever they arrive. So, by adding the following lines to your configuration file:
SCRIPT e1 on :: /usr/local/minerva/bin/mixer default dec master 10
SCRIPT e1 off :: /usr/local/minerva/bin/mixer default inc master 10
You can vary the volume of whatever music is playing on your machine.
Cosmic Control
Media Control
For many people, the start (and end) of their home automation experiments involve media distribution. This
can vary from a simple file server or NAS providing their mp3 collection to their PC, up to a full set of DVR
machines for every room in the house. There is no correct solution here, it varies according to the amount of
time, money, and expertise youre willing to lavish on the problem.
Media Control
Local Operation
Use a PC in each room to stream the file across the network, and decode the music locally. This doesnt need
to be very powerful (a Mini-ITX is more than enough) and there are even hardware solutions, such as the
aforementioned Slingbox. Also, you can use any media player and operating system for this, since you can
simply mount your media server as a normal drive.
Streaming Server
Set up a streaming server in node 0, and use VLC to distribute the music across your wired, and wireless,
network. There is also a plug-in for Firefox that allows you to stream VLC data directly to your browser. It is
also possible to stream using Shoutcast and Darwin.
If video-only is all thats required, as it is with CCTV footage, then camserv is a possibility. This produces
streaming Mjpeg images through a specific port with its own in-built web server, allowing you to view the
camera output from any compatible web browser.
Remote Operation
Put a soundcard in the server, and run audio cables from here to other amplifiers around the house. This
requires some physical work, but it is not hard. From here, you can set-up some simple MP3 jukebox software
on your server, and control your songs playback through a web browser.
I have personally adopted the third approach since I can use the same approach to also control my CD player
(through cdcd), the volume (using aumix) and FM radio (present on most TV cards, controlled through the
fmtools package). In each case, I use Bearskin (part of the Minerva project) to abstract the underlying
software, so should the best tool change I dont need to update any of my scripts or web pages.
TV Bonuses
There are two features, often overlooked, once you have a TV card inside your PC. The first is infra-red
remote control. While some many use the supplied remote to switch channels on the TV card, many will be
impressed by the LIRC project which can watch these IR signals and perform other, more interesting tasks, by
triggering arbitrary scripts on the host PC. It can also function as a mouse if youre running X. Even if youre
DVRs and PVRs
Communication
When you have a house functioning as a peripheral to your computer there is a significant paradigm shift, in
much the same way that broadband brought about a change more substantial than simply faster and
continuous downloads. So having your own home server running 24-7 is more important than the ability to
check your email without tying up the dial-up phone line.
When you have a house functioning as a peripheral to your computer there is a significant paradigm
shift
Being able to connect to your home at any time to check up on a document on your home server is an obvious
benefit, and one GNU/Linux users, through SSH, have enjoyed for many years. But with HA solutions, you
can also check up on the CCTV feeds, or listen to your on-line baby monitor. Both can be serviced through
the same streaming technology (such as vlc) as your MP3 server, thereby eliminating any extra work.
It is not too difficult to extend this idea and roll-your-own security systems, similar to the expensive
proprietary solutions, such as Comfort. Within this example, a simple doorbell and intercom becomes a
significant improvement in household security, as the intercoms audio can be routed (via Asterisk ) to your
desk at work, or mobile phone if youre on holiday. Any caller can then be made to believe youre indoors,
but bedridden, thus limiting the possibility of a subsequent burglary.
But VoIP is not the only phone-based interface available. There are a number of mobile phones in use that are
compatible with utilities such as Gnokii, Gammu and gsmlib. These allow your suitably-equipped
GNU/Linux machine (youll need an extra cable) to listen to SMS text messages, and trigger scripts according
to their content. These scripts can include controls for your lights, or setting the PVR to record something you
didnt previously know was on. It can also text you alerts without relying on an external (and expensive)
server, so reminders about the last train, or wake-up calls are easy.
Similarly, since everything is run by a GNU/Linux server, it is trivial to add your own mail server into the
mix, and control the other technologies (radio, video, lighting) by email. I have emailed my light switches at
home on many occasions, just because I could! More practically, you could email your kettle when youre
leaving the office, and because it knows how long it takes to boil the kettle, and the commute duration, it can
have a fresh brew ready for you the second you step through the door. Or you could use procmail to
monitor the where are we meeting tonight thread and SMS you of anything marked with change, or
otherwise deemed important. Because this is home automation, you dont need to use on sophisticated
technical solutions to this, as you can rely on the social bond between all those using the system to not abuse
it.
I have emailed my light switches because I can
Advanced users may also use Bluetooth to detect the owners mobile phone coming into range and use this as
a remote control to switch lights on, and start playing music.
Communication
Web Life
While discussing current projects with a friend of mine, he happened to remark that every project of yours
starts with a web page. He was right! This is because the web browser is a ubiquitous piece of technology,
and provides a uniform interface across most devices, making no distinction whether Im at home or work, or
working on a PC, PDA, or mobile phone. There is consequently no difference between what I can do at home,
and at work, and since my data is stored on my own server Im happily in charge (and control) of it. This is a
feature that most commercial solutions have thus far overlooked.
Preparing a home server is easy, since we need only an Apache web server and a rudimentary ability with any
of the P programming languages (Perl, PHP, Python, or, er, Ruby!) With this we can provide access to
Google Calendars, manage our contacts lists, and handle the home notice board. These are accessible from
anywhere in the world, and each PC in the house.
the web browser is a ubiquitous piece of technology
This also provides a common place to store bookmarks for all the familys common web pages, such as those
with the TV listings, weather, or train departures. We already have a number of commonly accessed pages,
each personal to ourselves. For example, we might always read the news from Slashdot, and check our diary,
while we eat breakfast. So gathering this information and unifying it into a daily personal digesteither on a
web page, or transferred to your mobile or PDAis a useful task, and easy to do with free software.
the fridge is the focal point for many families, so having unified access to all data here is a boon to living
Apart from the standard Apache installation, it can be pleasant to setup dynamic DNS so you can access your
home server with http://my.homelinux.net, for example. One service to provide this is DynDNS. You will
naturally have to provide your own security, perhaps with SSL, but there are many documents available on the
web detailing this. It is even possible to require SSL for remote access, but not for local traffic. After all, all
local traffic can only come from your house, where any cracker already has physical access to the machine,
your fridge, and TV set. Such attacks can be dealt with by sending the perpetrator to bed early with no dinner!
Data Sources
What separates a home automation server with any other common-or-garden server is the home-oriented
information present. Conversations and matters of general life such as will it rain this afternoon and I hope
the trains on time are more important to domestic life than how many web pages your Apache installation
can serve. That is, content is king and localized. Consequently, we need to know from where this data
originates, and how to present it.
In all cases web services would appear to be the answer. However, since many content providers are either
unable (or unwilling) to provide their information in a simple and direct manner we have to often get our data
from second hand sources utilizing glue software.
TV Guides
Being able to list todays TV shows that feature Freddie Mercury (I dont consciously remember to look for
them, but Ill watch every one thats on!) is a very useful home-oriented feature. Naturally, a server is the best
place for this because the information can be collated locally, and distributed remotely to whichever machine
youre working at. (Unlike the programme guides found on many digital TV boxes which remain routed to the
Data Sources
The Weather
Both my parents and grandparents had a barometer, which gave an indication of the weather based on changes
in atmospheric pressure. Before they went out, they would tap the barometer to see how the needle moved,
and take their umbrella with them if it moved to the left.
TV Guides
And then processes this XML into a simple description through an XSL stylesheet. The UKXX0088 reference
is an indication of your worldly physical location, so it can get the right forecast for you. This resultant text is
then rendered onto one of my web pages, and spoken (through Festival) over the speakers as part of my
alarm call. All this code is available for free within the Minerva Home Automation suite, but is easy enough
to write yourself.
For more advanced weather reports, some people have their own weather stations at home. These can be
bought from most gadget shops, and are relatively inexpensive. However, most of them function only as
electronic barometers because they cant interface to a computer.
If you cant interface with it you cant automate it
Audio CDs
Most people will know this already, but FreeDB contains the track listings of several million CDs. This can be
incorporated into CD playing applications to provide a nicer interface. The web interface for the CD player
applet, for example, lets you click on the song name in order to play it (see Figure 8) instead of the track
number. Similarly, instead of the rather bland 07 track readout present in the 1980s, this can be rendered to
a web page, Jabber tag line, Twitter, Facebook, or whatever the cool-du-jour happens to be this week!
Whats Next?
FLOSS provides many possibilities to enhance existing HA installations, and in some cases they surpass the
current commercial offerings, but theres always room for improvement in both software and hardware.
Embedded systems are still required in many areas, to reduce the carbon footprint of full-blown PCs in each
room. One such benefit would be a stand-alone kiosk browser. This would run on basic hardware featuring a
network socket, speaker, microphone, a touch-screen display, and nothing else. With this, you have a remote
control that may be placed anywhere in the house giving you full access to everything (including streaming
Whats Next?
10
Biography
Steven Goodwin (/user/39" title="View user profile.): When builders go down to the pub they talk about
football. Presumably therefore, when footballers go down to the pub they talk about builders! When Steven
Goodwin goes down the pub he doesn t talk about football. Or builders. He talks about computers.
Constantly... He is also known as the angry man of open source. Steven Goodwin
(http://www.bluedust.com/blog/) a blog that no one reads that, and a beer podcast
(http://www.thebeercrate.com) that no one listens to :)
Copyright information
This article is made available under the "Attribution-NonCommercial" Creative Commons License 3.0
available from http://creativecommons.org/licenses/by-nc/3.0/.
Source URL:
http://www.freesoftwaremagazine.com/articles/home_automation_in_linux
Biography
11