The Open-Source Classroom

Jarvis, Please Lock the Front Door

Shawn Powers

Issue #264, April 2016

I'm like Tony Stark, but my Jarvis is named Alexa.

Years ago, we put out a request for articles on home automation. About the time Eureka came out on TV, people wanted to have their very own SARAH (Self Actuated Residential Automated Habitat), and it seemed like the perfect time for nerds everywhere to make their houses smart. The problem was, although a few programs existed (MisterHouse for example), the hardware wasn't really reliable or highly available. The X10 company was about the only game in town hardware-wise, and it tended to be glitchy without much advantage over traditional switches.

In recent years, a glut of products have been dumped onto the market, all toting options for automated lighting, wireless switches and so on. Unfortunately, most were very closed and proprietary, forcing users to stick to a specific brand. That probably was the goal, but it backfired, because the concept of branding my house with proprietary hardware and software was anathema. Thankfully, times are changing, and the product that made me jump into the home automation pool with both feet is a surprisingly proprietary one: Amazon Echo (but, more on that later).

Wireless Communication

Several brands of home automation devices use standard Wi-Fi (2.4GHz) to communicate. At first glance, that seems like a good idea. Unfortunately, the 2.4GHz frequency is so cluttered, adding more devices might be counterproductive. It's also a high-bandwidth type protocol, which is just not needed for simple switching and communication.

Most home automation devices, regardless of brand, focus on the 900MHz spectrum. You might remember 900MHz from the days of cordless phones (not cell phones, rather the old cordless phones from the 1990s). For several reasons, 900MHz network devices have never really gone mainstream, which means the frequency isn't oversaturated. It also penetrates walls better, making it perfect for connecting devices around your home.

Unfortunately, everyone has been trying to become “the standard” in home automation, making the various brand names often incompatible with each other. When I decided to start using home automation devices, I wanted something that was compatible with the most products. For me, that meant SmartThings from Samsung. It supports the very common Z-Wave protocol and the ZigBee protocol, which is similar, but is based on an actual IEEE standard (IEEE 802.15.4).

Figure 1. SmartThings is my choice for the most flexible platform upon which to build.

Unfortunately again, even though SmartThings supports Z-Wave and ZigBee, that doesn't mean it has native support for all devices that use Z-Wave or ZigBee. It might be able to communicate with them wirelessly, but it's sorta like using a standard phone line. Just because I can call someone in Germany doesn't mean we'll be able to understand each other once connected. That downfall is actually another reason I chose SmartThings over the alternatives. Even though it doesn't support all devices, it does have a very open development platform that allows users to write device drivers for any product the SmartThings hub can find. That even includes devices it can't communicate with directly, like my Nest thermostat. The developer community is very active, and drivers for devices are usually easy to implement. Be sure to google the device before you buy it though, because some products are just so closed, communicating with them is currently not possible. (I'm looking at you, Insteon.)

The Actual Automation

This is starting to feel like an advertisement for SmartThings, but really it's just my opinion based on lots of research and time using it. When it comes to using your phone to turn lights on and off, or lock doors, most brands work just fine. With SmartThings, however, you can go one step further and write programs that have actual intelligence. Those programs can be shared, and many are available in the SmartThings Marketplace. You can add these “SmartApps” to your system and provide a wide variety of actions based on events.

Figure 2. The Marketplace is full of SmartApps ready to download.

For example, if SmartThings detects my front door opening (due to either detecting motion on the front porch via motion sensor, door opening via door sensor or lock unlocking via manual code entry on my Z-Wave deadbolt), it checks the current time of day and compares that to the sunrise/sunset. If it's dark, it turns my entryway light on for five minutes, then turns it back off. That might seem like a fairly complicated event for a simple action, but that's the beauty of programmatically dealing with mundane house activities. It requires no thought, and the house responds intelligently every time, without any interaction on my part.

If you're not a programmer, that doesn't mean you're left out of the automation game. SmartThings (and in all fairness, several other platforms too) integrates with If This Then That (ifttt.com) for trigger-based actions that will interact with your home. Want to get a call or text if your house senses motion? You could pay for an expensive security system, or you could just have IFTTT call you when SmartThings triggers a motion event. With the flexibility of IFTTT, your smart house becomes one more thing you can add to your recipes.

Figure 3. IFTTT with SmartThings makes your smart house even smarter.

Call Me Alexa

I mentioned earlier that the Amazon Echo is really what convinced me to start delving into the home automation world. That's largely because although the Android app for SmartThings is very nice, it's not very nice if you're a guest. I do have many Z-Wave physical switches installed so lights can be manipulated in the traditional way, but if you have a smart house, you want it to be convenient for people. That's where the integration with Amazon Echo comes into play.

Interacting with SmartThings via Alexa can happen in two basic ways. First, there is direct integration with SmartThings. Unfortunately, the direct integration is limited to turning switches on and off. That sounds great, and it is, but there's so much more I'd like Alexa to do. That's where Alexa and IFTTT comes into play. In fact, I do just as much integration with Alexa and IFTTT as I do with SmartThings.

Figure 4. Alexa can do IFTTT things even if you don't use SmartThings!

Alexa isn't perfect, and sometimes the verbiage has to be perfect in order for it to function properly. That said, it's nice to crawl into bed and say:

  • “Alexa, turn off all lights.” (“All lights” is an Alexa group of SmartThings switches all around our house.)

  • “Alexa, trigger door locks.” (This starts an IFTTT recipe that tells SmartThings to lock all the deadbolts.)

  • “Alexa, bedroom lamps to 20.” (This turns on our reading lamps and dims them to 20%.)

  • “Alexa, turn on box fan.” (This activates an outlet, turning on the fan my wife needs in order to sleep at night.)

  • “Alexa, turn on night mode.” (This triggers a SmartThings virtual switch, which actually activates a certain string of events, which happens to include all of the above actions.)

Don't Skimp on Physical Switches

If I lived alone and never had houseguests, I wouldn't need any physical switches in my house at all. (I'd also smell worse and probably be unshaven.) But because I live in a house with my family, it's very important that our “smart house” is adding value instead of adding unneeded complexity. For example, it's sometimes difficult to get Alexa to do exactly what I want. For some tasks, it's required to say, “Alexa, trigger <ACTION>”, and for other things, it's, “Alexa, turn on <ITEM_OR_TASK>.”

Plus, if you have a house full of people, or if the television is playing, Alexa often can't hear what you're saying clearly. In situations like that, it's vitally important to have a plain-old switch on the wall to turn things on and off. Thankfully, adding a smart switch in place of a traditional light switch often gives you the best of both worlds. You can use traditional (or LED) light bulbs and get the automation by utilizing a wall switch that will turn the lights on and off via physical switching or wireless control. In fact, rather than buying smart light bulbs, I generally try to replace switches instead. A smart bulb is effective only if it's powered on—and if you keep your old switch, you inevitably will shut off the power, making your smart bulbs as dumb as ever.

Getting Started

Rather than just telling you to go buy a specific product, it's important to figure out what you want to accomplish with home automation. I eventually want every possible aspect of my house to be automatic, scriptable or voice-controlled. My wife would be just as happy with Alexa and a few smart light bulbs. When you stick to something basic, like an Amazon Alexa and some Phillips Hue lights, the integration is really simple.

For my personal goals, using a central hub like the Samsung SmartThings Hub was ideal. I can add devices to it. It supports a wide variety of brands and technologies. The open nature of the system means customizations can be made, even some specific to my needs, assuming I learn the programming language. Rather than taking my word for it, I urge you to research the various brands and see what fits into your world the best. Insteon, for example, has the nicest-looking switches available and a wide variety of products for sale. As long as you're happy being limited to those products, it's hard to beat the quality.

Show and Tell

After all the warnings about researching for yourself, it seems only fair to list my experiences with the handful of products I'm currently using (in no particular order).

Samsung SmartThings—Home Monitoring Kit ($249):

This is a pricy kit, but it includes not only the hub (only one hub required per house, regardless of the number of devices you have), but also a smart outlet, motion sensor (with temp sensor) and two door sensors (with vibration detection). This is a great way to start, because it gives you multiple devices that sense things and an outlet to “do” something. You easily can add a few smart light bulbs and make it a complete system.

Figure 5. The Samsung SmartThings Home Monitoring Kit is a great way to start your adventure.

Amazon Echo ($179):

There's actually a few other options for using Alexa. The new Echo Dot is $89, and it has all the same home automation features, it just doesn't have the nice sound system included with the full-blown Echo. It does have audio-out, however, so you potentially could build yourself an even better Alexa. Also, Amazon Fire TV includes Alexa. That version doesn't have all the functionality of the Echo or Echo Dot, but it does support all the home automation features.

Figure 6. The original Amazon Echo or the new Echo Dot both work well for home automation.

Leviton DZPD3-1LW Z-Wave Lamp Dimmer ($33.95):

Rather than install a bunch of expensive light bulbs in our living room lamps, I just bought this dimmer and plugged all the lamps (with extension cords) into the single dimmer module. It allows for on/off functionality, plus it dims all the lamps as well. (Note: it's very important not to plug electronic equipment into the lamp dimmer. It basically provides a brown-out situation and can ruin things like televisions!)

Figure 7. This is a great device for dimming lamps. Unfortunately, it's also great for ruining televisions. Be careful!

Enerwave ZWN-SC7-W 7-button Scene Controller ($42.99):

The problem with the lamp dimmer module is that it doesn't include any switches. Since I replaced a wall-mounted outlet switch with the dimmer module, I just used that junction box and wired this controller in place of the old switch. It required custom programming in order to make it work with SmartThings, but the code is stable and freely available from the SmartThings development community. I use only one of the seven buttons at this point, but I'll use the others for things like lowering my projector screen in the future.

Figure 8. Enerwave 7-Button Scene Controller—I use only the single big button now, but all seven are usable.

Kwikset 910 Z-Wave Smartcode Deadbolt ($150):

This was an expensive purchase, but since we had to replace our locks anyway (we recently moved in and have no idea who has keys to the old locks), it was a good time to make the investment. I'm really glad we did. Using one of the door sensors from the kit above, I have the deadbolt set to lock automatically when the door has been closed for a minute. That means as long as the door is shut, it's effectively locked as well. I sleep a lot better knowing the doors are locked whether I checked them or not. Plus, the programable codes means we won't have to re-key the lock later, just change codes if they are compromised.

Figure 9. This Kwikset deadbolt was expensive, but I think it was worth it. There's a more expensive version available too, with individual buttons for the numbers.

Aeon Labs Aeotec Z-Wave Home Energy Meter ($94.90):

I can't get this to work. I basically want to monitor the usage on our home circuit breaker to see when and what electricity we're using. Unfortunately, I can't get the dumb thing to work with my SmartThings hub. Others have succeeded, so I just need to spend more time on it. I mention it because I don't want everyone to think things always go smoothly. This is technology after all, and technology is frustrating!

Figure 10. This Aeon Labs Home Energy Meter will be cool, if I can ever get it working!

GE 12727 Z-Wave Lighting Control Smart Toggle Switch ($40):

These look at a quick glance like a standard light switch. The “flipper”, however, is always in the center position and can be bumped up or down to trigger the on/off action. It doesn't actually switch to up or down, but activates a switch and then returns to the center position. This is so that if you turn the light on with the switch, then off with electronic automation, the switch isn't in the “wrong” position. It takes a little getting used to, but the function is straightforward even for folks who don't know it's a smart switch. (They just think it's weird!)

Figure 11. It feels weird, but it works like any other switch—sorta.

GE 12724 Z-Wave Smart Dimmer ($40):

This is the same as the above toggle switch, but includes dimming technology. It's also a wide “paddle” type switch. It functions the same way, in that it returns to a middle position, but it's less noticeable with this switch than with the toggle switch. You basically tap the top to turn lights on and the bottom to turn lights off. To dim/undim, you just hold the button up or down.

Figure 12. Perfect for dimming lights, but make sure they're dimmable bulbs!

SmartenIt Three-Button ZigBee Switch ($49.99):

This is a battery-operated switch, which functions a bit like the seven-button switch mentioned earlier, but with four fewer buttons. Also, since it's battery-operated, you can place it anywhere. We actually put this by our bed so we can turn our lamps on/off/20%-dim with the touch of a button. We can do the same with Alexa, but it's nice to have the tactile option as well. This is one of the only available battery-operated switches that I've found, which is frustrating because battery-operated switches are perfect for a smart house that doesn't require your switches to be hard-wired into the house power.

Figure 13. The SmartenIt Three-Button ZigBee Switch is great for sticking places that don't have power lines.

GE Link Wireless A19 Smart Dimmable LED Light Bulb, 60-Watt Equivalent ($15):

These bulbs are cheap. At $15, they're hardly more expensive than a non-smart LED bulb, but they are dimmable and work with SmartTools. I use these in our bedroom lamps. In fact, smart bulbs are best used in lamps where the cords are plugged in so the bulbs have constant power. I used bulbs instead of a common dimmer for both lamps next to our bed so we can have them on/off independently. The three-button switch mentioned previously manages both lamps at once, but Alexa can manage them individually or as a group. It's win/win. The only thing I don't like about them is that although they do dim, it's not an even distribution from 1–100%. There's hardly any variation between 20–100%, and the bulbs really get dim only when you go to 10% or below. That's just a nitpick, however, and the price of the bulbs makes it a complaint I can happily live with.

Figure 14. These GE LinkWireless Smart Dimmable LED bulbs are cheap, but occasionally difficult to pair properly. The cost makes them worth the hassle.

Is Your Home Smart?

As with most of my articles, I write about things I love. If you have implemented smart technology in your house, I'd love to hear about it. Just put something like [SMART HOME] in the subject line, and drop me a message at info@linuxjournal.com. I'm sure I'll follow up with cool things I do or horrible mistakes I make along the path to my future robot army—er, I mean smart home. I'll be sure to share the tips you send if I find them useful.

Shawn Powers is the Associate Editor for Linux Journal. He's also the Gadget Guy for LinuxJournal.com, and he has an interesting collection of vintage Garfield coffee mugs. Don't let his silly hairdo fool you, he's a pretty ordinary guy and can be reached via e-mail at info@linuxjournal.com. Or, swing by the #linuxjournal IRC channel on Freenode.net.