i am trying to add accesrroy in home here is my code
home.addAccessory(accessory, completionHandler: {[weak self]
(error: NSError!) in
let strongSelf = self!
if error != nil{
println("Failed to add the accessory to the home")
println("Error = \(error)")
} else {
println("Successfully added the accessory to the home")
println("Assigning the accessory to the room...")
strongSelf.home.assignAccessory(accessory,
toRoom: strongSelf.room,
completionHandler: {(error: NSError!) in
if error != nil{
println("Failed to assign the accessory to the room")
println("Error = \(error)")
} else {
println("Successfully assigned the accessory to the room")
strongSelf.findServicesForAccessory(accessory)
}
})
}
})
but it show me error
and accessory couldn't be added in home.
println("Failed to add the accessory to the home")
above mention statement does execute. it's not asking for accessory setup code.
What you have explain is not quite helpful in finding the exact reason,I have faced the same error many times and error logs was not sufficient however i fixed it by following steps.
As per my understanding this error only appears on simulator environment as you will run application on real device and test it with the real accessories instead of Home Kit Accessory Simulator this issue may not appear(Not Tested on device Yet).
I hope it may helpful to you.