Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save EddyVerbruggen/974b7fc2a180f9774a11740366b3a767 to your computer and use it in GitHub Desktop.
Save EddyVerbruggen/974b7fc2a180f9774a11740366b3a767 to your computer and use it in GitHub Desktop.
NativeScript HomeKit - Searching and assigning Accessories
// start searching
homekit.startSearchingForAccessories(
// event handler which is triggered when a new accessory is found
(accessory: Accessory) => {
console.log(`New accessory found: ${accessory.name}`);
// once found you can assign it to a home
homekit.addAccessoryToHome(accessory.name, homeName)
.then(added => console.log(`Added? ${added}`));
},
// event handler which is triggered when an accessory was removed
(accessory: Accessory) => {
console.log(`Accessory removed: ${accessory.name}`);
});
// stop searching
homekit.stopSearchingForAccessories().then(() => console.log("Stopped searchin'"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment