lib/Service.js
function Service(displayName, UUID, subtype) {

  if (!UUID) throw new 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 = [];

  this.isHiddenService = false;
  this.isPrimaryService = false;
  this.linkedServices = [];

  // 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);
  }
}
function Service(displayName, UUID, subtype) {

  if (!UUID) throw new 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 = [];

  this.isHiddenService = false;
  this.isPrimaryService = false;
  this.linkedServices = [];

  // 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);
  }
}
function Service ( displayName , UUID , subtype ) { if ( ! UUID ) throw new 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 = [ ] ; this . isHiddenService = false ; this . isPrimaryService = false ; this . linkedServices = [ ] ; // 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 ) ; } }
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.

Unlike Characteristics, where you cannot have two Characteristics with the same UUID in the same Service,
you can actually have multiple Services with the same UUID in a single Accessory. For instance, imagine
a Garage Door Opener with both a "security light" and a "backlight" for the display. Each light could be
a "Lightbulb" Service with the same UUID. To account for this situation, we define an extra "subtype"
property on Service, that can be a string or other string-convertible object that uniquely identifies the
Service among its peers in an Accessory. For instance, you might have `service1.subtype = 'security_light'`
for one and `service2.subtype = 'backlight'` for the other.

You can also define custom Services by providing your own UUID for the type that you generate yourself.
Custom Services can contain an arbitrary set of Characteristics, but Siri will likely not be able to
work with these.

@event 'characteristic-change' => function({characteristic, oldValue, newValue, context}) { }
Emitted after a change in the value of one of our Characteristics has occurred.
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 .