Add Accessory to home always returns error(GenericError)

191 Views Asked by At

I am trying to add a accessory to Home(HMHome) and always error block is execute. I am getting GenericError which means An error occurred for which there is no more specific error code. I am not able to understand the reason of this error even documentation does not has the proper reason of it.

And This is happening since last one day, earlier i was able to add the accessory by the same code.

if (self.home != nil ){

self.home!.addAccessory(accessory, completionHandler: ({(error:NSError!) in

   if ( error != nil) {
        //Method which returns error alert according.
        self.handleError(error)
       }

  else{

   let alert:UIAlertController = UIAlertController(title: "HomeKitPOC", message: "Accessory added successfully", preferredStyle: .Alert)
   alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler:{
      (action:UIAlertAction!) in
      self.dismissViewControllerAnimated(true, completion: nil)
      }))
      self.presentViewController(alert, animated: true, completion: nil)
      }
  }))

}

Anybody who has faced the similar problem or have something to suggest.

1

There are 1 best solutions below

0
On

I got the actual root cause of this issue. When I was trying to pairing-up my testing iPhone device with the BLE device. It was not having an active internet connection. Due to this I was getting the mentioned error.

And in order to add an accessory during the paring-up with BLE device, a proper internet connection is much needed.

Once there was the proper internet connection, everything started working fine.