How to use the hap-nodejs.Bridge 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 Capevace / halbert / system / home-kit.js View on Github external
function homeKitSetup(moduleRegistry) {
  init();

  const bridge = new Bridge('H.A.L.B.E.R.T.', config.device.uuid);

  // Identification Event
  bridge.on('identify', (paired, callback) => {
    console.logger.info('HomeKit paired:', paired);
    callback();
  });

  const modules = moduleRegistry.getRegisteredModules();
  Object.keys(modules).forEach(moduleKey => {
    if (!modules[moduleKey].accessories) return;

    modules[
      moduleKey
    ].accessories.forEach(accessory => bridge.addBridgedAccessory(accessory));
  });
github htreu / OpenHAB-HomeKit-Bridge / lib / openHABBridge.js View on Github external
function publishOpenHABBridgeAccessory(bridgeName, openHABWidgets) {
  let accessoryProvider = new AccessoryProvider();
  let homeKitAccessories = accessoryProvider.createHomeKitAccessories(openHABWidgets);
  let openHabBridge = new Bridge(bridgeName, uuid.generate(bridgeName));

  homeKitAccessories.forEach(function(accessory) {
    openHabBridge.addBridgedAccessory(accessory);
  });

  // Publish the Bridge on the local network.
  openHabBridge.publish({
    username: generateUniqueUsername(bridgeName),
    port: parseInt(targetPort),
    pincode: pincode,
    category: Accessory.Categories.OTHER
  });
};
github rdmtc / RedMatic-HomeKit / nodes / redmatic-homekit-bridge.js View on Github external
}

            this.hap = hap;

            this.version = pkg.version;

            this.name = config.name || 'RedMatic';
            this.username = config.username;
            this.pincode = config.pincode;
            this.port = config.port;
            this.allowInsecureRequest = Boolean(config.allowInsecureRequest);

            if (bridges[this.username]) {
                this.bridge = bridges[this.username];
            } else {
                this.bridge = new hap.Bridge(this.name, hap.uuid.generate(this.username));
                bridges[this.username] = this.bridge;
            }

            this.waitForAccessories();

            this.on('close', (remove, done) => {
                if (remove && this.bridge.isPublished) {
                //    this.bridge.unpublish();
                //    this.log('unpublished bridge ' + this.name + ' ' + this.username + ' on port ' + this.port);
                }

                done();
            });
        }
github nfarina / homebridge / lib / server.js View on Github external
Server.prototype._createBridge = function() {
  // pull out our custom Bridge settings from config.json, if any
  var bridgeConfig = this._config.bridge || {};

  // Create our Bridge which will host all loaded Accessories
  return new Bridge(bridgeConfig.name || 'Homebridge', uuid.generate("HomeBridge"));
}
github adafruit / adafruit-io-node / cli / homekit.js View on Github external
light(yargs) {

    yargs.usage(`Usage: adafruit-io homekit light [options]`)
         .command('help', 'Show help')
         .alias('n', 'name').demand('name')
         .nargs('n', 1).describe('n', 'the name of the light');

    const argv = yargs.argv,
          command = argv._[0];

    if(command === 'help')
      return yargs.showHelp();

    const name = argv.name || 'light',
          bridge = new Bridge('Adafruit IO', uuid.generate('Adafruit IO'));

    bridge.on('identify', (paired, cb) => cb());

    const light = new Accessories.light(name, this.client);

    bridge.addBridgedAccessory(light);

    this.logo();
    this.info('advertising homekit light accessory...');
    this.info('PIN: 100-11-100');

    bridge.publish({
      username: 'AD:A0:AD:A0:AD:A0',
      port: 60000,
      pincode: '100-11-100',
      category: Accessory.Categories.BRIDGE
github jensweigele / ioBroker.yahka / yahka.homekit-bridge.js View on Github external
THomeKitBridge.prototype.setupBridge = function () {
        var _this = this;
        var hapBridge = new HAP.Bridge(this.config.name, HAP.uuid.generate(this.config.ident));
        hapBridge.getService(exports.HAPService.AccessoryInformation)
            .setCharacteristic(exports.HAPCharacteristic.Manufacturer, this.config.manufacturer || "not configured")
            .setCharacteristic(exports.HAPCharacteristic.Model, this.config.model || "not configured")
            .setCharacteristic(exports.HAPCharacteristic.SerialNumber, this.config.serial || "not configured");
        hapBridge.on('identify', function (paired, callback) {
            _this.FLogger.debug('Node Bridge identify:' + paired);
            callback();
        });
        return hapBridge;
    };
    THomeKitBridge.prototype.createDevice = function (device) {