Hardware Reference
In-Depth Information
The next subtlety comes from the configurability of the teakettle itself. Each has its own peculiarities with regard
to boiling times, so you create a configuration file for your home indicating the X10 address of each teakettle and its
respective boiling time. 2 This is then processed by the main kettle script. I use a configuration script like this:
#!/bin/bash
DEVICE=$1
CMD=$2
# DEVICE here refers to a particular kettle, for those that need
# to differentiate between one in the bedroom, and kitchen.
if [ "$CMD" == "time" ]; then
# report the number of seconds the kettle takes to boil
echo 215
fi
if [ "$CMD" == "device" ]; then
# the x10 device
echo e3
fi
This allows me to add other kettles as needs require, which makes the configuration script look like this:
DEVICE=$1
homedevice default on `kettle.conf $DEVICE device`
sleep `kettle.conf $DEVICE time`
homedevice default off `kettle.conf $DEVICE device`
Note the abstracted script homedevice , instead of heyu , which I'll discuss later.
There is then one detail to add—once the teakettle has switched itself off, you can use the speech synthesis
module to announce the fact. You could alternatively issue a popup window on your terminal, like this:
kdialog --msgbox "The kettle has boiled!"
Providing a fresh boil when you return from work is a similar combination of simple scripts. In this case, you need
to know the time the teakettle takes to boil (as shown earlier) and the travel time from work to home. You then perform
a basic subtraction and issue a sleep before the kettle script is called. What calls the script is then a matter of taste
(no pun intended). If you're used to working on the command line, then a simple script could initiate a sequence to
awaken the teakettle, switch on lights, and so on.
Naturally, this same code could be run from a web page or triggered on receipt of an e-mail.
This works in the specific case where the journey duration is consistent, as it is for walkers, cyclists, and anyone
not reliant on public transport or at the mercy of traffic.
More complex solutions are also possible by looking at the live train departure boards (as covered in Chapter 6),
for example, and letting the computer work out which train you are most likely to have caught and check for its arrival
time before beginning the boil. This is left as an exercise for you!
Naturally, if you have a fast-boiling teakettle, there might be enough time to trigger the script from a pressure mat
sensor under the front door mat or when the Bluetooth dongle detects your phone coming into range for the first time
that day. In that case, by the time you've approached the house, opened the door, and taken off your shoes and coat,
the teakettle is ready.
4HEBOILINGTIMEOFMOSTKETTLESSHORTENSWHENTHEREISLESSWATERSOEMPIRICALLYTESTTHEBOILTIMEWITHAFULLTEAKETTLE
Search WWH ::




Custom Search