How to use the hap-nodejs.uuid.generate function in hap-nodejs

To help you get started, we’ve selected a few hap-nodejs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nfarina / homebridge / lib / server.js View on Github external
if (!(services[0] instanceof Service)) {
    // The returned "services" for this accessory is assumed to be the old style: a big array
    // of JSON-style objects that will need to be parsed by HAP-NodeJS's AccessoryLoader.

    // Create the actual HAP-NodeJS "Accessory" instance
    return AccessoryLoader.parseAccessoryJSON({
      displayName: displayName,
      services: services
    });
  }
  else {
    // The returned "services" for this accessory are simply an array of new-API-style
    // Service instances which we can add to a created HAP-NodeJS Accessory directly.

    var accessoryUUID = uuid.generate(accessoryType + ":" + (uuid_base || displayName));

    var accessory = new Accessory(displayName, accessoryUUID);

    // listen for the identify event if the accessory instance has defined an identify() method
    if (accessoryInstance.identify)
      accessory.on('identify', function(paired, callback) { accessoryInstance.identify(callback); });

    services.forEach(function(service) {

      // if you returned an AccessoryInformation service, merge its values with ours
      if (service instanceof Service.AccessoryInformation) {
        var existingService = accessory.getService(Service.AccessoryInformation);

        // pull out any values you may have defined
        var manufacturer = service.getCharacteristic(Characteristic.Manufacturer).value;
        var model = service.getCharacteristic(Characteristic.Model).value;
github nfarina / homebridge / lib / bridgeSetupSession.js View on Github external
function BridgeSetupSession(stateChar, controlChar) {
  this.validSession = false
  this.sessionUUID = uuid.generate(crypto.randomBytes(32));
  this.stateChar = stateChar;
  this.controlChar = controlChar;

  this.transactionID = 0;
  this.preferedLanguage = "en-US";

  this.lastResponse = null;

  // 0 - Waiting for negotiate
  // 1 - Waiting for selection
  // 2 - List platforms, waiting selection to give session to plugin
  // 3 - Forward message to platform
  // 4 - Manage accessory config, waiting selection
  this.currentStage = 0;

  this.currentPluginName;
github htreu / OpenHAB-HomeKit-Bridge / lib / subtypes / RollershutterItem.js View on Github external
buildAccessory(state) {
    let position = state === 'Uninitialized' ? 100 : +state;
    let accessory = new Accessory(
      this.name, uuid.generate(this.constructor.name + this.name));

    let service = accessory.addService(Service.WindowCovering, this.name);

    let charactersiticCurrentPosition =
      service.getCharacteristic(Characteristic.CurrentPosition);
    charactersiticCurrentPosition.setValue(this.convertValue(position));
    charactersiticCurrentPosition.on('get', this.readOpenHabCurrentPosition.bind(this));

    let charactersiticTargetPosition =
      service.getCharacteristic(Characteristic.TargetPosition);
    charactersiticTargetPosition.setValue(position);
    charactersiticTargetPosition.on('set', this.updateOpenHabItem.bind(this));
    charactersiticTargetPosition.on('get', this.readOpenHabCurrentPosition.bind(this));

    let charactersiticPositionState =
      service.getCharacteristic(Characteristic.PositionState);
github htreu / OpenHAB-HomeKit-Bridge / lib / Slider.js View on Github external
buildAccessory() {
    let accessory = new Accessory(this.name,
      uuid.generate(this.constructor.name + this.name));

    let charactersiticOnOff = accessory
      .addService(Service.Lightbulb, this.name)
      .getCharacteristic(Characteristic.On);

    charactersiticOnOff.setValue(+this.state > 0);
    charactersiticOnOff.on('set', this.updateOpenHabItem.bind(this));
    charactersiticOnOff.on('get', this.readOpenHabPowerState.bind(this));

    let charactersiticBrightness = accessory
      .getService(Service.Lightbulb)
      .addCharacteristic(Characteristic.Brightness);

    charactersiticBrightness.setValue(+this.state);
    charactersiticBrightness.on('set', this.updateOpenHabItem.bind(this));
    charactersiticBrightness.on('get', this.readOpenHabBrightnessState.bind(this));
github htreu / OpenHAB-HomeKit-Bridge / lib / ContactSensor.js View on Github external
buildAccessory(state) {
    let accessory = new Accessory(this.name,
      uuid.generate(this.constructor.name + this.name));

    let charactersiticContactState = accessory
      .addService(Service.ContactSensor, this.name)
      .getCharacteristic(Characteristic.ContactSensorState);

    charactersiticContactState.setValue(this.convertState(state));
    charactersiticContactState.on('get', this.readOpenHabContact.bind(this));

    return accessory;
  }
github htreu / OpenHAB-HomeKit-Bridge / lib / Colorpicker.js View on Github external
buildAccessory(state) {
    let accessory = new Accessory(
      this.name, uuid.generate(this.constructor.name + this.name));

    let singleStates = this.parseState(state);
    let hue = +singleStates[0];
    let saturation = +singleStates[1];
    let brightness = +singleStates[2];

    let service = accessory.addService(Service.Lightbulb, this.name);

    let charactersiticOnOff =
      service.getCharacteristic(Characteristic.On);
    charactersiticOnOff.setValue(brightness > 0);
    charactersiticOnOff.on('set', this.updateOpenHabBrightness.bind(this));
    charactersiticOnOff.on('get', this.readOpenHabPowerState.bind(this));

    let charactersiticBrightness =
      service.addCharacteristic(Characteristic.Brightness);
github htreu / OpenHAB-HomeKit-Bridge / lib / Text.js View on Github external
buildAccessory(state, name) {
    let accessory = new Accessory(this.name,
      uuid.generate(this.constructor.name + this.name));

    let service = CustomServices.TextInfoService;
    let characteristic = CustomCharacteristics.TextInfoCharacteristic;
    let initialValue = this.labelValue(name);

    switch (this.textType) {

    case 'contact':
      service = Service.ContactSensor;
      characteristic = Characteristic.ContactSensorState;
      initialValue = this.stateValue(state);
      break;

    case 'temperature':
      service = Service.TemperatureSensor;
      characteristic = Characteristic.CurrentTemperature;