Sharing passion in Swift

#38 Home automation with Homebridge

One beautiful day I thought:

“hmm… it would be great to control my gramophone using voice commands…”

After a few weekends everything worked as I had dreamed about:

I’m so excited!:)

Introduction

In today’s post I would like to present simple case: how to control electric devices in our homes with usage of Apple HomeKit. Before we start to dive deeper into the details let’s draft some general schema of the designed system:

Homebridge is a lightweight NodeJS server you can run on your home network that emulates the iOS HomeKit API. It supports plugins, which are community-contributed modules that provide a basic bridge from HomeKit to various 3rd-party APIs provided by manufacturers of “smart home” devices.”

I have used Raspberry Pi 2 model B which I bought 2 years ago. Today I would recommend Raspberry Pi 3 with integrated Wi-fi and Bluetooth. On Raspberry I have Raspian Wheezy but also should work on newer Jessie system.

Raspberry Pi USB Wi-Fi Dongle (optional)

I used this one. You only need this kind of device if your Raspberry doesn’t have built-in Wi-fi module. Wi-fi is required because you need to connect your device to your local network.

and of course: iPhone (also connected to your local Wi-fi)

That’s all. It’s time to build everything from scratch:

Step by step tutorial

1) Install Homebridge on Raspberry Pi

Install Homebridge on your Raspberry Pi. You can find a great tutorial here

2) Install necessary plugins

To see the full list of all available plugins visit this website. In my case I needed to install only one plugin (homebridge-hs100 plugin)

4) Run Homebridge on Raspberry Pi

5) Integration with HomeKit

Open HomeKit on your iPhone and press “Add Accessory” button, it should ask you for a PIN code:

After entering the code you should see an accessory edit view:

After clicking next we go to screen with possibilities to edit smart plug name, location etc.:

6) Control

Siri

Once your device has been added to HomeKit, you should be able to tell Siri to control your devices:

Manually

or you can do the same by clicking on smart plug icon in control center if you marked option “Include in “Favorites” in previous step:

Summary

I have to say that I have had great fun during creating this smart solution!:) My system can only turn on and off my gramophone and there is neither possibily to change volume nor to start play record… but I love what I did and for sure I will invest more time to develop my smart room:) So what can I say?