A home automation accessory, like a garage door opener or a thermostat.
SDKs
- iOS 8.0+
- tvOS 10.0+
- watchOS 2.0+
Framework
- Home
Kit
Declaration
class HMAccessory : NSObject
Overview
An HMAccessory
instance represents a physical device, like a garage door opener, installed in a home and assigned to a room.
You don’t create accessories directly. Instead you get them from the accessories
array of an HMHome
instance when you want all the accessories in a home, or the accessories
array of an HMRoom
instance when you want all the accessories in a particular room. Each physical accessory in the home is represented by exactly one accessory instance, so that one instance appears in both a home and a room collection. This is because it’s simultaneously part of the home and in one of the home’s rooms.
When you want to add new accessories, you call the home’s add
method. In response, HomeKit presents the user with an interface that steps through the process of searching for new accessories in the physical environment, naming them, and assigning them to a room.
Accessories provide one or more services, represented by instances of HMService
, that are the features that the user can control, like the light attached to a garage door opener, or the door opener mechanism itself.