Sunday, 9 October 2016

HomeKit bridge for Z-Wave

Updated 2017-10-25 !

For the moment there are not so many devices available for Apples HomeKit and the devices are Bluetooth, BLE, or WiFi connected so it could be a limited range in Your house.

The Z-Wave solution have a smarter setup running on a type of network called a "mesh network". One Z-Wave product will pass the signal along to another (“hop”) until the final destination is reached. Every device in your home acts as a messenger; the more devices you have, the more powerful and strong your network is.

Also important is the they have a lot of different devices available.

On the other hand I like the Apple solution where You for example can switch on the light in the bedrom whith Siri.  So how to combine them ? 

Out there on the web there are several smart guys who seems to think the same and are very great in programming. So they have fixed applications running on Rasberry Pi which emulates a HomeKit device and on the same time bridges the functions to Z-Wave products.

And now over to the software and installation which assumes that You have a Z-Wave controller up and running on an RPI

The software to be installed is Hombridge, emulating HomeKit, and a Hombridge-Zwave plugin. It is also there I picked up the following installing instructions
So log on to the updated RPi and issue the following command to installing some tools

$ sudo apt-get install git make

Then install Node, a JavaScript engine and NPM a package manager.

$ curl deb.nodesource.com/setup_8.x | sudo bash
$ sudo apt-get install nodejs

Check if everything is OK, by showing respective installed version

$ node -v
v8.7.0
$ npm -v
5.4.2

Install Avahi and other dependencies

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

Install Homebridge and other dependencies

sudo npm install -g --unsafe-perm homebridge hap-nodejs node-gyp
cd /usr/lib/node_modules/homebridge/
sudo npm install --unsafe-perm bignum
cd /usr/lib/node_modules/hap-nodejs/node_modules/mdns
sudo node-gyp BUILDTYPE=Release rebuild
$ cd /

And then Homebridge 

$ sudo npm install -g --unsafe-perm homebridge

To check that Homebridge is correct installed, without the Plugin, run the commando

$ homebridge

At the end of the log You will se 

[10/7/2016, 7:13:52 PM] No plugins found. See the README... on installing plugins.
[10/7/2016, 7:13:52 PM] config.json (/home/pi/.homebridge/config.json) not found.
Scan this code with your HomeKit App on your iOS device to pair with Homebridge:
                       
    ┌────────────┐     
    │ 031-45-154 │     
    └────────────┘     
                       

[10/7/2016, 7:13:52 PM] Homebridge is running on port 34442.

At this moment You can start Your HomeKit iOS app and check that Hombridge is discovered. Terminate the process and install the plugin

$ sudo npm install -g homebridge-zway

Copy the config file to the .homebridge/ folder, rename it to config.json and edit it so it matches the requirements for the plugin. Something like this

{                                        
    "bridge": {                          
        "name": "Homebridge",            
        "username": "CC:22:3D:E3:CE:30", 
        "port": 51826,                   
        "pin": "031-45-154"              
    },                                   
    "description": "Z-Wave controller",  
    "platforms": [                       
      {                                  
        "platform": "ZWayServer",        
        "url": "http://localhost:8083/", 
        "login": "admin",                
        "password": "admin"              
      }                                  
    ]                                    
}                                        

If You don't have the Z-Way server at the same RPi change localhost to the actual IP-adress

Start hombridge and if everything goes right it will show

[10/9/2016, 9:25:56 PM] Loaded plugin: homebridge-zway
[10/9/2016, 9:25:56 PM] Registering accessory 'homebridge-zway.ZWayServer'
[10/9/2016, 9:25:56 PM] Registering platform 'homebridge-zway.ZWayServer'
[10/9/2016, 9:25:56 PM] ---
[10/9/2016, 9:25:56 PM] Loaded config.json with 0 accessories and 1 platforms.
[10/9/2016, 9:25:56 PM] ---
[10/9/2016, 9:25:56 PM] Loading 1 platforms...
[10/9/2016, 9:25:56 PM] Initializing ZWayServer platform...
[10/9/2016, 9:25:57 PM] Initializing platform accessory 'Switch (2.0)'...
Scan this code with your HomeKit App on your iOS device to pair with Homebridge:
                       
    ┌────────────┐     
    │ 031-45-154 │     
    └────────────┘     
                       

[10/9/2016, 9:25:57 PM] Homebridge is running on port 51826.

Run Your iOS App and check that Homebridge and, in this case, the Switch(2.0),appears

Configure autostart at power on with the config from this post, the best way, or the simple way

$ sudo nano /etc/rc.local

And add this line before the exit 0 line:

su -c "screen -dmS homebridge homebridge" -s /bin/sh pi

and then reboot.

There is a nice way to force a special behavior in the Homebridge-Zway plugin using Tags. For example using "Homebridge.Skip" on a device will make it not visible in Your Homekit app. In my case i have a Fibaro device with double switch function but I am just using one. Don't wanting to see the other switch in the HomeKit app I just register "Homebridge.Skip" in the Z-Way UI, se picture

If You also use Telldus Live here is a congfig.json for both plugins. Telldus Live and the Z-Wave together.

Instructions updating the installation is found here



No comments:

Post a Comment