Last active
January 13, 2017 10:01
-
-
Save EddyVerbruggen/974b7fc2a180f9774a11740366b3a767 to your computer and use it in GitHub Desktop.
NativeScript HomeKit - Searching and assigning Accessories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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