Contents

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 throws

Parameters

  • accessory:

    The accessory to add to the home.

  • completion:

    The block executed after the request is processed.

    error

    nil on 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().

See Also

Managing accessories