iOS 8 Homekit: An Overview – Part 2
The recently announced iOS8 HomeKit framework by Apple is its official entry into the fast growing home automation market. The smart home market in the past 1- 1.5 years has witnessed many products and applications by giants and small companies alike.
The current state of home automation landscape is filled with numerous wireless standards, different communication protocols and apps to control every smart device. Now with the HomeKit, Apple has tried to bring some balance in this fast evolving market. HomeKit allows you to control various smart appliances/accessories in your home easily and also offers integration with Siri. It has encouraged many developers, with its easy to use design and configurability, to build innovative home automation apps. And the most important concern i.e. security of these smart devices is in process of being addressed by Apple, with end to end encryption between smart devices and their controllers.
In our previous blog about iOS8 HomeKit, we discussed about HomeKit’s basic features and abilities. First, we create a “Home” by giving a unique name to it. Then we add rooms as kitchen, parking, etc to the home with unique room names. With the help of an accessory browser, we add accessories corresponding to actual devices such as doors, lights, etc to the home with unique name & then add those accessories to a particular room. Each accessory installed in the user’s home has a service associated which includes lights, door locks, switches, etc. These accessories have different types of characteristics which enable the user to adjust the brightness, know its locked/unlocked position or simply know the current temperature of a selected accessory.
To encourage innovation, invention & creativity, Apple has allowed defining of custom services or custom characteristics through the HomeKit framework. Interactions such as turn lights ON, switch AC OFF, etc can be performed with these accessories via the created application. But interacting with each accessory, each service every time may cause redundant actions. To simplify such redundant actions, let us have a look at some of the advance concepts.
Some Advance Concepts
Small components like Room, Accessories and Services can make initial setup ready but in real life scenarios, we need to connect these components together & work on them collectively. Following are some of the collections available:
- Zones (HMZone):
Zones are arbitrary grouping of rooms where one room can be added in any number of zones, but it should be uniquely named within a home space and should be in a position to be accessed by Siri.
- Service Groups (HMServiceGroup):
Service groups are formed according to the functionality of accessories, as one might want to perform a similar function across multiple accessories. With service groups, a user can control multiple accessories and perform one specific action. For example, there can be a service group called “NightLights” which control the light of the coffee machine, lights of the refrigerator & so on.
Similar to Zones, a service can be present in multiple service groups, which can be uniquely named for Siri to recognize.
- Action Sets (HMActionSet):
Action set is a collection of actions that are executed together. For example, one action set can be “Night” which executes actions such as lock garage door, lights off, temperature down, close gates, etc., All such actions are grouped together & executed once but in an undefined order.
Action sets, too are uniquely named & can be recognized by Siri. Such action sets can be more useful when we can execute them in a recurring manner and to solve this need we have Triggers represented by HMTimerTrigger.
Triggers execute actions & can be set for a specified date with an option to repeat, so as to allow a recursive pattern. As triggers have a specific time for execution, they can be launched by system/iOS in the background as well. Thus, action sets & triggers together can control many accessories simultaneously, helping the developer to script the complex behaviour within any home automation app.
How do we test?
With the information presented in the previous blog, the user can add home, rooms, accessories and have complete access to the services and features of the utility.
Furthermore, users can interact with devices & accessories through one application or via Siri. Now that we have a basic flow ready one needs to test and confirm the functioning of this application as per the requirements.
But how do we test without accessories being present? Surely one cannot recreate a home environment equipped with all the accessories to be tested, within an organizations premise. For testing, with Xcode 6 we have a tool called “HomeKit Accessory Simulator” It simulates the actions exhibited by real accessories. It is a great way to get started with the HomeKit which enables the user to test & debug the behaviour.
HomeKit has surely captured the imagination of many mobile app developers. It has given them the opportunity to develop innovative and futuristic apps and with a ready to serve market outlook, thus limiting their risk.