Developing Apps with the HomeKit Accessory Simulator

Developing Apps with the HomeKit Accessory Simulator

Understand how to use Apple's HomeKit Accessory Simulator (HAS) to simulate smart home accessories when developing HomeKit-enabled apps.

If you are developing a HomeKit-enabled app and want to test accessories your app may be able to control, Apple's HomeKit Accessory Simulator (HAS) is what you need.

The HomeKit Accessory Simulator can simulate any accessory and help automate your testing process. You can configure accessories with standard and custom services and characteristics and even simulate network cameras or video doorbells with your Mac's system camera.

The HAS comes as a part of the Additional Tools for Xcode package and can be downloaded from the Apple Developer Website. Inside the package, there is a Hardware folder in which you can find the HomeKitAccessorySimulator.app that you may put in your Applications folder.

The Apple HomeKit Accessory Simulator

Accessories, Services & Characteristics

HomeKit supports all kinds of smart home accessories, ranging from lightbulbs to sensors, cameras, and door openers. An Accessory can have various control elements, which are called Services, e.g. a smart lightbulb might have an ambient light sensor service and a lightbulb service.

A Service can have various Characteristics you can use to control it. As in the previous example, the ambient light sensor service may have values to indicate the current ambient light level and an indication of whether ambient light detection is on or not. The lightbulb service may have an on-and-off state and a brightness level. With these Characteristics, the behavior of the accessory can be configured. Also, every accessory comes with a default accessory information service that contains manufacturer information, such as firmware version or model numbers, etc.

Example of a HomeKit Accessory, its Services and Characteristics

In the HomeKit Accessory Simulator, you can add accessories by clicking on the + symbol in the bottom left corner of the window.

You can select the accessory category from an extensive list, ranging from air conditioners or door locks to lightbulbs, outlets, sensors, or thermostats. Also, you can specify in the accessory type whether it is an IP camera or video doorbell. For the simulation, you can add a name, manufacturer information, serial number, and setup code.

Once the accessory has been added, you can inspect the settings and you can also see the setup code that can be used to configure the accessory in the testing environment. Also, below the main information about the accessory, you can inspect its services and characteristics.

In this example, you can see the lightbulb 71 service and its characteristics On, Brightness, Hue and Saturation.

You can add additional characteristics to the service by clicking on the Add Characteristics button. You can select from an extensive list of characteristics, ranging from simple states such as active, in use, etc. to air quality, battery level, and all kinds of sensor characteristics. For example, you could add a Color Temperature characteristic to the lightbulb which might come in handy to indicate the lights' warmer or colder color temperature.

You can also add additional services to the accessory, for example, a Light Sensor. Again the list of possible services is extensive, ranging from air quality or carbon dioxide sensors to fans, lock mechanisms or switches.

Once the service is added, it will appear in the accessory's overview and can be configured and extended with additional characteristics. If needed, characteristics can also be removed by clicking on the - symbol on the right side.

Next, let's see how we can add the accessory to our HomeKit environment. Become a free member or log in to proceed.