7

How I Automated my Smart Home with Apple HomeKit and Raspberry Pi

 3 years ago
source link: https://myvirtualcloud.net/how-i-automated-my-smart-home-with-apple-homekit-and-raspberry-pi/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How I Automated my Smart Home with Apple HomeKit and Raspberry Pi

  • 12/26/2017

Nowadays when it comes to home automation, the possibilities are practically endless, and virtually every device in a home can be connected and automated with a little bit of patience and some extra money to spend. There are proprietary and open-source platforms and accessories to choose from and deciding on how to go about automating your home can be a daunting task for newbies.

I went through the home automation challenge myself with my new home, and I will try to make it easier for you to understand why and how I did it. Before I get started, I would like to clarify some of the premises that have driven my decisions.

1 –  My family, for good or the bad, is locked into the Apple ecosystem. My wife and I own iPhones; our daughter has an iPad, we all have MacBook Pros, Apples TVs, Apple Watch, and the Apple Airport Extreme as the home router. Not surprisingly, we are also on iTunes and Apple Music. So, whatever solution I chose would have to be compatible with the Apple ecosystem.

2 –  I have enough devices at home, so a critical metric was to add the least amount of devices, including bridges, sensors, and cameras.

3 –  Alarm Sensors – Fortunately, I moved into new home construction that has been entirely cabled with cat5e cables for PoE (Power Over Ethernet). Furthermore, all doors and windows have been pre-wired with sensors connected to the alarm system.

4 –  Cameras – When it comes to cameras, I wanted to make sure I didn’t have to introduce an NVR in my home, and ensure that the streaming was going directly to the cloud. From my perspective, this is also more secure in case of a home invasion, as the NVR with the images can just be taken out of the home.

5 –  DoorBell – All doorbells have somewhat the same functionality. More on that later.

6 –  Lights and Switches – While there are many accessories to control lighting, in my opinion, the approach of replacing sockets and bulbs is somewhat counter-intuitive. I wanted to make sure that whatever I do, it’s a solution that doesn’t require me to buy expensive replacements from the same vendor. This drove me to look at replacing the house switches with smart switches that can operate with any bulbs.

7 –  Other Devices – I wish I could connect all devices, but not all devices are ready for that. That said, I also managed to automate my TVs, Roomba, and even the Garage Door (ore on that later).

Now that I have revealed my fundamental premises I need to be clear that cost was never a concern for my automation project. I made decisions merely on the features and benefits that I wanted to be delivered to my home. In some cases, I chose not to adopt a more expensive accessory or bridge, but that wasn’t based on cost. So, if you are building a budget conscious home automation project, this likely is not going to work entirely for you. That said, keep reading the article as you will see that I also used open-source components that you can (like I did) efficiently run on a cheap Raspberry Pi3.

Choosing the Platform

I looked at many platforms, read lots of reviews and watched plenty of YoutTube videos, but for the sake of the family in learning how to operate all these smart devices, I ended up choosing the Apple HomeKit platform. Please note that Apple HomeKit may not be the most feature-rich platform, but the native iOS integration wins for me. Furthermore, anything I configured for my home would automatically be exposed to my Apple Watch.

The Apple HomeKit

IMG_3006-576x1024.jpg
Apple HomeKit has been out there for a little while, but for the most part vendor adoption has been low due to a special Apple-specified MFi coprocessor to authenticate, connect and transfer information securely, and also a closed API that didn’t allow vendors to achieve the desired outcome for their devices. So, there aren’t many accessories out there to chose from.

Recently Apple has dropped that requirement and introduced software authentication for its system with iOS 11, and things are slowly changing, with more accessories compatible with HomeKit being made available.

Apple HomeKit is native to iOS, and you can use an Apple TV 4th Gen or an iPad as the home hub. In HomeKit you can configure accessories, rooms, scenes, combine accessories, switch on/off, and create automation rules {if/then/when} for accessories and sensors. Using Apple TV as the bridge, I didn’t have to buy and deploy yet another device – other proprietary platforms would likely require a new bridge.

For my automation, as an example, I have a simple rule that turns entrance overhang lights On for 5 minutes whenever my Ring Doorbell detects motion. Another nice one is the auto turn On of the Christmas Tree lights every day at sunset and turn it off at 11 PM automatically.

With the platform defined it’s was time to choose accessories – in my case, they all must be Apple HomeKit compatible if I want them to be part of the automation rules and single pane of glass to manage them all.

Something I found out later is that even with HomeKit compatible accessories, not all functions and features are exposed to HomeKit, and for some devices, you will still need to configure them using their native iOS app. However, after initial configuration, most of what needs to be done can be performed via HomeKit.

206193826_HomeKit_EN-1-300x78.png

Smart Security Cameras

At this point in time (Dec/2017) the only HomeKit enabled camera available with WiFi support is the Logitech Circle 2. The Circle 2 does not natively support PoE, but I didn’t want to drill holes for the power or have to re-cable only for the cameras.

My preference was to buy a PoE Splitter with a USB connector, the Circle 2 standard power connector. Using this method I was able to feed power to the cameras using the built-in cat5e cables and also send the streaming via WiFi to the Apple Airport Extreme and to Logitech Circle 2 cloud.

I deployed Circle 2 cameras inside and outside my home, and I really like the functionality, including configurable motion zones, smart person detection, and the family-favorite Day Brief feature, where we can see everything that happened during the last 24hs in 60 seconds – mostly the cat and squirrels having fun in the backyard.

circle_web-1024x599.jpg

Live Web View

circle_zoneeditor-1024x599.jpg

Logitech Circle 2 Zone Editor (web only)

The camera has a high price tag and also a subscription model where the Freemium version only gives you 24hs of cloud storage and no smart features. Definitely not cheap, but works really well.

[Automation] I automated the home lighting based on camera motion sensor, so whenever a camera detects motion it starts recording, but also the lights for the areas being recorded are automatical turned on. This enables better recording clarity and hopefully scares anyone willingly trying to get into my property.

Video streaming is also available from AppleTV or from any iOS device part of the Family Sharing.

Smart Lighting

66337-details1.png
Lighting is probably what is most widely available for Apple HomeKit, but most of the solutions are socket or bulb based. I decided to take the grassroots approach and replace the in-wall switches with Lutron Casetta Wireless that fully integrate with Apple HomeKit. Lutron and Leviton are the two most prominent brands in the in-wall switch automation market.

Unfortunately, with Lutron, I had to buy and deploy their home bridge, but it was worthwhile because a single Lutron bridge commands many switches and it will seamlessly integrate with Apple HomeKit. In any case, that was the first extra piece of hardware I had to add to my home.

Lutron has wireless switches with On/Off, Dimmers and Remote Controls for 1-way, 3-way, and multi-location deployments. Please note, that most switches will require ground and neutral wiring, what may be an issue with older buildings.

The only downside of using in-wall switches is that you may need to be the electrician and do the work yourself, including re-wiring, but there are YouTube videos that explain the process in detail. I did it by myself, and while it took some time to learn all the different configurations (at my home I have few 3-way and multi-location switches), after a while, it gets straight-forward. The upside of in-wall switches is that it is a set and forget solution, not requiring specific bulbs or sockets.

[Automation] After configuring the switches, I created a HomeKit Scene, “Goodnight” where I simply say “Siri, Goodnight” and all the lighting are set the way I want. Also, as part of the Goodnight scene, Homekit will check that the front door and the garage doors are closed and turn off the TVs. I also have a movie scene that sets the lighting and sound for the perfect movie experience. (my next venture will be in a home theater with Dolby Atmos)

[Automation] Another automation that I like is the ability to turn on and off multiple switches whenever any switch is used. As an example, I have various switches to control the back porch lighting, and they are in different rooms, but now any switch will trigger all lights at the same time.

Smart Thermostat

Lyric-Hero-300x260.pngThere are few options for Apple HomeKit, and you can check and manage temperature from your phone, and most will use house proximity to adapt the temperature to your preference and location. The most adopted are the Nest and Honeywell.

While I really liked the Nest, it was not compatible with Homekit, so the essential checkbox in my project that was not being ticked. I then watched and read reviews about how the Honeywell Lyric Round Wi-Fi was really good with its geofence feature – and it also integrates with Homekit. To be honest, the Apple HomeKit feature was the decision-factor for the thermostat.

IMG_3018-169x300.jpg
I followed the Lyric instructions (there’s some manual wiring required), and in no time I had installed the accessory, the app and also integrated with HomeKit.

Now our home always has our desired temperature using both cool and heat, and at night it brings the temperature down by 2 degrees automatically just so we can have a cozy sleep. Yes, I can also change the temperature from my couch, but that is never needed.

The Lyric also knows when we are not home based on our phone geolocation and will not waste energy if we are home, but it likewise knows when we crossed the pre-defined geo-boundaries and will make sure it turns itself on if we are getting back home. Most smart thermostats work similarly.

Smart Lock

I initially wanted the August to manage my door lock, but I soon decided that was better to get something a little more robust and permanent, and also containing the actual deadbolt. I looked at Kwikset and Schlage. The problem was that my door has a 2 piece deadbolt and removing the original deadbolt would leave a mark on the external part of the door. Because of that, I ended up choosing the August, which I have been pleased with it.

The August integrates with HomeKit using the AppleTV and enables you to open and close the door using your iPhone or Apple Watch (yes, I use that when I go for a run). I can also check the status of the door with my iOS and the door will auto-close in 5 minutes, in case someone left open.

The August can provide temporary keys to people, but for that, I would have to buy their August Connect bridge and yet another device in my home. I decided not.

[Automation] I also implemented some automation rules for the August. As an example, in my home whenever the door unlocks, and it’s night time, the front overhang lights are turned on automatically for 5 minutes. Of course, with any of Apple HomeKit, accessory status alert are always configurable.

IMG_3007-169x300.jpg

Apple HomeKit Automation Rules for my Home

Non-Apple HomeKit Compatible Devices

So far, despite some trade-off and in the case of the in-wall switches, requiring some work, all the devices were Apple HomeKit compatible, and their installation and configuration were pretty straight-forward. However, I still had accessories that I would like to connect to HomeKit, so I started looking for a solution.

The accessories included a Ring Doorbell, couple Samsung TVs, the Roomba and a Chamberlain MyQ garage door (this last one does support HomeKit with yet another bridge).

DRl6i0YUEAA_BiM-225x300.jpg

I soon learned about the Homebridge project, a lightweight NodeJS server you can run on your home network that emulates the iOS HomeKit API. I looked at the plug-ins available, and they would solve the rest of my automation project while making everything seem native to iOS and HomeKit.

I first thought about buying an Intel NUC for Homebridge, but it felt like bringing an automatic weapon to a sword fight. I next discovered that couple people had ported Homebridge to ARM and that I could run on a Raspberry Pi. I immediately went to Datrium marketing department (the company I work for) and asked for one of the RPi customer giveaways during conferences – and to my luck, they had a spare one. With a little bit more research I learned that there was a Homebridge Docker image and that someone had already created a Dockerfile for that. BINGO!

(I am not going into configuring Homebridge here as it will undoubtedly require a dedicated article)

homebridge-1024x562.jpg

Ring Doorbell (w/ Homebridge)

I had been waiting for a vendor to release a doorbell that could integrate with Apple HomeKit, but despite announcements, no vendor has released anything to date. I had just couple options really, the August and the Ring, but none would integrate with HomeKit. Well, at least until Homebridge. I acquired the Ring  Doorbell Pro.

[Automation] As part of the automation rules, whenever Ring detects front door motion it will turn the front lights On, but we also have been using Ring doorbell and August smart lock to allow the cleaners into the house, so we don’t have to give them a set of keys.

There is also an option to integrate the Ring camera using Homebridge FFmpeg plug-in, but I have not done that yet. If someone rings the door, we use the Ring app to answer, and I think it will stay this way because it also allows for two-way communication. Ideally, the doorbell and the smart-lock should be integrated with the same app, but that is not the case. I’m hopeful that August will solve this problem soon as they have both the smart-lock and the doorbell.

Ring works well, but whenever an Apple HomeKit doorbell is available, I’m likely to replace it. It seems that Ring 2 is ready for it, but not enabled.

More Integrations (w/ Homebridge)

Aditional integration and smart automation in my home using Homebridge include the Roomba vacuum cleaner, the garage door, and the Samsung TVs. I have added them all to the Goodnight scene, and now the system makes sure everything is off, closed and locked as we go to bed.

IMG_3028-225x300.jpg

UPDATE – I have a new and an old Samsung TV. For automation I used Homebridge. Here you will find couple links to Samsung plug-ins. https://www.npmjs.com/search?q=homebridge-plugin%20samsung&page=1&ranking=optimal

The Alarm System

No top-tier alarm monitoring companies on the market are supporting Apple Homekit yet; they all have their own iOS and Android apps. There’s a Homebridge plug-in for SimpliSafe, but I have not tested.

Because of lacking support for HomeKit and because my home was fully cabled with in-wall sensors for windows and doors I didn’t have an option here. I’m just using a standard monitored alarm system with top-tier vendors. They have an iOS app, but it’s not integrated into Homekit unfortunately.

UPDATE – The Honeywell Controller alarm system supports HomeKit.

What’s next and what I’ve learned.

All this home automation is expensive, and the benefits will differ for each and every one of you. In my case, it all started with securing and monitoring the home, but soon it became a hobby, and I had a lot of fun in doing it. As for next steps, I still have lights to add to my Scenes, and I also would like to replace the smoke and carbon dioxide detectors with smart ones that can let me know about an incident even when I am not home. Also, I would like to experiment with music following me across rooms.

There are ways to make all this automation cheaper, but being in the Apple ecosystem Homekit was the right choice for me. Open Source platform options will also work, but based on my experience they require far more engineering work than proprietary platforms such as Apple HomeKit, Wink, Samsung SmartThings and others. Even to get Homebridge to work properly with all devices was a PitA. Moving forward I expect all accessories to be able to talk most platform languages and remove the need for a dedicated bridges.

Do you have your own experience automating your home? Let us know what worked and what didn’t.

This article was first published by Andre Leibovici (@andreleibovici) at myvirtualcloud.net.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK