Here is a brief description of how to setup other types in Homekit and link them to Openhab. It’s not exhaustive and there are probably more elegant ways but it works, something a lot of OH users have been asking for. So hopefully it’s a starting point for those.
It assumes you have node red running. For those using Openhabian from @ThomDietrich it’s easy, the openhabian install script takes care of the node red installation (it’s one of the optional components), for all others there are a lot of node red topics on the forum.
Now we have node red follow below
Step 1 : Install the homekit node https://www.npmjs.com/package/node-red-contrib-homekit .
Do sudo apt-get install libavahi-compat-libdnssd-dev
afterwards you can just install the homekit node as described or from the node red UI (At the right top corner of the node red UI there are 3 bars, click them and select manage palette. Search for the homekit node and install)
You now have a homekit node under the advanced section on the left.
Step 2: Add a homekit node and configuring it. (i.e. select the type of accessory, enter the pin, select the service which matches the acessory and give it a name).
Don’t forget to deploy.
Step 3: Add accessory in the home app. On your IOS device add accessory, you should see the accessory appear and can add it in the same way you added the openhab bridge by manually entering the PIN you configured in node red.
Step 4: link the openhab item to the accessory. This is merely a matter of conversion. Node red has an incredible debug window, this will help and below as an example the configuration for the window and the fan from the video.
The switch node detects an ON or OFF and switches based on this
The change node sends the payload in the correct homekit node format below the format for fan on. The fan off one is the same but with payload {“On”:0}
This will make the Home app fan change when the OH items changes.
Now we need to do the same from the Home accessory to OH (the righ hand side of the Homekit node).
The first node is a edit template node. configure it like this
The switch node evaluates the output true of false
And the edit change nodes convert it to an openhab ON OFF
which feeds into the OH item.
The window example is similar but since you don’t change the window in the Home app it only has a left hand side.
The switch node is configured as follows
every switch output has 2 edit change nodes, one for currentposition and one for targetposition. Below the ones for Window open. The window closed ones are the same but with 0 instead of 100 as a value.
I’m sure the conversions can be done in OH as well and probably more elegantly.
Any other type in Homekit is similar it’s just a mater of converting into the right JSON format.
To find out use the debug window and send {“foo”:“bar”} into the homekit node as suggested in the info field the debug window will show you all the variable that are appropriate for the accessory you want to add.