<!--
{
  "availability" : [
    "iOS: 10.0.0 - 15.4.0",
    "iPadOS: 10.0.0 - 15.4.0"
  ],
  "documentType" : "symbol",
  "framework" : "HomeKit",
  "identifier" : "/documentation/HomeKit/HMHome/addAndSetupAccessories(completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HomeKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HMHome(im)addAndSetupAccessoriesWithCompletionHandler:"
  },
  "title" : "addAndSetupAccessories(completionHandler:)"
}
-->

# addAndSetupAccessories(completionHandler:)

Finds and adds nearby accessories to the home.

```
func addAndSetupAccessories(completionHandler completion: @escaping @Sendable ((any Error)?) -> Void)
```

## Parameters

`completion`

The block executed after the request is processed.

- error: `nil` on success; otherwise, error object indicating the reason for failure.

## Discussion

This method launches an interactive process that first asks the user to provide a HomeKit code for the accessories—for example, by scanning an 8-digit code, by scanning the QR code, wirelessly by holding an iPhone next to the device, or by manually entering the HomeKit code. The process then asks the user to configure the accessory’s services, naming them and placing them in rooms.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)