Instance Method

assignAccessory(_:to:completionHandler:)

Assigns an accessory to a different room.

Declaration

func assignAccessory(_ accessory: HMAccessory, to room: HMRoom, completionHandler completion: @escaping (Error?) -> Void)

Parameters

accessory

The accessory to assign; must already have been added to the home.

room

The room to which the accessory will be assigned; must already exist in the home.

completion

The block executed after the request is processed.

error

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

See Also

Managing Accessories

var accessories: [HMAccessory]

The collection of accessories that are part of the home.

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

Finds and adds nearby accessories to the home.

func addAndSetupAccessories(with: HMAccessorySetupPayload, completionHandler: ([HMAccessory]?, Error?) -> Void)

Finds and adds nearby accessories to the home using a HomeKit code provided by your app.

class HMAccessory

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