Josh Gafni
Josh Gafni

Reputation: 2881

Re-Pair HomeKit Accessory

There is an unpair button in the HomeKit Accessory Simulator. When you unpair an accessory, it seems that the accessory stays in your HomeKit database in the home that it was previously assigned. I would like to add a process to either remove the accessory from the database, or re-pair the accessory.

  1. Is there any delegate method called when an accessory is unpaired?

  2. Is there a way to test if previously discovered accessories are currently paired? I'm looking for something specifically related to pairing - the isReachable property is too generic.

  3. Is there a way to repair the accessory? After calling the addAccessory method on the home, I receive an error since the accessory is already in the home - just not paired with the device.

Upvotes: 0

Views: 1190

Answers (2)

Adam Shiemke
Adam Shiemke

Reputation: 3742

Unpairing the accessory from the simulator just removes the pairing relationship in the simulator, not from the homekit database. From HMCatalog, you can remove the accessory by swiping on the accessory in the home view and pressing the delete button.

There isn't a way for homekit to detect if the accessory has ended it's pairing relationship. When you unpair in the simulator that way, it clears the simulator's keys for that accessory but doesn't tell homekit. As far as homekit can tell, that accessory just isn't visible anymore (i.e. unreachable).

To remove the accessory, you need to call the removeAccessory method on HMHome from your app. This will both remove the accessory from the home and notify the accessory to remove the pairing relationship with the device. From there, you should be able to add the accessory again.

Upvotes: 1

Dario Fiumicello
Dario Fiumicello

Reputation: 768

I actually don't know how to remove a single accessory from a home, neither the sample HMCatalog app from Apple seems to be able to do this.

Anyway, you can always clean the whole HomeKit database from your iPhone by going into Settings->Privacy->HomeKit and tapping "Initialize config data. HomeKit...". Then you have to recreate the home and pair the accessory again.

HTH

Upvotes: 1

Related Questions