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

# addServiceGroup(withName:completionHandler:)

Adds a service group to the home.

## Declaration

```swift
func addServiceGroup(withName serviceGroupName: String, completionHandler completion: @escaping @Sendable (HMServiceGroup?, (any Error)?) -> Void)
```

```swift
func addServiceGroup(named serviceGroupName: String) async throws -> HMServiceGroup
```

## Parameters

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

## See Also

### Grouping services

- [servicesWithTypes(_:)](homekit/hmhome/serviceswithtypes(_:).md)
- [serviceGroups](homekit/hmhome/servicegroups.md)
- [removeServiceGroup(_:completionHandler:)](homekit/hmhome/removeservicegroup(_:completionhandler:).md)
- [HMServiceGroup](homekit/hmservicegroup.md)
