Tải bản đầy đủ (.pdf) (5 trang)

Apress - Smart Home Automation with Linux (2010)- P12 ppsx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (251.94 KB, 5 trang )

CHAPTER 1 ■ APPLIANCE CONTROL

38

[cdrom]
comment = Media server's DVD
writable = no
locking = no
path = /dvd
public = yes
preexec = /bin/mount /dvd
postexec = /bin/umount /dvd

The last two lines will automatically mount the disk when asked for and unmount it after it’s been
unused for a short period of time. The system is told how to handle the (un)mounting of /media/dvd with
a suitable description in /etc/fstab.

/dev/scd0 /dvd udf,iso9660 user,noauto 0 0

Depending on the range and login configurations on your network, you may want to set up specific
Samba users. If you’re a sysadmin by trade, setting up a centralized login database for all machines
(Windows/Linux/Mac) might appear like a simple task. But for the rest of us, each machine will maintain
its own set of usernames and passwords. Consequently, the Samba server has no way of knowing about
these other machines or when their respective users decide to change their passwords. This makes it
impossible for Samba to know what username/password combinations it should accept from this other
machine. Therefore, it uses a separate set password table.
You simply need to type, as root, the following for each user who has password access to the
particular Samba shared folders:

smbpasswd -a steev


For each user, you will be asked for the following

New SMB password:
Retype new SMB password:

at which point you can either ask the family member for a password or assign them one—knowing that it
can be changed only by root on this same machine. Once the user has logged in from a particular
machine, however, the operating system will usually remember the credentials, so no one will be
continually prompted for this information.
You should then restart the Samba service to make these changes visible to the world.

/etc/init.d/samba restart

This is all that’s necessary to make the files available across your network. This allows you to use the
various media-streaming devices, or head units, currently available.
CCTV Cameras
Although the perception of CCTV is grainy black-and-white footage attached to small TV screens, the
reality is much removed, particularly since color CCTV is now very cheap and the images are often
transmitted via Ethernet. And although the technology behind webcams and CCTV cameras are similar,
CHAPTER 1 ■ APPLIANCE CONTROL

39

it is not particularly easy to use cheap webcams as a suitable replacement for the more expensive CCTV
cameras:
• Webcams use USB to transmit their data, which imposes a limit on the cable
length to around 5 meters, without special extension cables.
• Webcams don’t work particularly well in low-light environments.
• Webcams are not physically rugged, or waterproof, enough to live outside.
So, although you might be able to get away with a webcam peering out of the window beside the PC

during the daytime, you won’t get much further than that. Instead, you’ll need a specially designed
camera, generally transmitting its images through a wireless network, so you can position the camera
where it’s needed—rather than whether you can run a cable to it.
■ Note Several versions of CCTV camera are available that are wired for indoors only. The primary benefit that
these have over traditional webcams is that they transmit their data across an IP network, meaning they don’t
need to be directly attached to a PC.
Virtually every CCTV camera on the market requires a power cable (although a Power-over-Ethernet
connection can often suffice), so regardless of whether you choose wired or wireless networking, you will
have to run at least one cable to the camera’s location. Apart from that, the main choice is for an indoors
or outdoors mounting, the latter being more resilient to the weather. If you buy for indoors (such as a Y-
cam) and later change your mind, you can usually place it in a wall mount unit (the Y-cam shell) and
attach it underneath a soffit.
For indoor CCTV, used maybe as a baby monitor, there are cameras like the Panasonic Wireless IP
camera (BLC-20), which has motion detection and a built-in web server so it doesn’t need a PC to
operate and can be viewed remotely provided the appropriate network ports are opened on the router.
Its elder brother (BLC-131) also provides remote control of the camera with pan and tilt functionality.
When a camera is located inside but pointing outward, then it is best to look for those supporting
some form of “night view mode.” Those using a CMOS sensor are better in this regard because they can
work at light levels down to 0.2 lux, whereas traditional CCDs (as used in webcams) are a mere 3 lux.
Most CCD cameras that claim night mode usually implement it in software and do nothing that a good
GIMP session couldn’t fix, so opt for CMOS wherever possible.
For the most part, all CCTVs will work in the same way; it’s a case of balancing specification and
price for your budget. Consider the size of the images, FTP upload, web access, whether you get e-mail
notifications on motion detection, and so on.
Wireless Cameras That Aren’t
Many CCTV cameras on the market use the phrase wireless in a context that does not refer to WiFi. One
such device is the XCAM2 Wireless Camera System. They actually use the industrial, scientific, and
medical (ICM) wireless radio band to transmit their signals to a customized receiver, often for display on
an attached monitor. These are therefore unsuitable for integrated home automation solutions, where
the CCTV output needs to be viewed remotely.

CHAPTER 1 ■ APPLIANCE CONTROL

40

However, if the particular receiver provides an output to RCA composite video, you can plug these
into a TV card and record from that or use a hardware media recorder such as the Emprex ME-1. This
limits you to one camera and prevents you from using the TV card (for recording or watching) while the
CCTV is active. Of these, the second problem is easily solved by buying a second TV card. The former is
more difficult.
If you need multiple cameras, then you will need to employ some additional control hardware,
which could push the cost beyond that of an all-in-one IPCCTV camera. There are two approaches to the
problem.
The first involves using several cameras but only one receiver. You can then use X10 to switch
particular cameras on and off as required. The receiver will pick up the (only) signal now present and
pass it to the TV card as before. This is the method suggested for the XCAM2, but it means you can’t
review all the cameras at a glance.
The second solution uses multiple receivers (and therefore more cost) and a TV switcher to select
between the different inputs. Some of these will even combine all images into one. Switching these units
will require the use, and programming, of a computer-based IR transmitter because most are not IP-
controllable. (We’ll look at IR control later.)
Custom Hardware
In many cases, it is not necessary to build your own CCTV configurations, because it’s a known problem
for which manufacturers have provided their own solutions. One such unit is a CCTV recorder/DVR,
which usually comes with a CD rewriter and video out. This box will capture the feeds from multiple
cameras and provide their output by S-video or composite, which can then be fed into a TV card, as
before, for remote viewing and recording. Some versions are also supplied with an infrared remote
control and network port.
Another alternative, if you’d like to keep everything PC-based, is a PCI card for real-time
surveillance that can monitor four or more input channels from a single card, like the RW-1240R. The
software and drivers for most of these, however, are currently Windows-based, so we don’t dwell on it

any further.
■ Caution Many of the stand-alone CCTV devices accept camera inputs from BNC video connectors, whereas the
webcam-based ones use RCA.
Linux Software
Once the webcam image is available in a digital format, either through a USB driver or connected to the
composite input of a TV card, the image can be processed or transmitted at will. Generally, the
processing will occur through one of the standard video for Linux drivers (V4L), now in the second major
version. This allows the data to be processed by any compatible software. Here are some examples:
xawtv: An X window utility to play back and record video streams, including
composite input and TV stations. It has some functionality for previewing many
video streams at once, but since most (analog) cards have to retune between
devices, the results are not real time.
CHAPTER 1 ■ APPLIANCE CONTROL

41

camserv: This provides its own web server whereby you can watch the video
input in real time from any web browser, supporting the motion JPEG format.
There is no sound support here, however.
mencoder: Part of the mplayer package, this provides a command-line interface
to record the AV signal from a V4L channel.
motion: A small utility that incorporates motion detection so that you only need
to record the feed (and therefore use up hard disk space) when there is
something moving outside. The specific amount of movement is user
configurable to prevent it wasting space on trees swaying in the wind or your
cat walking across the view.
Stand-Alone BitTorrent Clients
This is one of many “Linux-in-a-box” devices that have seen an upsurge in recent years, and no doubt
there will be more to come. These, such as the Emprex NDS-100, take the place of a full-powered PC and
provide functionality for BitTorrent and file and printer sharing. Essentially, it’s the low-power

functionality you’d want from an always-on machine, without the high-power hardware to run it. If you
already have, or plan on using, your own home server for other things, then this will not save you much
depending on the type of server used. A Mini-ITX box, for example, will have a similar power footprint
and provide a better level of functionality.
Infrared Remote Control
For coach-potato living, nothing has the convenience of an infrared remote control. A small infrared
LED in the handset flashes in a predetermined sequence, which an “eye” on the receiving device
decodes to change the channel, increase the volume, and so on. IR remotes are so cheap that every
device has once. That is the first problem because as the number of devices increases, the free space on
the sofa proportionally decreases!
The second problem is line of sight, by which all IR remotes work. This means you have to point the
remote at the device, within a moderate tolerance, for the signal to be received. But it’s not always
convenient to have the device placed in front of you; a projector, for example, will usually be behind you.
If the TV audio is wired up to a HiFi, they may be in different places in the room, because of lack of space
or power sockets. Or you might want to run cables from the DVD player into the bedroom or kitchen to
continue a film uninterrupted. In each case, you may be unable to remotely control the device without
moving yourself or the devices.
An occasionally third problem with IR remote controls is with the receiving eye, which doesn’t
always see the signal. This third problem can often be solved by placing a piece of frosted glass or Scotch
Magic Tape
14
over the “eye.” This diffracts the incoming light from a greater range of angles, making it
more sensitive. The first two problems need more involved hardware.


14
See www.cleverandeasy.com/Multimedia/increase-operating-angle-of-infrared-remote-control.html.
CHAPTER 1 ■ APPLIANCE CONTROL

42


All-in-One Remotes
There are so many combined all-in-one remotes that it’s difficult to know which to get without trying
them. Unfortunately, that is what you must generally do, because each one has some quirk or another
that makes it unsuitable for your particular set of devices.
Although several varieties of “all-in-one” remotes exist, they are not created equally. You need to
consider the specifics of each device you want to control because in the United Kingdom and Ireland,
Sky Plus, for example, uses a slightly different IR protocol than normal, so unless your remote is
specifically designed to handle it, you device will appear mute.
A number of learning remotes are available now, and these can prove a good investment. Another
useful feature is a macro, which will store a number of commands in sequence. For example, a movie
mode macro could switch the TV to DVD input, switch on and eject the DVD tray, and set the HiFi to
accept a DVD input.
IR Relays
These devices overcome the line-of-sight problem by retransmitting IR signals from one place to
another. They consist of both a transmitter (which watches for IR signals and relays them over the air)
and a matched receiver (which replays the same IR message to the device). With a suitable transmission
range, you can remotely control the downstairs TV from upstairs.
Sometimes it’s possible to have multiple transmitters, one in the kitchen and one in the bedroom,
say, that both send the signals to one place, allowing you to remotely control the TV from anywhere.
By the same token, it is sometimes possible to have multiple receivers, enabling an all-in-one
remote to send commands from the bedroom to both the TV downstairs and the HiFi in the next room.
However, this configuration is less common because, if you’ve installed an IR relay, the location of the
equipment doesn’t matter, so it is usually in the same physical location; therefore, you only need to
mount one IR receiver, which sends the relayed signal to all devices at once. If the devices are fairly close
to one another but the receiver can’t see both devices, then it is usual to use a Y-splitter and two IR LEDs
rather than buying another receiver unit.
Communication between the two transmitter and receiver is done through one of the ways outlined
next.
Over the Aerial Cable

If your primary purpose is to relay IR controls for a TV, then you can get devices that embed the IR data
onto the existing coaxial aerial cable, hiding it with similar results to X10. The Labgear MRX120
HandyLink, for example, provides such a solution. Naturally, this approach requires an aerial cable in
each room, which there will be if your focus is TV control. If the aerial cables already exist, then scaling
up is easy, because adding extra amplifiers is fairly cheap and is a simple plug-and-play affair. Without
existing cables, however, this can be more trouble than it’s worth, given the IR-RF-IR possibilities, but it
can provide a solution where RF reception is especially poor.
In both cases, it is impossible to watch different channels in each room, even with Sky, because it’s
distributing a single signal from the tuner.

×