this print for content only—size & color not accurate 7.5 x 9.25 spine = x.xxx" xxx page count Goodwin Smart with Linux Home Automation CYAN MAGENTA YELLOW BLACK PANTONE 123 C Companion eBook Available BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® Smart Home Automation with Linux Dear Reader, With this book you will turn your house into a smart and automated home. You will learn how to put together all the hardware and software needed for home automation, to control appliances such as your teakettle, CCTV, light switches, and TV. You’ll be taught about the devices you can build, adapt, or hack yourself from existing technology to accomplish these goals. In Smart Home Automation with Linux, you’ll discover the scope and possi- bilities involved in creating a practical digital lifestyle. In the realm of media and media control, for instance, you’ll learn how you can read TV schedules digitally and use them to program video remotely through e-mail, SMS, or a web page. You’ll also learn the techniques for streaming music and video from one machine to another, how to give your home its own Twitter and e-mail accounts for sending automatic status reports, and the ability to remotely control the home lights or heating system. Also, Smart Home Automation with Linux describes how you can use speech synthesis and voice recognition systems as a means to converse with your household devices in new, futuristic, ways. Additionally, I’ll also show you how to implement computer-controlled alarm clocks that can speak your daily calendar, news reports, train delays, and local weather forecasts. You can then reuse this same weather data in conjunction with motion sensors to remind you to take an umbrella when you’re about to leave the house on days when the forecast calls for rain! I’ve written this book to document all the processes and lessons I’ve learned when creating my own smart and automated house, and now with the help of this book you can do the same. Steven Goodwin US $34.99 Shelve in: Computer Hardware/ General User level: Beginner to Intermediate www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version ISBN 978-1-4302-2778-6 9 781430 227786 5 3 4 9 9 THE EXPERT’S VOICE ® IN LINUX Smart Home Automation with Linux Steven Goodwin Learn how to control your home from your PC Steven Goodwin, Author of Cross-Platform Game Programming Game Developer’s Open Source Handbook THE APRESS ROADMAP Expert Shell Scripting Smart Home Automation with Linux Automating Linux and Unix System Administration, Second Edition Practical MythTV: Building a PVR and Media Center PC Beginning Ubuntu Linux, Fourth Edition Beginning SUSE Linux, Second Edition Beginning the Linux Command Line THE EXPERT’S VOICE ® IN LINUX Learn how to control your home from your PC www.it-ebooks.info www.it-ebooks.info Smart Home Automation with Linux ■ ■ ■ Steven Goodwin www.it-ebooks.info Smart Home Automation with Linux Copyright © 2010 by Steven Goodwin All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-2778-6 ISBN-13 (electronic): 978-1-4302-2779-3 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Java™ and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc., in the US and other countries. Apress, Inc., is not affiliated with Sun Microsystems, Inc., and this book was written without endorsement from Sun Microsystems, Inc. Publisher and President: Paul Manning Lead Editor: Duncan Parkes Development Editor: Matt Wade Technical Reviewers: Steve Potts and Michael Still Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Anne Collett Copy Editor: Kim Wimpsett Production Support: Patrick Cunningham Indexer: Julie Grady Artist: April Milne Cover Designer: Anna Ishenko Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. For information on translations, please e-mail rights@apress.com, or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at www.apress.com. You will need to answer questions pertaining to this book in order to successfully download the code. www.it-ebooks.info To Mum and Dad for the first automated home I had, where clothes washed themselves and food cooked itself! www.it-ebooks.info iv Contents at a Glance About the Author xii About the Technical Reviewers xiii Acknowledgments xiv Introduction xv ■Chapter 1: Appliance Control 1 ■Chapter 2: Appliance Hacking 49 ■Chapter 3: Media Systems 85 ■Chapter 4: Home Is Home 117 ■Chapter 5: Communication 149 ■Chapter 6: Data Sources 185 ■Chapter 7: Control Hubs 215 Index 269 www.it-ebooks.info v Contents About the Author xii About the Technical Reviewers xiii Acknowledgments xiv Introduction xv ■Chapter 1: Appliance Control 1 X10 1 About X10 2 General Design 4 Device Modules 6 Stand-Alone Controllers 15 Gateways and Other Exotic Devices 20 Computer Control 23 C-Bus 28 About C-Bus 28 Differences Between X10 and C-Bus 28 Devices 29 Controllers 30 Gateways 31 www.it-ebooks.info ■ CONTENTS vi Networked Devices 31 Ethernet Devices 31 Networking Primer 31 CCTV Cameras 38 Stand-Alone BitTorrent Clients 41 Infrared Remote Control 41 All-in-One Remotes 42 IR Relays 42 IR Control 46 Conclusion 48 ■Chapter 2: Appliance Hacking 49 Software Hacks 49 Linksys NSLU2 49 Developing on the Slug 51 Hacking Game Consoles 52 Hardware Hacks 58 Linksys NSLU2 58 LEGO Mindstorms 60 Arduino as an I/O Device 61 Joysticks for Input 79 Other Input Controllers 80 Hacking Laptops 80 Your Own X10 Devices 81 Conclusion 83 www.it-ebooks.info ■ CONTENTS vii ■Chapter 3: Media Systems 85 The Data Chain 85 Extracting the Data 86 Storage 91 Stand-Alone NAS Systems 91 NAS with Media Playback 94 Configuring a Linux Box 95 Media Extenders 98 Stand-Alone Hardware 99 Just Linux 105 Distribution 107 Local Processing vs. Remote Processing 107 AV Distribution 107 Wiring Looms 109 Wireless AV Distribution 110 Matrix Switchers 110 Control 112 Local Control 112 Remote-Control Methods 112 Conclusion 115 ■Chapter 4: Home Is Home 117 Node0 117 Function and Purpose 117 Determining the Best Room 118 Primary Options 121 Building the Rack 122 www.it-ebooks.info ■ CONTENTS viii Servers 123 Purposes of Servers 123 Types of Server 125 Power Consumption 128 Server Coordination 131 UPS 132 Backups 136 Hiding Your Home 140 Adding to Your Home 141 General Considerations 142 Wired Network 143 Wireless Points 145 Audio Cabling 146 Other Access Points? 147 Conclusion 148 ■Chapter 5: Communication 149 Why Comms? 149 IP Telephony 150 Skype 150 Asterisk 151 E-mail 151 Preparing E-mail in Linux 151 Sending E-mail 152 Autoprocessing E-mails 153 Security Issues 156 www.it-ebooks.info [...]... commercial HA companies can be taken, adapted, and implemented with the information presented here using very little effort And then you will graduate from an automated home to a smart home to a personalized smart home! xvi www.it-ebooks.info CHAPTER 1 ■■■ Appliance Control Making Things Do Stuff For most people, home automation begins and ends with the principle of appliance control When any household... enough to understand it!) Steven Goodwin xiv www.it-ebooks.info Introduction Home automation (HA) is anything that your home does for you automatically to make living there more enjoyable or productive A smart home is one that appears to apply intelligence to make that happen To my friends, family, and visitors, my home is both smart and automated; I can e-mail my light switches, I can receive tweets... Manchester, England He is continuously refitting his house with home automation technology ■Michael Still is the author of The Definitive Guide to ImageMagick and Practical MythTV He hacks on a variety of open source projects and likes playing with embedded systems He also spends too much time reading science-fiction novels He lives in Australia with his wife and two kids xiii www.it-ebooks.info Acknowledgments... methods of wiring a home network, and the methods of preparing your home for the patter of tiny silicon feet! This is followed by how to use and install communication protocols, which allow anything in your home to talk to anything else and which is the first step toward true technology homogeneity Finally, the book covers the data sources that provide the information to make your home appear intelligent... people are involved in home automation (and specifically X10) for this to be a practical issue You can provide yourself with some peace of mind right now by placing a filter between the electricity meter and the rest of the house mains This is usually called a whole house filter, and several makes and models exist, such as the PZZ01, which permits 200A of current Naturally, with the levels of current... night without them simply unplugging it, as they might with an AM12U Table 1-1 gives a breakdown of the previously referenced devices Table 1-1 Basic X10 Modules Appliance Name AM12U Appliance Module (plug) AWM2 Appliance MicroModule (in wall) LD11 DIN Rail Dimmer LM10U Wall Switch LM12U Lamp Module LM15EB Bayonet Lamp Module LM15ES Screw-in lamp module LWM1 MicroModule with dimmer LW12 In-wall module with. .. controller earlier, wired to the mains, with control for eight devices, along with “all lights on”/“all units off” and brightness control However, it also includes a light sensor that will switch on a predetermined group of lights when it gets dark and turn them off when it’s light again These brightness settings can be tuned with a little trial and error, although with dusk and dawn changing throughout... from work The growth of this desire for home automation led to the creation of the Minerva project, an open source suite of tools and protocols that make it possible to combine many different technologies and have them interact in new and interesting ways It is a project for which he is still the lead architecture and developer He is also an active member of the Linux, free software, and open source... is not generally practical in a home environment! 5 www.it-ebooks.info CHAPTER 1 ■ APPLIANCE CONTROL • The only time I need to know the numbers by heart is when fumbling with the remote in the dark This is when I’m in bed looking for a light switch Since the master bedroom is upstairs, I start counting upstairs And when lying in bed, I’m facing the rest of the house, with the second bedroom directly... you slightly increase the brightness of a dim light without first making it fully dark, but local control means the light comes on immediately after pressing the button so as to not confuse any guests Figure 1-3 The LW10U, 85 ×85 ×30mm This device also responds to the “all lights on” and “all units off” messages for matching house codes 3 Most home automation enthusiasts are male, which has led to the . PC www.it-ebooks.info www.it-ebooks.info Smart Home Automation with Linux ■ ■ ■ Steven Goodwin www.it-ebooks.info Smart Home Automation with Linux Copyright. Available BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® Smart Home Automation with Linux Dear Reader, With this book you will turn your house into a smart and automated home. You will learn