Skip to content

Instantly share code, notes, and snippets.

@128keaton

128keaton/Code stuff

Created Sep 25, 2014
Embed
What would you like to do?
In OTIHapCore.m:
- (void)setupBridgeAccessory {
/* HAKAccessory *bridgeAccessory = [[HAKAccessory alloc] init];
HAKAccessoryInformationService *infoService = [[HAKAccessoryInformationService alloc] init];
infoService.nameCharacteristic.name = @"Hue Bridge";
infoService.serialNumberCharacteristic.serialNumber = @"972BB8AF";
infoService.manufacturerCharacteristic.manufacturer = @"Philips";
infoService.modelCharacteristic.model = @"Hue Bridge";
bridgeAccessory.accessoryInformationService = infoService;
[bridgeAccessory addService:infoService];
[self addAccessory:bridgeAccessory];*/
HAKAccessory *bridgeAccessory = [[HAKAccessory alloc] init];
HAKAccessoryInformationService *infoService = [[HAKAccessoryInformationService alloc] init];
infoService.nameCharacteristic.name = @"Lamp";
infoService.serialNumberCharacteristic.serialNumber = @"972BB8AF";
infoService.manufacturerCharacteristic.manufacturer = @"Keaton";
infoService.modelCharacteristic.model = @"Desk Lamp";
bridgeAccessory.accessoryInformationService = infoService;
[bridgeAccessory addService:infoService];
[self addAccessory: [self createSwitchAccessoryWithUUID:@"lamp" Name:@"Bulby"]
];
}
and add:
- (HAKAccessory *)createSwitchAccessoryWithUUID:(NSString *)uuid Name:(NSString *)name {
NSLog(@"Init Accessory With UUID:%@, name:%@",uuid,name);
HAKAccessory *switchAccessory = [[HAKAccessory alloc]init];
HAKAccessoryInformationService *infoService = [[HAKAccessoryInformationService alloc] init];
infoService.nameCharacteristic.name = [name copy];
infoService.serialNumberCharacteristic.serialNumber = uuid;
infoService.manufacturerCharacteristic.manufacturer = @"Philips";
infoService.modelCharacteristic.model = @"Hue 01";
switchAccessory.accessoryInformationService = infoService;
[switchAccessory addService:infoService];
[switchAccessory addService:[self setupLightService]];
return switchAccessory;
}
- (HAKService *)setupBulbService {
HAKLightBulbService *service = [[HAKLightBulbService alloc] init];
service.nameCharacteristic = [[HAKNameCharacteristic alloc] init];
HAKNameCharacteristic *name = service.nameCharacteristic;
name.name = @"Bulbasaur";
HAKOnCharacteristic *state = service.onCharacteristic;
[service addCharacteristic:name];
[service addCharacteristic:state];
return service;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.