[homekit] Need to do clearPairing at each reboot if clearPairing is not immediately followed by restart
See original GitHub issueOn latest OpenHab2 release (stable), Homekit is not working properly.
At each restart I get the following message:
[WARN ] [nhab.io.homekit.internal.HomekitImpl] - Could not find existing MAC in org.eclipse.smarthome.storage.json.JsonStorage. Generating new MAC. This will require re-pairing of iOS devices.
It seems that it comes from JsonStorage that does not store the MAC address.
To check this, here is what I did:
Step 1 After a clearPairing, I get this :
{}
Step 2 Upon exit, the /var/lib/openhab2/jsondb/homekit.json file contains:
{
"user_46:93:cd:2f:84:bCA88FE36-F8C2-412E-BEF2-7BAA64340E71": {
"class": "java.lang.String",
"value": "BlsF/k40f6cx7gkiX9Yndc5+M3jOzbycU08jXkSs/O8\u003d"
},
"user_46:93:cd:2f:84:bE6101B5F-86A2-4823-BF27-E417D56B0DA3": {
"class": "java.lang.String",
"value": "MkMKYuDnEDg6YeoB7CDKRrmVuSsYkPsXnlVBn1s+xkM\u003d"
}
}
As you can see, no MAC address is stored there.
Step 3 After restart (and so after the message “Could not find existing MAC…” is raised) the file contains this:
...
"mac": {
"class": "java.lang.String",
"value": "5e:54:18:f0:bb:95"
}
}
So there is a problem with Homekit JsonStorage since it does not store MAC just after pairing.
When restarting, I get the following error in log:tail
16:55:53.743 [ERROR] [.eclipse.smarthome.model.persistence] - [org.eclipse.smarthome.model.persistence.manager(104)] The unsetModelRepository method has thrown an exception
java.lang.NullPointerException
at org.eclipse.smarthome.model.persistence.internal.PersistenceModelManager.unsetModelRepository(PersistenceModelManager.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_121]
at org.apache.felix.scr.impl.inject.BaseMethod.invokeMethod(BaseMethod.java:224)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.inject.BaseMethod.access$500(BaseMethod.java:39)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke(BaseMethod.java:617)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.inject.BaseMethod$NotResolved.invoke(BaseMethod.java:576)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.inject.BaseMethod.invoke(BaseMethod.java:501)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.inject.BindMethod.invoke(BindMethod.java:655)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.DependencyManager.invokeUnbindMethod(DependencyManager.java:1837)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.DependencyManager.close(DependencyManager.java:1600)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.SingleComponentManager.disposeImplementationObject(SingleComponentManager.java:352)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.SingleComponentManager.deleteComponent(SingleComponentManager.java:152)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.doDeactivate(AbstractComponentManager.java:813)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.deactivateInternal(AbstractComponentManager.java:787)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.dispose(AbstractComponentManager.java:579)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.disposeComponents(ConfigurableComponentHolder.java:706)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.BundleComponentActivator.dispose(BundleComponentActivator.java:523)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.Activator.disposeComponents(Activator.java:452)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.Activator.access$300(Activator.java:54)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.Activator$ScrExtension.destroy(Activator.java:306)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.utils.extender.AbstractExtender$2.run(AbstractExtender.java:290)[32:org.apache.felix.scr:2.0.6]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_121]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_121]
at org.apache.felix.utils.extender.AbstractExtender.destroyExtension(AbstractExtender.java:312)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.utils.extender.AbstractExtender.bundleChanged(AbstractExtender.java:186)[32:org.apache.felix.scr:2.0.6]
at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:902)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:165)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:75)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:67)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:102)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.container.Module.publishEvent(Module.java:466)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.container.Module.doStop(Module.java:624)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.container.Module.stop(Module.java:488)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.decStartLevel(ModuleContainer.java:1623)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1542)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.container.SystemModule.stopWorker(SystemModule.java:248)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule.stopWorker(EquinoxBundle.java:144)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.container.Module.doStop(Module.java:626)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.container.Module.stop(Module.java:488)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:186)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule$1.run(EquinoxBundle.java:159)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
As described into this thread I installed mapdb and then re-installed homekit.
I also added /etc/openhab2/mapdb.persist
as described here with the default=mapdb instruction.
However, nothing works until I do the following:
- From openhab console :
smarthome:homekit clearPairings - Restart openhab2 (without pairing)
- Pair HomeKit items
Then the MAC address is correctly saved (the restart makes the MAC address properly stored into homekit.json file)
Pairing then will not do the Generating new MAC upon restart so it will be OK (yet, the NullPointerException is still there)
This current behaviour is a bug: the Homekit Pairing should automatically add it to the homekit.json file.
@beowulfe this topic has already be addressed in a community forum, but I open a bug to keep a full trace of it 😃
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:15 (2 by maintainers)

Top Related StackOverflow Question
I had the same issue on 2.0 release. Turnes out that after enabling the homekit integration, you have to restart openhab to get the JSON persistance to write the mac address. Only after that, you should do the pairing. Steps I took:
Closing as current master shares only very little code parts with 2.1.0