I would like to know if you can set the code that enables the accessory programmatically? I in this moment use:
import UIKit
import Foundation
import HomeKit
let homeManager = HMHomeManager()
func addAccessory () {
if let home = homeManager.primaryHome {
for room in home.rooms {
if room.name == "Kitchen" {
homeManager.primaryHome?.addAccessory(accessory, completionHandler: { (error) -> Void in
if error != nil {
print("ERROR 1 \(error?.localizedDescription)")
}else {
self.homeManager.primaryHome?.assignAccessory(accessory, toRoom: room, completionHandler: { (error) -> Void in
if error != nil {
print("ERROR 2 \(error?.localizedDescription)")
} else {
print("Accessory Add successfully")
}}}}
}
I would not use the usual view offered by Apple to enter the code.