Smart Home Automation with Linux and Raspberry Pi Steven Goodwin Apress*
Contents J About the Author About the Technical Reviewers Acknowledgments Introduction xv xvii xix xxi Chapter 1: Appliance Control: Making Things Do Stuff 1 X10 1 About X10 1 General Design 3 Device Modules 6 Stand-Alone Controllers 14 Gateways and Other Exotic Devices 19 Computer Control 21 Z-Wave 26 System Design 26 Bypassing NDAs 26 ZigBee 28 Linux Software 28 The Differences with Z-Wave 28 C-Bus 29 About C-Bus 29 Differences Between X10 and C-Bus 29 Devices 30 Controllers 31 Gateways 31 vii
CONTENTS Lighting Control 31 Hue 32 Insteon 34 Life 34 Night Lights Sheding Light 34 35 Networked Devices 36 Ethernet Devices 36 Networking Primer 37 CCTV Cameras 43 Stand-Alone BitTorrent Clients 45 Infrared Remote Control 45 All-in-One Remotes 46 IR Relays 46 IR Control 50 Conclusion 51 Chapter 2: Appliance Hacking: Converting Existing Technology 53 Software Hacks 53 Linksys NSLU2 53 Developing on the Slug 55 Hacking Game Consoles 55 Hardware Hacks 60 Linksys NSLU2 60 LEGO Mindstorms 62 Arduino as an I/O Device 63 Joysticks for Input 82 Other Input Controllers 83 Hacking Laptops 83 Your Own Powered Devices 84 Conclusion 86 viii
CONTENTS Chapter 3: Media Systems: Incorporating the TV and the HiFi 87 The Data Chain 87 Extracting the Data 87 Storage 93 Stand-Alone NAS Systems 93 NAS with Media Playback 96 Configuring a Linux Box 96 Media Extenders 99 Stand-Alone Hardware 99 Just Linux 104 Remote Control and UPnP 106 A Brief History of UPnP 106 High-Level Separation of UPnP 109 Distribution 114 Local Processing versus Remote Processing 114 AV Distribution 114 Wiring Looms 116 Wireless AV Distribution 117 Matrix Switchers 117 Control 118 Local Control 118 Remote-Control Methods 119 Conclusion 121 Chapter 4: Home is Home: The Physical Practicalities 123 NodeO 123 Function and Purpose 123 Determining the Best Room 124 Building the Rack 127 Servers 128 Server Capacity 128 ix
is CONTENTS Server Extensibility 129 Types of Server 129 Power Consumption 132 Server Coordination 135 UPS 136 Backups 140 Hiding Your Home 142 Adding to Your Home 144 General Considerations 144 Wired Network 146 Wireless Points 148 Audio Cabling 148 Other Access Points? 150 Conclusion 151 Chapter 5: Communication: Humans Talk. Computers Talk 153 Why Comms? 153 IP Telephony 154 Skype 154 Asterisk 154 E-mail 155 Preparing E-mail in Linux 155 Sending E-mail 155 Autoprocessing E-mails 156 Security Issues 159 Voice 160 The Software for Voice Recognition 160 Remote Voice Control 165 Speech Synthesis 166 Piecemeal Samples 169 Web Access 171 Building a Web Server 171 x
s CONTENTS SMS 179 Processing with a Phone 179 Custom Numbers and APIs 182 Conclusion 188 Chapter 6: Data Sources: Making Homes Smart 189 Why Data Is Important 189 Legalities 189 Distribution 193 Public Data 193 TV Guides 193 Train Times 194 Road Traffic 196 Weather 196 Radio 200 CD Data 202 News 204 Other Public Sources 207 Private Data 207 Calendar 208 Accessing Webmail through P0P3 209 Twitter 211 Facebook 213 Automation 213 Timed Events 213 Error Handling 216 Conclusion 216 Chapter 7: Control Hubs: Bringing It All Together 217 Integration of Technologies 217 The Teakettle: An Example 218 Minerva 220 xi
CONTENTS Overview 220 Linux Users Are Not HA Users 222 Device Abstractions 223 Conduits 227 Messaging Conduits 229 Message Relays 234 Time-Based Messaging 234 Location-Based Messaging 236 Cosmic 237 To Yaks 239 Living Modes 240 Routines 241 Minty 243 The Universal Remote Control 244 Web Applets 246 Manifest 263 Marple 265 Utility Scripts 267 Topology Ideas 269 Networking 269 Wiring Looms 271 Conclusion 273 Chapter 8: Raspberry Pi 275 The Raspberry Pi within HA 275 Obvious Benefits 276 Towards Full Local Control 276 The Joy of Community 277 The Drawbacks 278 Typical Projects 280 The Telephone 280 Child Minding 280 xii
CONTENTS Photo Frames 281 Weather Stations 281 Raspberry Pi as a USB Host 281 As a Device Host 282 Proximity Sensing 283 Coffee Machine 283 Clock Radio 284 Without Mains Power 284 Installation 284 Software 284 Hardware 285 Interfacing With Hardware 286 Hardware Caution 286 With the GPIO 287 With thearduino 290 With SPI 293 WithArduino Shields 294 Software Options 295 Conclusion 296 Index 297 xiii