<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 8.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HomeKit",
  "identifier" : "/documentation/HomeKit/HMService/updateAssociatedServiceType(_:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HomeKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HMService(im)updateAssociatedServiceType:completionHandler:"
  },
  "title" : "updateAssociatedServiceType(_:completionHandler:)"
}
-->

# updateAssociatedServiceType(_:completionHandler:)

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

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

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

- error: `nil` on success; otherwise, error object indicating the reason for failure.

## Discussion

This method is only valid for services of type [`HMServiceTypeOutlet`](/documentation/HomeKit/HMServiceTypeOutlet) or [`HMServiceTypeSwitch`](/documentation/HomeKit/HMServiceTypeSwitch). See [`associatedServiceType`](/documentation/HomeKit/HMService/associatedServiceType) for details of associated service types.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)