Need to reset HomeKit pairing at every launch

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) [/]:
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

That log doesn’t tell me much, but it’s probably irrelevant. If you’re seeing the message that the MAC had to be recreated, it explains why you’re losing the pairing. As far as why it’s not persisting… I don’t have any ideas.

The MAC message doesn’t appear anymore. The problem now is that if I exit the APP and enter again all Items don’t respond (keep updating) and this is the Log. Is estrange because if I enter the APP after 5 min, then is ok.

I got exactly the same problem as you. A few minutes after connecting it seems like my iPhone loses connection to the homekit. All of the devices won’t respond anymore and the only way to fix it is by re-pairing. I’m Using Openhab2, Homekit Integration, and an iPhone and iPad both at iOS 10. Openhab and Homekit are both running on a Raspberry pi 3.

Can one of you attach a longer log file? Looking at the snippet above, it does seem unlikely that iOS is trying to send a 36k message.

For me the following sequence worked to keep my pairing:

  1. Clear the existing pairing if one already exists.

  2. Restart openHab, this will log Could not find existing MAC...

  3. Do not pair yet but instead restart again. After the second restart the message does not appear again.

  4. Then pair. After a third restart the pairing still functions.


Thanks this thread has been helpful in resolving many of common issues pairing with OH2 with HK plugin.

I have one question though

After installing mapdb and following @richard1 steps, I no longer experience the need to repair with the HK addon ay every OH reboot. However I’m seeing following issue in my openhab.log. Any idea what could be wrong?

==> /var/log/openhab2/openhab.log <==
2016-11-09 22:31:56.809 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'ut': cannot invoke method public abstract org.eclipse.smarthome.core.types.State org.eclipse.smarthome.core.persistence.HistoricItem.getState() on null

Hi there
seems to be a quite old threat, but i experience the same issue of the “repair need” only since i installed openhab “final” 2.0. i did not had the issue with beta 4 (i guess that was the previous version before final).
@beowulfe Is it still a known bug in the final version?
EDIT: I thought i had installed the latest version but i had RC1 installed. I was on the unstable apt library. Made a clean install of the latest version on the stable package and everything works fine.

I am still having trouble keeping HomeKit working with openhab2. Is the mapdb persist hack still needed to make this work?

The mapdb hack was actually a coincidence, and actually didn’t do anything. The problem stems from a race condition in HomeKit. The steps to get it to work consistently are as follows:

  1. Log into karaf console and run smarthome:homekit clearPairings
  2. Restart openHab
  3. Check logs for [WARN ] [] - Could not find existing MAC in Generating new MAC. This will require re-pairing of iOS devices.
  4. Restart openHab again.
  5. Make sure you do not see the “Could not find existing MAC” message in the logs. If you do, start over.
  6. Repair your iOS device.
  7. Restart openHab to ensure it stuck.

Still having the same problem and the WARN Message is always there:

017-05-05 12:43:50.976 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'default.sitemap' has errors, therefore ignoring it: [7,1]: missing EOF at '{'

Welcome, You should start a new thread for questions not related to what is being discussed in this thread. You have a syntax error in your sitemap file, if you are editing it in the Eclipse Smart Home designer app it should give you a more detailed description of the error.

do i need a sitemap if i only would like to use the homekit and not the UI?

oh and i just realized i copyed the wrong WARN

[WARN ] [homekit.internal.HomekitAuthInfoImpl] - Could not find existing MAC in Generating new MAC. This will require re-pairing of iOS devices.

I think its now working, finally the warning was gone after several time trying. :slight_smile:

Andy, in web address you are mentioning window coverings, for me namely the rollershutters. However i couldn’t find that information in openhab2 distro snapshots. Are these already included in the distro binding, or the binding in your git page is different? Thanks

I have tried your method, but I do not seem to succeed.
And now iOS 11.2.5 (beta 7) seems to break it completely.

Hi there,
Any news on this? This tread is quite old bus still same problems in 2020. after reboot OH2 need to pair the device again!