Last active
          January 14, 2017 15:49 
        
      - 
      
 - 
        
Save EddyVerbruggen/18dc11c274a33f4334b8991373a64f99 to your computer and use it in GitHub Desktop.  
    NativeScript HomeKit - Listing Services and Characteristics
  
        
  
    
      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
    
  
  
    
  | // import a few Classes we're gonna use | |
| import { Accessory, Service, Characteristic } from 'nativescript-homekit'; | |
| // given an accessory.. | |
| let accessory: Accessory = myPreviouslyFoundAccessory; | |
| // .. you can now list its services.. | |
| accessory.services.forEach((s: Service) => { | |
| console.log(`Service ${s.name} of type ${s.type} has ${s.characteristics.length} characteristics`); | |
| // .. and the service characteristics | |
| s.characteristics.forEach((c: Characteristic) => { | |
| console.log(`Characteristic ${c.description} is of type ${c.type}`); | |
| }); | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment