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.
Is there any delegate method called when an accessory is unpaired?
Is there a way to test if previously discovered accessories are currently paired? I'm looking for something specifically related to pairing - the
isReachableproperty is too generic.Is there a way to repair the accessory? After calling the
addAccessorymethod on the home, I receive an error since the accessory is already in the home - just not paired with the device.
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.