How To Get Started with Apple HomeKit

HomeKit is Apple’s entry into the smart-home arena. Following in the footsteps of Google’s recently acquired Nest system (as well as Google’s seemingly forgotten Android @Home initiative), Apple now provides an SDK as well as certification for smart devices in a more contextually aware home.

Apple announced HomeKit back in June, during its annual WWDC conference. The system will allow users to seamlessly hook up smart devices via Bluetooth or Wi-Fi. What will this look like in your home? Well, imagine everything from a toaster than can alert you when your bagel has popped up to a system that adjusts the lighting and turns on the television when you enter a room.

As with its HealthKit, the focal point of Apple's HomeKit initiative is a unifying protocol--standardization via a singular SDK--to act as the conduit for devices or gadgets to communicate with iOS. This goes along with the consistent theme we have seen in iOS 8 and OSX Yosemite: contextual awareness through technologies such as Continuity or handoff. Via HomeKit, smart devices know when you are in a room, when you are going to use something and when you are finished using something--and take action accordingly.

Building the Home of the Future

We don't expect HomeKit to explode in popularity and use--at least not right out of the gate--but Apple's (and Google's) weight will certainly go a long way toward boosting the smart home market.


Apple has given us the SDK; now all we have to do is figure out what to do with it--that is, coming up with creative ways of unifying home appliances and gadgets with iOS. There are some obvious candidates for "smart-enablement," in the home, including thermostats, garage door openers and cameras. But developers should also think outside the box--perhaps working to build an automated pet feeder or backyard grill.

Developers should also be keeping in mind future Apple TV software, as well as the much-awaited release of the Apple Watch (slated to arrive in 2015). Both of these systems will have some sort of interaction potential with HomeKit, paving the way for more interesting and contextual apps and projects.

For our pet how-to project, we will actually create a pet feeder (pun intended)--a hypothetical accessory that stores pet food, sets storage temperature and dispenses food to your dog or cat.

Getting Started

Class Hierarchy

It’s important to first familiarize yourself with the various classes that are part of HomeKit, and understand how each class and subclass relate in the hierarchy.

The most prominent class is HMHomeManager, which represents a collection of one or more homes (locations). Within that collection, each house is represented by an HNHome, with each room represented by an HNRoom.


Each room can contain one or more accessories (HMAccessory), which are the actual physical home automation item.

Looking at the individual Accessory (HMAccessory), it would normally expose or provide a service (HMService) such as "roll down the garage door" or "turn on the security camera." Services belonging to an Accessory are grouped as a HMServiceGroup, making it easy to address accessory services as a single logical entity.

HomeKit diagram 2

Accessories are also organized according to zones (HMZone). This allows developers to group parts of the home according to different locations, such as kitchen or second floor. This provides indicative metadata to allow you to direct communications toward a certain area of the home. (This also plays in well with Apple's Siri voice-enabled app, which will become evident later on.)

Finally, each service is made up of specific attributed characteristics (HMCharacteristic), which expose certain properties for interaction--such as a Boolean (on or off, yes or no), string or floats--to signify a certain state of the service (for example, whether it's turned on or what the current temperature of the accessory is).


(Source: Apple Dev)




NSObject is the root class of most Objective-C class hierarchies.


An HMAccessory object represents a home automation accessory in the home, such as a garage door opener or a thermostat.


An HMAccessoryBrowser object is a network browser used to discover new accessories.


HMAction is an abstract base class for actions in Home Kit.


An HMCharacteristicMetadata object is used to represent an action in an action set that writes a value to a characteristic.


An HMActionSet object represents a set of actions (instances of HMAction) to be applied as a single set.


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


An HMCharacteristicMetadata object represents metadata for a characteristic.


An HMHome object allows you to communicate with and configure the different accessories in a home.


A home manager object manages a collection of one or more homes.


An HMRoom object is used to represent a room in a home.


An HMService object represents a service provided by an accessory.


An HMServiceGroup object represents a collection of accessory services, making it easier to address the services as a single entity.


An HMTrigger object represents a trigger event, used to trigger one or more action sets (instances of HMActionSet) when the conditions of the trigger are satisfied.


An HMTimerTrigger object represents a trigger based on periodic timers.


An HMUser object represents a person in the home who may have access to control accessories and services in the home.


An HMZone object represents a collection of rooms that the user thinks of as a single area or zone—for example, “Living Room” and “Kitchen” might be grouped into a zone called “Downstairs”.





HMAccessoryBrowserDelegate defines the interface for an HMAccessoryBrowser object to notify its delegate of new accessories.


The HMAccessoryDelegate protocol defines the communication method for state updates from accessories to their delegates.


The HMHomeDelegate protocol define the communication method for configuration changes to a home and for the state of executing action sets in the home.


The HMHomeManagerDelegate protocol defines how home manager objects communicate changes to their delegate.

Setting Up the Environment

We are building a simulated accessory, so we will use HomeKit’s Accessory Simulator, which comes bundled with XCode. (The system may prompt you to download it if it hasn’t been downloaded already; it can be accessed as follows: Choose Xcode > Open Developer Tool > HomeKit Accessory Simulator.)

To add the pet feeder device to the simuator, select Add and choose New Accessory. Then, set its properties, from manufacturer to serial number:

HomeKit screen 1

You will then be presented with:

HomeKit screen 2

During our tests, we then set the Service to expose a switch that would determine whether the feeder is On or Off. (Set to On during vacation, of course).


Next, we set Characteristics, which let us control the accessory. We started by setting up the ability to control the temperature of the device.


We added another Characteristic that will let users read the temperature of the accessory.

final screenshow

We set up a custom Characteristic type, setting float as the type format for Celsius. We also set maximum and minimum temperature points, as well as the step value (or incremental value). We used a freely available online generator for the UUID, but you can also use the NSUUID class in Cocoa to generate a unique identifier.

Easy enough, right? We'll cover the coding aspects of HomeKit in greater detail in How to Code the Home of the Future with HomeKit.

Be sure to read the next Home Automation article: Code Your Smart Home with Apple HomeKit