HMAccessory
A home automation accessory, like a garage door opener or a thermostat.
Declaration
class HMAccessoryOverview
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 addAndSetupAccessories(completionHandler:) 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.