It seems that every time I restart openhab I have to reset and repair HomeKit. Does anyone else experience this issue? Could there be something wrong with my installation that I can fix to prevent this issue?
Yep, I’m experiencing the same. After restart of openhab i need to do a smarthome:homekit clearPairings and pair again on iOS to get it working again.
How do you restart openHAB? If I remember it right, you have to stop openHAB (using
sudo systemctl stop openhab2.service) to make configuration persistent, because openHAB will store it’s configuration when stopped properly.
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.
You need to do
smarthome:homekit clearPairings and then remove and re-add the openHAB device on your iOS device.
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
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.
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
You can also turn on persistence debugging with log:set DEBUG org.openhab.persistence.mapdb to make sure its writing correctly to mapdb.
default = everyUpdate
// persist all items on every change and restore them from the db at startup
* : strategy = everyChange, restoreOnStartup
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.
@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?