question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[homekit] Need to do clearPairing at each reboot if clearPairing is not immediately followed by restart

See original GitHub issue

On 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:

  1. From openhab console : smarthome:homekit clearPairings
  2. Restart openhab2 (without pairing)
  3. 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:closed
  • Created 7 years ago
  • Reactions:7
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
serhatozkaracommented, Apr 27, 2017

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:

  1. Delete pairing from the IOS home app
  2. Uninstall Homekit Integration
  3. Delete /var/lib/openhab/jsondb/homekit.json
  4. Install homekit integration addon and configure
  5. Restart openhab and check to see if /var/lib/openhab/jsondb/homekit.json has the mac address entry.
  6. Pair on IOS
  7. Profit!
0reactions
J-N-Kcommented, Aug 4, 2019

Closing as current master shares only very little code parts with 2.1.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rebooting router to fix Homekit "No response"
I use the Apple TV and the HomePod mini as the HomeKit Hub and ... Do all of the devices periodically show "no...
Read more >
[SOLVED] HomeKit Integration - Pairing Problems (iOS 10
Hi Guys, i installed with Paper UI: Add-ons/Misc/HomeKit Integration 2.1.0 and this is my configuration: on my iPhone (Home.app) i can see ...
Read more >
Controlled Reboots - HomeKit Helper
When rebooting your system, it is best practice to do a controlled reboot. That is, reboot your system in an order of device...
Read more >
HomeKit Controller - Home Assistant
If your device is currently paired with an Apple device via HomeKit, you will need to reset it in order to pair it...
Read more >
HomeKit-enabled routers Frequently Asked Questions - Linksys
If you reset your Linksys Tri-band network, you will need to go through connecting your Linksys to the Apple Home app. 9. How...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found