---
title: "updateAssociatedServiceType(_:completionHandler:)"
framework: homekit
role: symbol
role_heading: Instance Method
path: "homekit/hmservice/updateassociatedservicetype(_:completionhandler:)"
---

# updateAssociatedServiceType(_:completionHandler:)

Associates the service type of the plugged-in device with a switch or an outlet service.

## Declaration

```swift
func updateAssociatedServiceType(_ serviceType: String?, completionHandler completion: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
func updateAssociatedServiceType(_ serviceType: String?) async throws
```

## Parameters

- `serviceType`: The service type of the device that is hooked up to the switch or outlet.
- `completion`: The block executed after the request is processed.

## Discussion

Discussion This method is only valid for services of type HMServiceTypeOutlet or HMServiceTypeSwitch. See associatedServiceType for details of associated service types.

## See Also

### Associating a secondary service

- [associatedServiceType](homekit/hmservice/associatedservicetype.md)
