May 21, 2021

HomeKit bridge with Z-Wave


Updated 2021-05-21 !

These devices are available for Apples HomeKit. 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, not battery charged, acts as a messenger; the more devices you have, the more powerful and strong your network is.

Raspberry USB SSD boot made simple ? Check link 

I like the Apple solution where You for example can switch on the light using Siri. So how to combine them ? 

Prerequisites
The software and installation assumes that You have a Z-Wave controller, V3, up and running on a Raspberry Pi(RPi) and have updated your RPi with 

$ sudo apt update && sudo apt full-upgrade -y && sudo apt clean

Install
The fast way
The fastest, 3 minutes ??, and the simplest !! way to be up and running is using the Z-way plugin Apple HomeKit Gate.

The flexible way
The most flexible/more complicated way, with many add ons for other devices than Z-wave, is the Homebridge(HB) application.

Please ! read Remark below !

So after the HB installation go on and install the Hombridge-Zwave plugin via the UX interface and then go to Checking below. 

Doing it manually  go on with command

$ sudo npm install -g homebridge-zway

If its the first plugin in the HB server 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 homebridge


$ homebridge

 and if everything goes right it will show

[2018-8-16 11:41:26] Loaded config.json with 0 accessories and 1 platforms.
[2018-8-16 11:41:26] ---
[2018-8-16 11:41:27] Loaded plugin: homebridge-zway
[2018-8-16 11:41:28] Registering accessory 'homebridge-zway.ZWayServer'
[2018-8-16 11:41:28] Registering platform 'homebridge-zway.ZWayServer'
[2018-8-16 11:41:28] ---
[2018-8-16 11:41:28] Loading 1 platforms...
[2018-8-16 11:41:28] [ZWayServer] Initializing ZWayServer platform...
[2018-8-16 11:41:28] Initializing platform accessory 'Switch (2.0)'...

Setup Payload:
X-HM://0023ISYWYGKAF
Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

Or enter this code with your HomeKit app on your iOS device to pair with Homebridge:

                       
    ┌────────────┐     
    │ 031-45-154 │     
    └────────────┘     
                       
[2018-8-16 11:41:29] Homebridge is running on port 51826.

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

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 several plugins together.

If not using the UX

  • HB autostart at power on and failure, installed with a script !! , is found here.
  • Instructions updating the installation is found here
A post for connecting temperature sensors direct to RPi and show in Homekit.

Remark
The used plugin has not been maintained for a long time and have a memory leak, but it works. I have solutions below... 

Solution 1
Restarting the server once a week with a cron job. In a terminal/ssh session issue the command  

$ crontab -e

and add, at the end

0 2 * * 1 sudo reboot


and the server will reboot every Monday morning at 2 o'clock.

Solution 2
There are many forks but checking and testing I found that this one have no memory leak and have updated dependencies. 

With the HB UX installed, and the ordinary z-way plugin, go to ”Plugins” and on the ”Homebridge Zway” box click on the "wrench" and then "Uninstall", DON’T mark the ”Remove Plugin Config ?”, and then click on "UNINSTALL".


In a terminal/ssh session issue the command 


sudo hb-service stop


which will stop the Homebridge service and then install git


sudo apt install git


Manually install the alternative HB


sudo npm install -g wired/homebridge-zway

and start HB again with 


sudo hb-service start


If you don't have the ordinary z-way installed from the beginning. Install, via git, the "wired" plugin, configure the plugin and then restart the server.

Solution 3
There is a new z-way and updated plugin available. Not tested..... 

13 comments:

  1. Thank you for this tutorial! Worked like a charm, which is not so common in "the z-wave world".

    ReplyDelete
  2. Your tutorials gave me the guts to try RPI :) thanks.

    With the RPI 4 released this was more available in my area than the 3b, as I couldn’t wait I opted for the 4 (4gb).
    The setup went smooth but after reading some more on RPI 4, I understand it gets pretty hot compared to the RPI 3b.
    W
    The Z-wave card also make it (a) more complex due to limiting the free space over the CPU where one would potentially install a fan, (b) even more crowded in the case and (c) occupie the pond where the fan normally goes.

    So.. you seem like a skilled RPI wizard, have I made a mistake when opting for the RPI 4?
    I intend to run Z wave and Homebridge.. I have ~20-30 Zwave nodes. If possible at all I’d like to run my security cameras via the RPI to have them available in HomeKit or any other iPhone app. Either via h.264 /h.265 or in worst case RSTP (??)

    I don’t really like the idea of a fan, I want a quite and cheap solution.

    Should I change and go for the RPI3b while it is still available?
    Is the RPI3b quick enough for my needs?

    Many thanks
    Johan

    ReplyDelete
    Replies
    1. Nice I helped You trying RPi, its a fantastic never ending world ! I’m running RPi 4 on our boat in a plastic box and are using a PWM controlled fan because there are other things that have to bee cooled down. Post https://pysselilivet.blogspot.com/2019/07/node-red-raspberry-control.html In Your case, avoiding a fan, i think the Flirc RPi 4 case will solve the problem. At home I’m using RPi 3 and Homebridge with one Ring camera and the z-wave card without a fan. And just a heads up with the z-way plugin, lately there has been a problem https://github.com/SphtKr/homebridge-zway/issues/140. Restarting the HB server once a week ”solves” the problem, but really hope someone will start updating the plugin again.

      Delete
    2. Thank you for your quick reply :)

      I had a look at the Flirc case at https://m.youtube.com/watch?v=vkLr08K0c1E
      It seems the case make contact with the top of the processor in order to act as a passive cooling.
      This would seem to be a problem when using the z-wave.me IO card as it stretches from the IO pins and over the processor?

      I’ve had the pi 4 running a few days now it since I’m not at home I can’t check any temperatures. Zwave seem to work but it may be close to burning up, not sure, will try to check once home again.
      I use this case; https://www.netonnet.se/art/datorkomponenter/datorchassi/raspberry-pi-4-model-b-slide-case-white/1009088.8955/
      It’s made in plastic but at least has some holes for hot air to escape through.

      The RPI3 you run with HB and a camera, is the performance of the RPI3 enough? Do you have some room for expansion or would you have preferred to run a RPI4?

      Thanks

      Delete
    3. Ooops, yea You are right Flirc won't work. RPi 3 is running very smooth with one camera, but on the other hand I would go for the RPi 4, You never know what the next app will require. One way is to add ventilation holes to the case and mount it vertically with heatsinks on the hot IC:s.

      Delete
    4. scrypted for your cameras... move homebridge into a docker container and put scrypted in one also... bam... :)

      Delete
  3. Thank you very much for this tutorial.
    Do you plan to post a tutorial on adding a zwave usb stick to Homebridge on RPI ? Is it work ? Everspring usb stick is cheaper than razberry.
    Thanks

    ReplyDelete
    Replies
    1. Thanks ! No, sorry, thats not in the plan. If you really want to keep the cost down I wouldn't use z-wave at all. Shelly is a nice alternative, WiFi, so you don't need any gateway. Please check this post https://pysselilivet.blogspot.com/2020/05/homekit-with-shelly.html

      Delete
  4. Hi,

    I am using HomeKit bridge Gate Z-Wave
    6 fibaro double switch 2 fgs-223 connect to my zwave and work perfect.
    I can see the all 6 fibaro double switch 2 on my home kit.
    Only 1 fibaro double switch from the 6, not supported by homekit
    that 1 fibaro double switch work perfect inside zwaveme environment

    any idea ? where is the developer of that HomeKit bridge Gate?

    ReplyDelete
    Replies
    1. Must be a bug. You seems to be active in the z-way forum.... another way could be leaving a comment via the z-way GUI "Online Apps"

      Delete
  5. I already have the raspbee II installed on my raspberry pi, and would like to expand with z wave.
    Meaning the slot on the raspberry pi is already used, so can I just get the uzb instead?

    ReplyDelete
    Replies
    1. I'm not using the UZB, but since it's using a USB port it shouldn't interfere with the IO pins.

      Delete

Feel free to leave a comment ! ... but due to a lot of spam comments I have to moderate them. Will reply ASAP !