Apress - Smart Home Automation with Linux (2010)- P31 pptx

5 184 0
Apress - Smart Home Automation with Linux (2010)- P31 pptx

Đang tải... (xem toàn văn)

Thông tin tài liệu

CHAPTER 4 ■ HOME IS HOME 128 The biggest downside with these machines, however, is the lack of bravado when demonstrating your HA setup to friends. After showing how you can e-mail your light switch, send a text message to your video, and have your own home web server, opening a cupboard to show a small box that fits inside your hand is often a letdown for the male ego! Custom Embedded This group features both system-on-a-chip (SoC) machines and single-board computers (SBCs), of which there are many, including the Mini-ITX machines you saw earlier and the NSLU2 from Chapter 2. There are as many combinations of devices as there are uses for machines, so each needs to be considered on its own merits as the various components one often considers standard on a PC, such as a keyboard, mouse, and monitor, are not available on all SBCs such as the Gumstick. 4 Also, some machines, such as the NSLU2, can have issues with seemingly normal peripherals, like USB hubs, and refuse to work with them. Consequently, these types of device are usually better suited to client machines in confined areas of the house, rather than servers, because the server will be running a wide range of software where any annoyances of hardware incompatibility will generally outweigh the benefits of size. Power Consumption For many, home automation is likely to be the first time you need to consider the total cost of ownership (TCO) of a machine by factoring in its power usage. This can be computed empirically by using an electricity usage monitor, like Kill-A-Watt (www.p3international.com/products/special/P4400/P4400- CE.html). Such a device can be plugged into the wall on one side and the computer on the other to determine the power it’s using at any particular time. This will vary depending on whether it’s in the following states: • Idle • Playing optical media • Processing media (playback, recording, and transcoding all differ) • Being used as a desktop machine Knowing this information can help you calculate its running cost by multiplying the wattage shown by 8.76 (the number of hours in a year, divided by 1,000) to produce the number of kilowatt-hours. This is then multiplied by the cost per kilowatt-hour, which is generally shown on your electricity bill, to produce its TCO. 4 These incredible small machines measure less than a stick of chewing gum. See www.gumstix.com. CHAPTER 4 ■ HOME IS HOME 129 ■ Note You can even tweet your home’s power usage with the simple hack known as Tweet-a-Watt, from www.ladyada.net/make/tweetawatt. There are also alternate solutions such as Owl, AlertMe, Wattson, and Enistic. Unless the server manufacturer gives you its full power consumption data (remember that this varies according to task), you can only make a guess at its TCO. Table 4-1 shows some approximate numbers. They have been culled from various empirical tests, although only their relative values should be considered and only then as a guide. Table 4-1. Approximate Power Consumption Device Approximate Wattage Used Desktop machine 60–250 Desktop machine (sleep) 1–5 Laptop machine 15–50 Mini-PC 6–10 Mini-ITX 5 8–20 CRT monitor 80 LCD monitor 35 DVD/CD-ROM (desktop) 20 DVD/CD-ROM (laptop) 5 Hard disk (desktop) 14 Hard disk (laptop) 4 USB-powered devices 2 (each) 5 You can find a more complete power calculator for Mini-ITX machines at www.mini- box.com/site/mb/Power_MB.htm . CHAPTER 4 ■ HOME IS HOME 130 To reduce consumption costs, you can do several small things for both the computer and the other home hardware connected to it. First, switch it off. This applies primarily to consumer electronics such as monitors and TVs, whose power consumption in standby is almost as high as it is in normal mode. Various products on the market detect standby mode either by monitoring the drop in power usage or by catching the IR signal to switch off the TV and consequently isolate all power to the device. In this mode it is, however, impossible to switch it back on automatically. You can manage this automatically using X10 or C-Bus. Second, stop hard drives spinning. This reduces their consumption from 7W to around 1W, depending on device. You can achieve this with the hdparam tool by configuring it like this: # /etc/hdparm.conf /dev/sda { spindown_time = 60 # this means 5 minutes, since each spindown unit is 5 seconds } ■ Note This is reported to work only when the BIOS supports AHCI. In all other cases SATA drives should be controlled with the sg3-utils package. From a longevity point of view, however, hard disks should not be continually spun up and then down since the ball bearings will grind more and eventually wear out. Furthermore, the cost of getting them to spin back up is very high, so you really need to have kept them spun down for around 20 minutes to make the savings worthwhile. Switch into standby, suspend to RAM, or hibernate to disk mode, each saving progressively more power than the previous one. The Advanced Power Management (APM) daemon and tools handle the process itself, while the sleepd daemon can be to used to trigger the APM tools automatically upon certain conditions, such as lack of activity or input. Use alternative components. With the green lobby influencing most companies, you can buy more power-efficient devices than ever before. Better power supplies 6 can provide efficiencies in excess of 80 percent on moderate loads (90W), less powerful graphics cards use less power generally speaking (and often don’t need fans), LCDs monitors are more efficient than CRTs, and the power usage in CPUs can vary wildly, so consider replacing them. Unplug any unused devices, such as the CD drive used once for installation (but never again), USB units, and so on. This can be extended by using external hard disks throughout your system (with the exception of the boot device), which can be powered down via X10 after unmounting. Make use of more solid-state discs and/or laptop hardware where possible. Both are intended to work from batteries and therefore have more suitable CPUs and hardware inside them. For the primary control server, these are perfectly adequate. 6 The 80 Plus project, www.80plus.org, aims to promote manufacturers whose power supplies have a better than 80 percent efficiency rating. The average for a PSU is around 60 percent. CHAPTER 4 ■ HOME IS HOME 131 Use virtual machines (running on VMware, for example) instead of using a completely separate machine. This can offer real benefits when a particular device requires a specific version or operating system. The extra power used in processing the virtual is far behind that of a physical machine. Reducing the load is something that should be considered in as many cases as possible because, although you might save only a watt, over the course of a year this can add up to a reasonable savings. Server Coordination Having multiple servers to control your house is fine. But if they’re all switched on all the time, your electricity bill will increase disproportionately to the benefit gained. This also doesn’t consider the case where the various machines can’t communicate because the master server is offline. Coordinating how to switch specific machines on and off to save power is an easy problem for a human. But it’s incredibly difficult for a machine for automate! You would need to know what services are running on which machines, what dependencies exist on other hardware, and so on. This information would need to be synchronized among all machines in case one went offline (because of power outages or loss of network connectivity). Consequently, it is better to not try or to do one of the following: • Have human-designated time cycles for each machine. • Expect a larger than usual electricity bill. When running a separate media server to transcode streams to the MVPMC, for example, you will know that the machine needs to be on from 6 p.m. each weekday and all weekend, for example. If the machine is also in charge of recording TV programs, you will have write custom code to prevent it from switching off during one of those recordings. The inverse timetable is true of a machine intended to be a download server, when you only want it to be leeching your bandwidth during the early hours of the morning when you’re not likely to be web surfing or working from home. Although it is possible for a machine to self-terminate (through the Linux command shutdown -h now), you can’t generally force it to wake up at a specific time. Therefore, you will always need one machine (such as the lowest-power device you have) that remains on 24/7 to coordinate all the others. Having a machine switch on automatically requires a technology called Wake on LAN (WOL). WOL is enabled on many machines (although sometimes defaulted to off in the BIOS) whereby the motherboard watches for a specially formatted network message containing a “magic packet” sent directly to the machine in question. Since there is no IP address for an machine that is powered down, the MAC address must always be used. (It’s labeled as HWaddr from an ifconfig command.) The command and package to initiate this magic is as follows: etherwake 00:1d:33:a5:63:16 Note that this works only from a “soft” power down and needs power available to it, along with that of any routers between the sending machine and the target. That’s an important point to remember during a power cut! ■ Note Sometimes a password is required for a WOL command to be accepted. This is set in the BIOS of the particular machine and passed as an argument to etherwake. CHAPTER 4 ■ HOME IS HOME 132 Switching particular machines off is easier, because it’s something most desktop users do every day, so I’ll spend little time on it here. In its traditional invocations, you can initiate a shutdown with a single command, with a given delay from the issue of the command to the action with any console alert message you choose. You can also countermand any unenacted shutdown command with the -c flag. All shutdown commands must be carried out by that machine’s root user, and since root is disallowed from connecting to a machine through ssh by default, it is not always obvious how to shut down a remote machine. The standard method is to use sudo, letting a nonprivileged user connect to the machine and then upgrading themselves to root temporarily to shut down the machine with the following: sudo shutdown -h now Although a password is generally required for sudo, this can be waived by amending the /etc/sudoers file with a line such as this: steev localhost=NOPASSWD: /sbin/shutdown This can be automated further by issuing the command from a script that relies on a little-used feature of ssh, namely, the ability to log in, execute a command, and then quit: ssh steev@myhomemachine.homelinux.net 'sudo shutdown -h now' Since the shutdown command was created at a time when all users worked on the console, the alert message is generally invisible to most house users, so you might like to create a shutdown script that uses speech synthesis or music to indicate that the server is being switched off. However, since reboots and shutdowns in Linux are rare and you’re probably in the next room to your “users,” this is less important. Shutting down any Windows machines on your network may be more difficult, since the method for doing so is less well defined. A command such as the following: net rpc shutdown -I 192.168.1.100 -U windows_username%their_password can work in many instances but is dependent on firewalls, file-sharing options, and even the version of Windows. Given these commands to start up and shut down most machines in your home, you can effectively coordinate them to ensure the best power usage scenarios for your needs using a simple crontab on your primary server. UPS An uninterruptable power supply (UPS) is an essential piece of kit for anyone relying on moderate- to high-cost technology. And since your house is now a high-cost peripheral to that high-cost technology, it becomes important part in your HA setup—not just to eliminate the effects of short-term power dropouts and blackouts but to prevent the damage caused by surges. Most UPS units work on the same principle. Namely, a device looking like an oversize multigang power strip connects the mains and a battery together to provide consistent power to four or more sockets. In the cheaper and most commonly seen devices, the device monitors the mains supply and, if it fails or drops below a specified threshold, switches to the battery. The second type of UPS supplies the output from the battery at all times and uses the mains power to keep the battery charged. The shape of . chewing gum. See www.gumstix.com. CHAPTER 4 ■ HOME IS HOME 129 ■ Note You can even tweet your home s power usage with the simple hack known as Tweet-a-Watt, from www.ladyada.net/make/tweetawatt machine 15–50 Mini-PC 6–10 Mini-ITX 5 8–20 CRT monitor 80 LCD monitor 35 DVD/CD-ROM (desktop) 20 DVD/CD-ROM (laptop) 5 Hard disk (desktop) 14 Hard disk (laptop) 4 USB-powered devices. that relies on a little-used feature of ssh, namely, the ability to log in, execute a command, and then quit: ssh steev@myhomemachine.homelinux.net 'sudo shutdown -h now' Since

Ngày đăng: 03/07/2014, 20:20

Mục lục

  • Contents at a Glance

  • About the Technical Reviewers

  • Appliance Control

    • Making Things Do Stuff

    • Using Multiple House Codes

    • Controlling Lights

      • Lamp Module (LM12U)

      • Bayonet Lamp Module (LM15EB)

      • Wall Switch (LW10U)

      • MicroModule with Dimmer (LWM1)

      • DIN Rail Dimmer (LD11)

      • Controlling Appliances

        • Appliance Module (AM12U)

        • Combination Devices

          • Electronic Curtain Rails: Retrofit

          • Electronic Curtain Rails: Prebuilt

          • Tabletop Transmitter Modules

            • Mini Controller (MC460)

            • Sundowner Dusk/Dawn Controller (SD7233/SD533)

            • Mini Timer (MT10U)

            • Handheld Transmitter Modules

              • Handheld RF Remote (HR10U)

              • Keyfob Remote (KR22E)

              • EasyTouch35 Universal Remote Control

              • Gateways and Other Exotic Devices

              • Differences Between X10 and C-Bus

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan