Announcing some improvements to the Homekit plugin for openHAB 2

Ugh yeah, we can move that duplicate subscription to DEBUG level. It happens all the time, and is not a problem. OpenHAB continues to send updates to HomeKit as items change. HomeKit has a very specific way you’re supposed to inform it off changes to what accessories (and characteristics on those accessories) are available, which is difficult to reconcile with the dynamic nature in which OpenHAB adds/removes/reloads items. So for now it uses a big hammer of “if any change happens, disconnect all HomeKit clients, and then let them figure it out when they reconnect”. I’m hopeful that if/when we stop disconnecting from HomeKit all the time, the duplicate subscriptions will go away. In the meantime, they’re just noise in the log, and can be ignored (and moved to DEBUG level).

1 Like

Now you have to help me. I tried to install homekit, that works fine and I see all items tagged with “Lighting” as homekit devices in the openhab-log. If I use the Home app on the iPhone I can search for devices near me and see “OpenHAB” and it asks me for the PIN. I can enter that but then - nothing happens. There is nothing in the OH log and no devices show up in my Home app. Any idea?

Which Pin do you use? As far as I remember, that could cause a problem.

Funny. After restarting OH without changing anything else and re-pairing it worked.

@ccutrer: I have used SecuritySystem from your private fork together with OH version 2.4.0. I do get some error messages in the log most likely due to the dependencies you mentioned. However, it still works very fine. Thanks a lot for this contribution.

This has been merged today and should be available in the next snapshot

1 Like

Hi, concerning item placement in rooms of Apples home app
Is there a way to specify or tag a room in the item file where we define homekit times?
It would be very helpful to have that feature for many reasons

I would really appreciate to have this, too. Unfortunately my TODO list is quite long, this is on it, but not near top at the moment. It may be possible that this required extensions to the underlying library.

What features/enhancements are on your todo list and is there some kind of status tracker what you implement and how far you are?

No, there is no fixed list. I have https://github.com/openhab/openhab2-addons/pull/5503 on top, including some bug fixes, I’ll help with https://github.com/openhab/openhab2-addons/pull/5677, I need a Fritzbox TR064 binding for OH2, and something else. If I find time in between, I’ll have a look at null annotations for homekit (and probably HAP-Java) and if all of that is working new features for homekit. List subject to change.

@crxporter, @J-N-K, @Tim_Harper, @steilerDev

I have done some testing with the dimmer and strobe challenge with the lights moving up and down when the level is changed in the Homekit app.

The strobe is a problem with the current implementation of Homekit addon in openHAB as mentioned in this thread.
The strobe is NOT a problem for the same dimmers with Homebridge.io using openhab complete - see link

Most likely it is not a problem with any dimmer binding in openhab. Instead, I guess functionality similar to Homebridge / openhab complete needs to be implemented in the homekit addon. And sorry, I do not have the talent to do this.

@ccutrer @EjvindHald
This is an issue I solved in my implementation (homebridge-openhab2-complete). The way I implemented (and feel free to use the same idea) is to wait a couple of mseconds (I am using 125ms) (See this).

In homebridge I add setState and commitState to every .on('set', ...) call of the characteristic, where commitState checks for a lock, returns if the lock is locked or waits 125ms and setState sets the respective characteristic (binary, hue, saturation or brightness) in a data structure. After the 125ms timeout of commitState the function will check the data structure and decide on the appropriate command for openHAB (See _commitFunction for lights here).

I hope this was helpful :slight_smile:

2 Likes

Great work with this.
Will there be support for GarageDoorOpener, TelevisionMediaPlayer or MediaPlayer in the future?
Thanks

2 Likes

I’m VERY new to OpenHAB2. I started exploring OpenHAB2 and Homebridge.IO because I have an existing Home Tech infrastructure that I couldn’t justify abandoning. My lighting is UPB and my "alarm (slash, existing automation system) is HAI/Leviton OmniPro2. All I really needed was something that would expose all the HAI elements to Homekit (since the lighting is already in there). I thought about going UPB Direct in OpenHAB2, but there are some automation elements still within the Omni I haven’t learned how to duplicate yet on OpenHAB2 so I really just wanted to leave them, besides motion-based lights may respond quicker if I leave them on the system that’s aware of everything (the Omni).

Your plugin appears to be exactly what I’ve been looking for to act as a Homekit bridge for the Omni Lighting and Omni Security, but I’m having a heck of a time even getting it functional. I can get it to broadcast on the network for initial pairing, but after I try to pair, it seems to die, the phone ultimately saying it can’t pair with the accessory and in order to get it to broadcast again, I have to restart the OpenHAB2 service (sometimes also clear pairings). I’m also having a hard time understanding the tags and how/where to place them. I was going to load the latest release of the Homekit plugin, but also have no idea how to upgrade it from the CLI (since the version I got - 2.4.0 - was from the plugin store).

Could someone provide some guidance on how to upgrade to the latest version? Could someone also tell me how those tags work?

Thanks.

Yes, setting it up is a bit hard. And i don’t think you would see anything usefull in the logs when the tagging is set wrong.
Are you using tekst based config ? If so, i would suggest to remove all placed tags and just tag one item say a switchable light:

//["Switchable"] is the actual tag
Switch	light-item "Light"    <light>	(_lightsGroup)	["Switchable"]

If you have this setup, clear any existing pairings. Restart openHAB. Start pair and watch it work (or not)
If that doesn’t work, verify the Phone and the host running openHAB are on the same network/subnet and no firewall is blocking. if possible set the binding in debug mode and do it over again.

If not allready done, please check HomeKit Add-on - System Integrations | openHAB

I just re-read your post, you are on 2.4.0. A lot of work has been done to the homekit plugin afterwards, i suggest you to upgrade to 2.5.0 M2. How to upgrade depends on your host os, more details: Installation Overview | openHAB

I don’t believe I’m using a text based config - I haven’t manipulated any text files, except during troubleshooting. I wasn’t finding where to add the tags to items (PaperUI doesn’t seem to have a field), so I loaded HABMin, which seems to offer a tag field, but I’ve had some issues with my Omni module (can no longer find the v2 one), so it doesn’t let me save my edit to a test light source (comes back with “Error saving Light Level - Undefined”. So now I can’t add the tag “Lighting” to the switch. Sigh.

Oh, and this is OpenHABian. Image written last week. Sure enough, it says 2.4.0-1 but when I run the OpenHABian-config tool and tell it to upgrade all modules to latest, it basically says everything already is (as it runs through the script). Didn’t find at that link how to upgrade to 2.5.0M2. Ah, just found it in the config tool “latest milestone testing version”. Unfortunately, that version likes to crash a few seconds after it starts each time so I’m going to have to roll it back:

Aug 18 14:22:42 openhab systemd[1]: Started openHAB 2 - empowering the smart home.
[14:22:45] openhabian@openhab:~$ sudo service openhab2 status
● openhab2.service - openHAB 2 - empowering the smart home
   Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Sun 2019-08-18 14:22:57 EDT; 1s ago
     Docs: https://www.openhab.org/docs/
           https://community.openhab.org
  Process: 2050 ExecStart=/usr/share/openhab2/runtime/bin/karaf ${OPENHAB_STARTMODE} (code=exited, status=255/EXCEPTION)
 Main PID: 2050 (code=exited, status=255/EXCEPTION)

And now rolling back to 2.4.0 didn’t help (Does the same crashing thing), so I’ve moved it back to 2.5 since it’s dead anyway. Maybe it can be resurrected.

Seems to be where it’s failing, but could be wrong:

   CGroup: /system.slice/openhab2.service
           ├─13323 /bin/sh /usr/share/openhab2/runtime/bin/karaf daemon
           ├─13344 /bin/sh /usr/share/openhab2/runtime/bin/karaf daemon
           ├─13345 /bin/sh /usr/share/openhab2/runtime/bin/karaf daemon
           ├─13346 /bin/sh /usr/share/openhab2/runtime/bin/karaf daemon
           └─13353 expr /opt/jdk/zulu8.40.0.178-ca-jdk1.8.0_222-linux_aarch32hf/bin/java : /.*

Phone and HAB are on the same VLAN, so Firewall is irrelevant. :frowning:

When you browse to the root http://hostname:8080/ you can select the UI you want to use. On that same screen you would see the openHAB build number at the bottom.

If you look in openhab.log you should see the reason of the crash.

Web server isn’t responding - no GUI accessible, even at root. Here’s the last batch of entries in the log…

2019-08-18 15:34:47.176 [SEVERE] [org.apache.karaf.main.Main] - Could not launch framework
java.lang.RuntimeException: Error initializing storage.
	at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:70)
	at org.eclipse.osgi.launch.Equinox.<init>(Equinox.java:31)
	at org.eclipse.osgi.launch.EquinoxFactory.newFramework(EquinoxFactory.java:24)
	at org.apache.karaf.main.Main.launch(Main.java:256)
	at org.apache.karaf.main.Main.main(Main.java:178)
Caused by: java.io.IOException: Unable to create lock manager.
	at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:698)
	at org.eclipse.osgi.storage.Storage.getChildStorageManager(Storage.java:1776)
	at org.eclipse.osgi.storage.Storage.getInfoInputStream(Storage.java:1793)
	at org.eclipse.osgi.storage.Storage.<init>(Storage.java:132)
	at org.eclipse.osgi.storage.Storage.createStorage(Storage.java:85)
	at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:68)
	... 4 more

Something wrong with the write permissions i think because of:
java.io.IOException: Unable to create lock manager.

If you just started and there is nothing that needs to be saved, i think it is better to get a fresh install of openhabian from here: Download openHAB | openHAB

Another possiblitiy is to check and fix the write permissions, but that might get complicated and who knows what went wrong because this should never happen with a openhabian installation. Anywat, this has nothing to do with the homekit binding, so if it remains an issue, i woudl suggest to open another topic.

Did you also include the SecuritySystem made by @ccutrer in the merge? - I have used the SecuritySystem now for 3 months, and it works great. More info here, where he also provides updated guides and examples.