---
title: "addAndSetupAccessories(completionHandler:)"
framework: HomeKit
role: symbol
role_heading: Instance Method
platforms: [iOS 10.0+, iPadOS 10.0+, Mac Catalyst 10.0+]
path: homekit/hmhome/1771427-addandsetupaccessories
---

# addAndSetupAccessories(completionHandler:)

Finds and adds nearby accessories to the home.

## Declaration

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

```swift
func addAndSetUpAccessories() async throws
```

## Parameters

- `completion`: The block executed after the request is processed.

## 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.

## See Also

### Managing accessories

- [accessories](accessories.md)
- [addAndSetupAccessories(with:completionHandler:)](addandsetupaccessories(with:completionhandler:).md)
- [addAccessory(_:completionHandler:)](addaccessory(_:completionhandler:).md)
- [assignAccessory(_:to:completionHandler:)](assignaccessory(_:to:completionhandler:).md)
- [removeAccessory(_:completionHandler:)](removeaccessory(_:completionhandler:).md)
- [supportsAddingNetworkRouter](supportsaddingnetworkrouter.md)
- [unblockAccessory(_:completionHandler:)](unblockaccessory(_:completionhandler:).md)
- [HMAccessory](../hmaccessory.md)
