A service provided by an accessory.


class HMService : NSObject


A single accessory may provide multiple services. Services have characteristics that can be queried to discover their state or modified to cause the accessory to modify its behavior.


Managing Services

var name: String

The name of the service.

func updateName(String, completionHandler: (Error?) -> Void)

Updates the name of the service to the specified string.

var accessory: HMAccessory?

The accessory that provides this service.

var serviceType: String

The type of the service.

var associatedServiceType: String?

The type of the service associated with an outlet or a switch.

func updateAssociatedServiceType(String?, completionHandler: (Error?) -> Void)

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

var characteristics: [HMCharacteristic]

An array of characteristics for the service.

var isPrimaryService: Bool

A Boolean value that indicates if this service is the primary service on the accessory.

var linkedServices: [HMService]?

An array of service objects that represents all the services to which the service links.

var localizedDescription: String

The localized description of the service.

var uniqueIdentifier: UUID

A unique identifier for the service.

var isUserInteractive: Bool

A Boolean value that indicates if this service supports user interaction.


Accessory Service Types

These constants define the service types supported by the HomeKit Accessory Profile.


Inherits From

Conforms To

See Also

Service and Characteristic Setup

class HMServiceGroup

A collection of accessory services.

class HMCharacteristic

A specific characteristic of a service—for example, if a light is on or off, or to what temperature a thermostat is set.

class HMCharacteristicMetadata

Metadata that further specifies a characteristic’s value and that may be useful for presentation purposes.