Homekit Siri

From Domoticz
Jump to: navigation, search

This wiki page describes the installation steps required to install Homekit with Siri support. This enables you to talk to your apple iPhone or iPad to control your domoticz installation (description is based on raspberry pi 2 running domoticz image)

BIG thanks to Joep ( Forum link ). I only followed instructions and wrote this down

Please note that the current Domoticz SDCard image has this included, and you can jump straight to Configure section.

Update your system

Make sure your system is up-to-date:

 sudo apt-get update
 sudo apt-get upgrade

Install dependencies

Node.js

Following the instructions on node.js [1] homepage, it automatically adds the repository and gives you the latest build.

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs

node -v

This should display the version number of the installed node.js

Python

sudo apt-get install python

g++

sudo apt-get install g++

MDNS

sudo apt-get install libavahi-compat-libdnssd-dev

HomeBridge

Installation

Following the instructions on the official Homebridge github page

sudo npm install -g --unsafe-perm homebridge

This will give a global installation of Homebridge. The next step is to install the plugin for Domoticz, following the instructions here homebridge-eDomoticz

sudo npm install -g homebridge-edomoticz

Configure

Start Homebridge, which creates a ~/.homebridge folder. Exit with CTRL-C.

Create config.json file in the HomeBridge config directory:

cd ~/.homebridge/
nano config.json

Paste the following into that file: (this file assumes default install of Domoticz)

It is recommended to create a 'Roomplan' in Domoticz and put all your sensors that you wish to control in this roomplan. Take a note of the roomplan IDX value. Once you created the roomplan, configure home bridge like (use "loadscenes": 0 or 1 depending if you wish to load your groups/scenes as well)

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:21:3E:E4:DE:33",
        "port": 51826,
        "pin": "031-45-154"
    },
    "description": "Configuration file for (e)xtended Domoticz platform.",
    "platforms": [
        {
            "platform": "eDomoticz",
            "name": "eDomoticz",
            "server": "127.0.0.1",
            "port": "8080",
            "ssl": 0,
            "roomid": <Input Domoticz IDX-value>,
            "mqtt": 1
        }
    ],
    "accessories": []
}

First start

homebridge

Start at boot

Install PM2 module:

sudo npm -g install pm2

Now when PM2 is installed, it should work starting Homebridge with the following command:

pm2 start homebridge

Check if Homebridge is running by:

pm2 list

Or for a more detailed description of the process:

pm2 show homebridge

In the detailed description the logs are shown, where you can check if everything went as intended. Or use the log function of PM2

pm2 logs homebridge

Of course you want Homebridge to autostart on boot. PM2 has a command making this easy:

pm2 startup

And this would give you a command to run, depending on your system setup. This is an example from a standard PI Jessie dist.

You have to run this command as root. Execute the following command:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi

It is important that you save the current PM2 process list, it is done by the following command:

pm2 save

After this you should be able to reboot, and hopefully you have working Homebridge-installation starting at boot.

sudo reboot


See PM2 documentation here https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md

Using HomeKit API on the iOS Devices

Choose one of the App's in the App Store that can manage HomeKit devices.

Try some of the following..

Once you've gotten a HomeKit app running on your iOS device, you can begin adding accessories. The app should "discover" the accessories defined in your config.json file, assuming that you're still running the HomeBridge server and you're on the same Wifi network.

When you attempt to add a device, it will ask for a "PIN code". The default code for all HomeBridge accessories is 031-45-154. Adding the device should create some files in the persist directory of the HomeBridge server, which stores the pairing relationship.

Further Readme for homekit: https://github.com/nfarina/homebridge#adding-your-devices-to-ios

To delete all of the home data from your iOS device and iCloud, go to Settings > Privacy > HomeKit and tap Reset HomeKit Configuration.