---
title: "addAction(_:completionHandler:)"
framework: homekit
role: symbol
role_heading: Instance Method
path: "homekit/hmactionset/addaction(_:completionhandler:)"
---

# addAction(_:completionHandler:)

Adds an action to the action set.

## Declaration

```swift
func addAction(_ action: HMAction, completionHandler completion: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
func addAction(_ action: HMAction) async throws
```

## Parameters

- `action`: The action to add. Actions may only be in one set—create separate doc://com.apple.homekit/documentation/HomeKit/HMAction objects for the same conceptual action if you want an action to be in more than one action set.
- `completion`: The block executed after the request is processed.

## See Also

### Defining the associated actions

- [actions](homekit/hmactionset/actions.md)
- [removeAction(_:completionHandler:)](homekit/hmactionset/removeaction(_:completionhandler:).md)
- [HMCharacteristicWriteAction](homekit/hmcharacteristicwriteaction.md)
- [HMAction](homekit/hmaction.md)
