---
title: "addRoom(withName:completionHandler:)"
framework: homekit
role: symbol
role_heading: Instance Method
path: "homekit/hmhome/addroom(withname:completionhandler:)"
---

# addRoom(withName:completionHandler:)

Creates a new room with the specified name.

## Declaration

```swift
func addRoom(withName roomName: String, completionHandler completion: @escaping @Sendable (HMRoom?, (any Error)?) -> Void)
```

```swift
func addRoom(named roomName: String) async throws -> HMRoom
```

## Parameters

- `roomName`: The name of the new room. Must not be nil, and must not be the name of a room already in the home.
- `completion`: The block executed after the request is processed.

## See Also

### Dividing a house into rooms

- [rooms](homekit/hmhome/rooms.md)
- [roomForEntireHome()](homekit/hmhome/roomforentirehome().md)
- [removeRoom(_:completionHandler:)](homekit/hmhome/removeroom(_:completionhandler:).md)
- [HMRoom](homekit/hmroom.md)
