addAccessory(_:completionHandler:)
Adds a new accessory to the home.
Declaration
func addAccessory(_ accessory: HMAccessory, completionHandler completion: @escaping @Sendable ((any Error)?) -> Void)func addAccessory(_ accessory: HMAccessory) async throwsParameters
- accessory:
The accessory to add to the home.
- completion:
The block executed after the request is processed.
- error
nilon success; otherwise, error object indicating the reason for failure.
Discussion
You discover accessories to add to a home using the HMAccessoryBrowser class. Newly added accessories are automatically added to the room returned by roomForEntireHome().