Class

HMAccessory

A home automation accessory, like a garage door opener or a thermostat.

Declaration

class HMAccessory : NSObject

Overview

An HMAccessory instance represents a physical device, like a garage door opener, installed in a home and assigned to a room.

You don’t create accessories directly. Instead you get them from the accessories array of an HMHome instance when you want all the accessories in a home, or the accessories array of an HMRoom instance when you want all the accessories in a particular room. Each physical accessory in the home is represented by exactly one accessory instance, so that one instance appears in both a home and a room collection. This is because it’s simultaneously part of the home and in one of the home’s rooms.

When you want to add new accessories, you call the home’s addAndSetupAccessories(completionHandler:) method. In response, HomeKit presents the user with an interface that steps through the process of searching for new accessories in the physical environment, naming them, and assigning them to a room.

Accessories provide one or more services, represented by instances of HMService, that are the features that the user can control, like the light attached to a garage door opener, or the door opener mechanism itself.

Topics

Tracking Changes to an Accessory

var delegate: HMAccessoryDelegate?

A delegate that receives updates on the state of the accessory.

protocol HMAccessoryDelegate

A set of methods that defines the communication method for state updates from accessories to their delegates.

Identifying an Accessory

var name: String

The name of the accessory.

var uniqueIdentifier: UUID

A unique identifier for the accessory.

var identifier: UUID

A unique identifier for the accessory.

Deprecated

Categorizing an Accessory

var category: HMAccessoryCategory

The category to which the accessory belongs.

class HMAccessoryCategory

A category for a HomeKit accessory.

Locating an Accessory

var room: HMRoom?

The room containing the accessory.

class HMRoom

The smallest subdivision of a home’s space.

Managing Accessory Profiles

var profiles: [HMAccessoryProfile]

An array of profiles implemented by the accessory.

class HMAccessoryProfile

A profile implemented by an accessory.

Managing Camera Profiles

var cameraProfiles: [HMCameraProfile]?

An array of camera profiles implemented by the accessory.

class HMCameraProfile

A camera profile that interacts with an accessory's camera.

class HMCameraView

The view into which a video stream or an image snapshot is rendered.

Getting Accessory State

var isReachable: Bool

A Boolean value indicating whether the accessory can be communicated with in the current network environment.

var isBlocked: Bool

A Boolean value indicating whether the accessory is blocked.

Asking an Accessory to Identify Itself

var supportsIdentify: Bool

A Boolean value that indicates whether the accessory supports the identify action.

func identify(completionHandler: (Error?) -> Void)

Asks an accessory to identify itself.

Controlling Accessory Features

var services: [HMService]

An array of services provided by the accessory.

class HMService

A controllable feature of an accessory, like a light attached to a garage door opener.

Managing Bridged Accessories

var isBridged: Bool

A Boolean that indicates whether the accessory is accessed through a bridge.

var uniqueIdentifiersForBridgedAccessories: [UUID]?

An array of unique identifiers, each of which represents an accessory vended by the bridge.

var identifiersForBridgedAccessories: [UUID]?

An array of identifiers for accessories available through a bridge.

Deprecated

Getting Manufacturer Information

var firmwareVersion: String?

The firmware version of the accessory.

var manufacturer: String?

The manufacturer of the accessory.

var model: String?

The model name of the accessory.

Browsing for Accessories

class HMAccessoryBrowser

A network browser you can use to discover new accessories in a home.

Relationships

Inherits From

Conforms To

See Also

Accessories

Interacting with a Home Automation Network

Find all the automation accessories in the primary home and control their state.

class HMService

A controllable feature of an accessory, like a light attached to a garage door opener.

class HMCharacteristic

A specific characteristic of a service, like the brightness of a dimmable light, or its color temperature.