Raspberry Pi 2 Homekit - From Zero to Hey, Siri (Updated)

141,128

143

91

Posted

Introduction: Raspberry Pi 2 Homekit - From Zero to Hey, Siri (Updated)

UPDATE:

Added the "ready to use" image file link to the youtube video description.

Download, write to SD, and ready to use.

UPDATE 2:

Rpi ZERO version:

Hi,

In this instructable, i will show you, how to install Homekit Bridge to your RPi 2, and control your home accessories.

There is a youtube video too, with step by step tutorial.

For me, Homekit on the RPi2 not worked well with other OS (Raspian), only with a Jessie image.

Tutorial video:

STEP 1 >>

Step 1: Step 1: Install Jessie

Tools needed:

- Jessie OS (version 2015-08-30)

http://sysprogs.com/files/SD/2015-08-30-jessie-ras...

- WinFlashTool (for write image to SD)

http://winflashtool.sysprogs.com/

Download the image and the WFTool from the links, put the image file into the WFTool, and install the OS to the SD

(First step in the video)

Step 2: Step 2: Installs, Installs Everywhere...

1:

Boot the RPi2 with Jessie.

Open a terminal program on your PC/MAC (im using putty)

Connect to your RPi2 with the putty (RPi2 ip found in your router DHCP client list)

Username: pi

Password: raspberry

In the youtube video find this step at 1:17.

2:

next, the ragular update and upgrade:

sudo apt-get update && sudo apt-get upgrade -y

In the youtube video find this step at 1:35.

3:

Add yourself superuser privileges (less "sudo" type)

sudo su

In the youtube video find this step at 2:13

4:

Install python-dev and python-pip

apt-get install python-dev python-pip

In the youtube video find this step at 2:21

5:

Install libavahi and libdnssd

apt-get install libavahi-compat-libdnssd-dev

In the youtube video find this step at 2:27

6:

Download and install the latest node

wget http://node-arm.herokuapp.com/node_latest_armhf.d...

dpkg -i node_latest_armhf.deb

In the youtube video find this step at 2:37

7:

Check node and npm version and installation

node -v

npm -v

8:

Clone Homekit Bridge from github, and go into the HAP-NodeJS folder

git clone https://github.com/KhaosT/HAP-NodeJS.git

cd HAP-NodeJS

In the youtube video find this step at 3:04

9:

There is a lot of missing modules, so install all of them in one command.

npm install -g node-gyp
npm install node-persist && npm install srp && npm install mdns && npm install ed25519 && npm install curve25519 && npm install debug && npm install python-shell

In the youtube video find this step at 3:37

10:

Rebuild

npm rebuild


Step 3: Step 3: Add New Light Accessory

1:

Go into accessories folder, and make a new light accessory:

cd accessories

nano myLight_accessory.js

In the youtube video find this step at 5:13

2:

Copy in this empty .js file everything from the linked homekit.txt file, from the

//Light accessory line

Homekit.txt link:

https://drive.google.com/file/d/0B6GR9Hj5Ut61bDZle...

Rename the accessory, change a little the "username" (looks MAC address, watch out the HEX rules)

Save the file and exit

In the youtube video find this step at 5:46

Step 4: Step 4: Make the Python Files to Control GPIO Pins

1:

in the HAP-NodeJS folder, make a new python folder, go into.

cd ..

mkdir python

cd python

In the youtube video find this step at 7:07

2:

Make the GPIO "on" and "off" python file

nano light1.py

Copy this into:

import RPi.GPIO as GPIO
GPIO.setwarnings(False)

GPIO.setmode(GPIO.BOARD)

GPIO.setup(16, GPIO.OUT)

GPIO.output(16, 1)

Save, and close the file

nano light0.py

Copy this into:

import RPi.GPIO as GPIO
GPIO.setwarnings(False)

GPIO.setmode(GPIO.BOARD)

GPIO.setup(16, GPIO.OUT)

GPIO.output(16, 0)

Save, and close the file

In the youtube video find this step at 7:19

3:

Connect a led GND into one of the RPi2 GND pin. Im used the outer line 3. pin, and connect the led "+" pin tho the RPi2 GPIO.16 pin. Thats the 8. pin in the outer line.

Test the python codes:

python light1.py (led turn on)

python light0.py (led tudn off)

If everything ok, go back to HAP-NodeJS folder.

cd ..

npm rebuild

In the youtube video find this step at 8:14

4:

Start the Homekit Bridge.

node Core.js

Step 5: Stap 5: Config Ios Device

1:

In the video, im using Apple HMCatalog app, but find better homekit app, like EVE elgato.

Add a new home, some room, and one of the rooms, add your new light accessory.

The PIN: 03145154

Add anyway.

In the youtube video find this step at 9:28

2:

Test it, enjoy it!

Thank you.

6 People Made This Project!

Recommendations

  • Epilog Challenge 9

    Epilog Challenge 9
  • First Time Author Contest 2018

    First Time Author Contest 2018
  • Sew Warm Contest 2018

    Sew Warm Contest 2018
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

72 Comments

hi wehn i run "sudo node Core.js" it returns

*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.

*** WARNING *** Please fix your application to use the native API of Avahi!

*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node>

*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.

*** WARNING *** Please fix your application to use the native API of Avahi!

*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister>

HAP-NodeJS starting...

/home/pi/HAP-NodeJS/lib/Service.js:101

if (!this.linkedServices.includes(newLinkedService))

^

TypeError: this.linkedServices.includes is not a function

at Service.addLinkedService (/home/pi/HAP-NodeJS/lib/Service.js:101:30)

at Object.<anonymous> (/home/pi/HAP-NodeJS/accessories/AirConditioner_accessory.js:83:19)

at Module._compile (module.js:435:26)

at Object.Module._extensions..js (module.js:442:10)

at Module.load (module.js:356:32)

at Function.Module._load (module.js:311:12)

at Module.require (module.js:366:17)

at require (module.js:385:17)

at /home/pi/HAP-NodeJS/lib/AccessoryLoader.js:33:29

at Array.forEach (native)
what's the problem?

Any chance someone can tell me what I did wrong?

pi@raspberrypi:~/HAP-NodeJS $ node Core.js

module.js:340

throw err;

^

Error: Cannot find module 'debug'

at Function.Module._resolveFilename (module.js:338:15)

at Function.Module._load (module.js:280:25)

at Module.require (module.js:364:17)

at require (module.js:380:17)

at Object.<anonymous> (/home/pi/HAP-NodeJS/lib/Accessory.js:3:13)

at Module._compile (module.js:456:26)

at Object.Module._extensions..js (module.js:474:10)

at Module.load (module.js:356:32)

at Function.Module._load (module.js:312:12)

at Module.require (module.js:364:17)

I should mention that I tried:

sudo npm insgall debug

npm install mdns

npm rebuild

Will this work on pi 3, too ?

1 in 1 not work, need some modification. I have not pi 3, cannot test it.

Same with the newest pi 2 as i know.

Ok I need Help

So I did everything like you said and every time I run node Core.js it says

Pls Help

Screen Shot 2017-03-10 at 2.50.37 PM.png

Maybe a syntactic error in the js file? check {}, characters.

Good day Imre,

I have created a Homekit light switch with the Raspberry Pi
Zero. Everything work perfectly except I want to take it a step further:

Is the a line of code that I can run on the Raspberry Pi
itself to switch off the light AND notify the Core.js service that the light
has been turned off?

Currently I can run the light0.py file and turn off the
light but the Homekit service does not know about this change and my phone
(Home app) still shows that the light is on.

Ultimately what I want to do is to add a button (Switch) on
the GPIO pins to control the light from the switch and my phone. Can you please
help me?

Thank you in advance

Help please ı realy need to do it