Class

HMHome

A home and its accessories.

Overview

Homes are the central organizing object for HomeKit. Homes have three main purposes:

  • Organize accessories into a number of rooms, which are themselves optionally grouped into zones.

  • Serve as the main access point for communicating with and configuring accessories.

  • Allow the user to define sets of actions that can be performed with a single operation, and triggers that can cause an action set to be performed at a specific time.

You don’t create homes directly—instead, you create them with the addHome(withName:completionHandler:) method of HMHomeManager.

Topics

Information About the Home

var name: String

The name of the home.

var uniqueIdentifier: UUID

A unique identifier for the home.

var isPrimary: Bool

A Boolean value that indicates whether the receiver is the primary home for its home manager.

var homeHubState: HMHomeHubState

Specifies the state of the home hub.

Managing Accessories

var accessories: [HMAccessory]

Array of all accessory objects added to the home.

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

Finds and adds nearby accessories to the HMHome object.

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

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

Managing Rooms

var rooms: [HMRoom]

An array of the rooms in the home.

func roomForEntireHome()

A room that represents all parts of the home that don’t have a more specific room to represent them.

Managing Zones

Managing Services

func servicesWithTypes([String])

Returns an array of all services provided by accessories in the home that match the specified types.

var serviceGroups: [HMServiceGroup]

An array of all service groups in the home.

Managing Actions

var actionSets: [HMActionSet]

An array of the action sets in the home.

func executeActionSet(HMActionSet, completionHandler: (Error?) -> Void)

Executes all the actions in a specified action set.

func builtinActionSet(ofType: String)

Retrieves the builtin action set for the specified type.

var triggers: [HMTrigger]

An array of triggers defined in the home.

Managing Users

var currentUser: HMUser

The current HomeKit user.

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

Presents a view controller to manage users of the home.

func homeAccessControl(for: HMUser)

Retrieves the access level of a user associated with the home.

let HMUserFailedAccessoriesKey: String

Key for retrieving details of what accessories failed to add or remove a user.

var users: [HMUser]

All users associated with the home.

Deprecated

Getting and Setting the Delegate

var delegate: HMHomeDelegate?

Delegate that receives updates on the state of the home.

protocol HMHomeDelegate

A set of methods that define the communication method for configuration changes to a home and for the state of executing action sets in the home.

Relationships

Inherits From

Conforms To

See Also

Home Setup

class HMHomeManager

The manager for a collection of one or more homes.

class HMUser

A person in the home who may have access to control accessories and services in the home.

class HMHomeAccessControl

The access privileges of a user associated with a home.

class HMAccessControl

An abstract superclass for accessing user privileges.