The primary unit of living space, typically composed of rooms organized into zones.


class HMHome : NSObject


An HMHome instance is a top-level container in HomeKit representing a structure that a user considers as a single home. Users might have multiple homes that are far apart, like a primary home and a vacation home. Or they might have two homes that are close together, but that they consider as distinct units—for example, a main home and a guest cottage on the same property.

An HMHome instance:

  • Is the main access point for communicating with and configuring accessories, like a garage door opener or a thermostat.

  • Organizes accessories into a number of rooms, which are themselves optionally grouped into zones, such as the upstairs.

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

You create a new home only in response to a specific user request, but you don’t do it directly. When the user asks your app to create a new home—for example, by tapping an Add button in your interface—your app calls the home manager’s addHome(withName:completionHandler:) method with a name that the user supplies. To get a list of existing home instances, use the homes array of the home manager (an instance of HMHomeManager).

Because HomeKit gives your app access to a shared database of home automation information, other apps can change the home’s configuration. Adopt the HMHomeDelegate protocol in your app to stay informed of any such changes that happen outside your app.


Keeping Track of Home Configuration Changes

var delegate: HMHomeDelegate?

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

protocol HMHomeDelegate

An interface that communicates changes to a home’s configuration.

Identifying a Home

var name: String

The name the user gives to the home.

var uniqueIdentifier: UUID

A unique identifier for the home.

var isPrimary: Bool

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

Dividing a House into Rooms

var rooms: [HMRoom]

An array of the rooms created and managed by the user.

func roomForEntireHome() -> HMRoom

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

class HMRoom

The smallest subdivision of a home’s space.

Grouping Rooms into Zones

var zones: [HMZone]

An array of all the zones in the home.

class HMZone

A collection of rooms that users think of as a single area, like upstairs or downstairs.

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.

Grouping Services

func servicesWithTypes([String]) -> [HMService]?

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.

class HMServiceGroup

A collection of accessory services.

Querying the State of a Home Hub

var homeHubState: HMHomeHubState

The state of the home hub.

enum HMHomeHubState

The possible states of the home hub.

Creating Action Sets

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) -> HMActionSet?

Retrieves the builtin action set for the specified type.

class HMActionSet

A collection of actions that you trigger as a group.

Triggering an Action Set

var triggers: [HMTrigger]

An array of triggers defined in the home.

class HMTimerTrigger

A trigger to activate an action set based on a periodic timer.

class HMEventTrigger

A trigger to activate an action set based on a set of events and optional conditions.

class HMTrigger

An abstract base class for triggering actions based on a set of conditions.

Managing Users

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

Presents a view controller to manage users of the home.

var currentUser: HMUser

The current HomeKit user.

class HMUser

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

Controlling User Access

func homeAccessControl(for: HMUser) -> HMHomeAccessControl

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

class HMHomeAccessControl

The access privileges of a user associated with a home.

class HMAccessControl

An abstract superclass for accessing user privileges.

let HMUserFailedAccessoriesKey: String

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

Deprecated Symbols

var users: [HMUser]

All users associated with the home.



Inherits From

Conforms To

See Also

Working with the Home Layout

var homes: [HMHome]

An array of all homes managed by this home manager.