nl_tokens: Service represents a set of grouped values necessary to provide a logical function . For instance a Door Lock Mechanism service might contain two values one for the desired lock state and one for the current lock state . A particular Service is distinguished from others by its type which is a UUID . HomeKit provides a set of known Service UUIDs defined in HomeKitTypes . js along with a corresponding concrete subclass that you can instantiate directly to setup the necessary values . These natively - supported Services are expected to contain a particular set of Characteristics .
pl_tokens: function Service ( displayName , UUID , subtype ) { if ( ! UUID ) throw <mask> Error ( "Services must be created with a valid UUID." ) ; this . displayName = displayName ; this . UUID = UUID ; this . subtype = subtype ; this . iid = null ; // assigned later by our containing Accessory this . characteristics = [ ] ; this . optionalCharacteristics = [ ] ; // every service has an optional Characteristic.Name property - we'll set it to our displayName // if one was given // if you don't provide a display name, some HomeKit apps may choose to hide the device. if ( displayName ) { // create the characteristic if necessary var nameCharacteristic = this . getCharacteristic ( Characteristic . Name ) || this . addCharacteristic ( Characteristic . Name ) ; nameCharacteristic . setValue ( displayName ) ; } }