Need to reset HomeKit pairing at every launch

It uses the configured ESH persistence service to store the values. Out of the box, OH uses mapdb, which seems to work well. The changes are committed to disk immediately. Are you using an alternative persistence service?

@rrgeorge How do you go about resetting and repairing Homekit? Is it via OSGI or another way? This may appear a dumb qestion but ive trawled the internet for answers and cannot find a clear solution! Essentially, i have homekit installed on OpenHab2 that no longer responds and i need to start over.

Thanks
AV

You need to do smarthome:homekit clearPairings and then remove and re-add the openHAB device on your iOS device.

2 Likes

Could you provide step-by-step instructions to issue smarthome:homekit clearPairings command to Openhab? I tried this in the Terminal but get -bash: smarthome:homekit: command not found

Sorry, you need to do it from the osgi console.
ssh -p8101 openhab@localhost (Password is habopen)

Clearing pairings shouldn’t be necessary unless you’re using a new iCloud account or you reset HomeKit from your phone. Are you both seeing the same error message that @sbrandon reported in Testing HomeKit add-on on OpenHAB 2
?

@beowulfe I believe so. If you are referring to this one:
2016-09-20 21:00:54.416 [WARN ] [nhab.io.homekit.internal.HomekitImpl] - Could not find existing MAC in org.eclipse.smarthome.storage.mapdb.MapDbStorage. Generating new MAC. This will require re-pairing of iOS devices.

I was able to fix this by adding the mapdb persistence binding and uninstalling homekit and adding it back. For some reason, this is NOT installed out of the box. I also had to create the mapdb.persist file in the conf/persistence folder and add default=mapdb. Everything is working great now. No more clearing binding when i reboot. @beowulfe, thanks for your great work on this.

1 Like

Oh wow, I thought that was always there out of the box. I wonder if something changed… I’ll update the docs and see if I can detect the missing persistence at runtime.

I have mapdb installed, and a mapdb.persist file, but it still does not work. @sbrandon could you post your mapdb.persist file? Also, where do you add default=mapdb?

You can also turn on persistence debugging with log:set DEBUG org.openhab.persistence.mapdb to make sure its writing correctly to mapdb.

/opt/openhab/conf/persistence/mapdb.persist

Strategies {
default = everyUpdate
}

Items {
// persist all items on every change and restore them from the db at startup
* : strategy = everyChange, restoreOnStartup
}

default=mapdb

Apparently thats all I needed. I added default=mapdb to the end of my mapdb.persist, and now HomeKit appears to continue to work after restarting openHAB multiple times.
Thank you @sbrandon and @beowulfe!

Awesome! That two weeks of doing nothing but this in my spare time has now paid off. Thanks again @beowulfe.

1 Like

@Kai - I see a lot of talk in ESH about changes to persistence, but I can’t figure it out. When you’re back in town, can you help identify what I need to change? HomekitAuthInfoImpl uses an ESH storage object to save the authentication info. I just tried with the latest snapshot, and I had to make the same changes to mapdb.persist that @sbrandon mentioned above.

I do not really understand this thread. “Persistence services” as configured through .persist files are something different than the “Storage” interface in ESH, which you use in HomekitAuthInfoImpl. A .persist file should therefore definitely not be needed and the mapdb bundles are installed by default…

I’ll try to trace it through then. Adding the .persist file definitely resolves issue.

I did as @sbrandon steps (install mapdb and reinstall homekit) and created the mapdb.persist file with the exactly code, but I still get the following error which means that every time I restart OH2 the pairing is lost.

[WARN ] [nhab.io.homekit.internal.HomekitImpl] - Could not find existing MAC in org.eclipse.smarthome.storage.mapdb.MapDbStorage. Generating new MAC. This will require re-pairing of iOS devices.

One thing I notice is that all the values for the homekit items now are stored, so the next pairing the values are still there, but it didn’t stop from having to pair again.

Why my MAC is not storing and the items data yes? What I am doing wrong?

I might found the problem. Let me explain the situation:

I have an iphone and an Ipad and with the new iOS10 icloud has added a Homekit button in which apparently you can share the homekit devices trough out all your devices. There is another option which is to use an apple TV or Ipad as a hub when you are outside your home LAN.

IIn my case, the pairing is done with one device (Iphone) and in the Ipad you can also see all devices paired with the iPhone and manipulate the items from both devices, but when you get out of the APP, it stops working and the MAC error message comes up.

I belive that at some point we are not using the Iphone to send the orders and therfore the iphone MAC which is the device that I used to do the pairing and is an icloud service the one that sends the orders instead. That is why OH doesn’t recognize the device as paired.

I tried to disable the icloud service and now my iphone works ok, but I can only use Homekit in 1 device, and if I am out of home I can’t control it.

Does it happen to you too?

When you use multiple iOS devices tied to the same iCloud account, they all share the same authentication code. Same thing for users you invite to the Home. We have two iPhones, three iPads, and an AppleTV all connected without issue.

The specific log line you included would only show up during initialization of the bundle.

This is the log when “Home APP” is not able to syncronize the items correctly.

2016-09-23 16:40:20.930 [TRACE] [pl.http.impl.NettyHomekitHttpService] - READ UnpooledUnsafeDirectByteBuf(ridx: 0, widx: 49, cap: 384) [/192.168.1.104:55943]:
00000000 E5 8B 16 8B 0D A1 0A 29 B7 DB EF 10 46 E6 61 0B .......)....F.a.
00000010 8F D6 6A C2 E2 0A EC 59 F7 86 47 AA D7 F2 39 7C ..j....Y..G...9|
00000020 76 CC D4 9C B1 6D E7 7F BA 78 45 F0 64 EE DA B9 v....m...xE.d...
00000030 4F                                              O


2016-09-23 16:40:20.931 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Received message of length 49. Existing buffer is 0
2016-09-23 16:40:20.932 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Attempting to read message of length 35831
2016-09-23 16:40:20.932 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Not enough data available
2016-09-23 16:40:20.933 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Remaining data available
2016-09-23 16:40:20.934 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Performing step operation on buffer of length 49 with pos 0
2016-09-23 16:40:20.934 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - targetLength is 35829
2016-09-23 16:40:20.935 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Storing 47 bytes in buffer until we receive the complete 35829
2016-09-23 16:40:20.935 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Returning 0 results