DIY Raspberry as HomeKit Device

Starting with iOS 10 Apple introduced the Home feature which allows you to control specific devices remotely. Either every lamp and every outlet is connected to your network individually or one device bundles the others through a different protocol.

I love reverse engineering and so this awesome Project HAPServer by KhaosT. It simply turns your Linux computer into a HomeKit Device. It is based on the widely used NodeJS platform and you can create your own, so-called accessories, in NodeJS.

My Setup

  • Three 433 MHz Remote Controlled Outlets ~ 15€
  • Raspberry Pi 2 ~ 25€
  • 433 MHz Transmitter ~ 1€

The Code

I used this NodeJS plugin to control the outlets.

Then used the default Fake_Outlet.accessory as a skeleton for all my accessories.
This is an excerpt of the essential code I use. I wrote the function tristateToDecimal() to convert the states of the DIP-Switches and input them directly.