Tabnine Logo For Javascript
hap-nodejs
Code IndexAdd Tabnine to your IDE (free)

How to use hap-nodejs

Best JavaScript code snippets using hap-nodejs(Showing top 13 results out of 315)

origin: rdmtc/RedMatic-HomeKit

this.on('input', msg => {
          console.log(msg);
          this.debug('update ProgrammableSwitchEvent SINGLE_PRESS');
          doorbellService.getCharacteristic(hap.Characteristic.ProgrammableSwitchEvent).updateValue(0);
        });
origin: rdmtc/RedMatic-HomeKit

config.inputsources.forEach((src, i) => {
          const id = i + 1;
          const inputService = acc.addService(Service.InputSource, src.name, src.name);
          inputService
            .setCharacteristic(Characteristic.Identifier, id)
            .setCharacteristic(Characteristic.ConfiguredName, src.name)
            .setCharacteristic(Characteristic.IsConfigured, Characteristic.IsConfigured.CONFIGURED)
            .setCharacteristic(Characteristic.InputSourceType, src.type)
            .setCharacteristic(Characteristic.CurrentVisibilityState, Characteristic.CurrentVisibilityState.SHOWN)
            .setCharacteristic(Characteristic.TargetVisibilityState, Characteristic.TargetVisibilityState.SHOWN);

          tvService.addLinkedService(inputService);
        });
origin: rdmtc/RedMatic-HomeKit

this.on('close', () => {
        this.debug('remove event listeners');

        tvService.getCharacteristic(Characteristic.Active)
          .removeListener('set', setActive);

        tvService.getCharacteristic(Characteristic.ActiveIdentifier)
          .removeListener('set', setActiveIdentifier);

        tvService.getCharacteristic(Characteristic.RemoteKey)
          .removeListener('set', setRemoteKey);

        tvService.getCharacteristic(Characteristic.PowerModeSelection)
          .removeListener('set', setPowerModeSelection);

        speakerService.getCharacteristic(Characteristic.VolumeSelector)
          .removeListener('set', setVolumeSelector);
      });
origin: norman-thomas/homebridge-particle-io

describe('constructor', () => {
  it('should assign config values to member variables', () => {
   const homebridge = dummyHomebridge(dummyConfig);
   const device = dummyConfig.devices[0];
   const dummyURL = 'https://some.random.url.com/';
   const dummyAccessToken = 'MY_top_SECRET_access_TOKEN';
   const Service = homebridge.hap.Service;
   const Characteristic = homebridge.hap.Characteristic;
   const accessory = new ActorAccessory(
    () => {}, dummyURL, dummyAccessToken, device, homebridge, Service.Lightbulb, Characteristic.On
   );
   accessory.url.should.be.equal(dummyURL);
   accessory.accessToken.should.be.equal(dummyAccessToken);
   accessory.deviceId.should.be.equal(device.device_id);

   accessory.services.should.have.length(2);
   accessory.services[1].should.be.an.instanceOf(Service.Lightbulb);
  });
 });
origin: rdmtc/RedMatic-HomeKit

accessory(config) {
      const uuid = hap.uuid.generate(config.id + (config.uuidAddition ? config.uuidAddition : ''));
      let acc;

      this.bridge.bridgedAccessories.forEach(a => {
        if (a.UUID === uuid) {
          acc = a;
        }
      });

      if (acc) {
        this.debug('already existing accessory ' + config.id + ' ' + config.name);
      } else if (this.bridge.bridgedAccessories.length >= 150) {
        this.error('maximum of 150 accessories per bridge exceeded, can\'t add ' + config.id + ' ' + config.name);
      } else {
        this.debug('addAccessory ' + config.id + ' ' + config.name);
        acc = new hap.Accessory(config.name, uuid, hap.Accessory.Categories.OTHER);
        this.bridge.addBridgedAccessory(acc);
      }

      this.waitForAccessories();

      return acc;
    }
origin: rdmtc/RedMatic-HomeKit

acc.on('identify', (paired, callback) => {
        this.log('identify ' + this.id + ' ' + this.username + ' ' + paired);
        callback();
      });
origin: rdmtc/RedMatic-HomeKit

  port: config.port,
  pincode: config.pincode,
  category: Accessory.Categories.TELEVISION
});
origin: rdmtc/RedMatic-HomeKit

this.on('input', msg => {
        switch (msg.topic) {
          case 'InputSource': {
            let identifier = msg.payload;
            if (typeof msg.payload === 'string') {
              config.inputsources.forEach((src, i) => {
                if (msg.payload === src.name) {
                  identifier = i + 1;
                }
              });
            }

            if (config.inputsources[identifier - 1]) {
              this.debug('set ActiveIdentifier ' + identifier + ' (payload was ' + msg.payload + ')');
              this.status({shape: 'dot', fill: 'blue', text: config.inputsources[identifier - 1].name});
              tvService.updateCharacteristic(Characteristic.ActiveIdentifier, identifier);
            }

            break;
          }

          default:
            this.debug('set Active ' + msg.payload);
            this.status({shape: msg.payload ? 'dot' : 'ring', fill: msg.payload ? 'blue' : 'grey'});
            tvService.updateCharacteristic(Characteristic.Active, msg.payload ? 1 : 0);
        }
      });
origin: rdmtc/RedMatic-HomeKit

  this.bridge = bridges[this.username];
} else {
  this.bridge = new hap.Bridge(this.name, hap.uuid.generate(this.username));
  bridges[this.username] = this.bridge;
origin: rdmtc/RedMatic-HomeKit

});
this.bridge.getService(hap.Service.AccessoryInformation)
  .setCharacteristic(hap.Characteristic.Manufacturer, 'RedMatic')
  .setCharacteristic(hap.Characteristic.Model, 'HAP-Nodejs Bridge')
  .setCharacteristic(hap.Characteristic.SerialNumber, this.username)
  .setCharacteristic(hap.Characteristic.FirmwareRevision, pkg.version);
        port: parseInt(this.port, 10),
        pincode: this.pincode,
        category: hap.Accessory.Categories.OTHER
      }, this.allowInsecureRequest);
      this.log('published bridge (' + this.bridge.bridgedAccessories.length + ' Accessories) ' + this.name + ' ' + this.username + ' on port ' + this.port);
origin: norman-thomas/homebridge-particle-io

  accessory.should.be.instanceOf(HumiditySensorAccessory);
  accessory.deviceId.should.be.equal(device.device_id);
  accessory.ServiceType.should.be.equal(homebridge.hap.Service.HumiditySensor);
  accessory.CharacteristicType.should.be.equal(homebridge.hap.Characteristic.CurrentRelativeHumidity);
 });
});
origin: norman-thomas/homebridge-particle-io

   device,
   homebridge,
   Service.HumiditySensor,
   Characteristic.CurrentRelativeHumidity
  );
  accessory.eventName.should.be.equal(device.event_name);
  accessory.services[1].should.be.an.instanceOf(Service.HumiditySensor);
 });
});
origin: rdmtc/RedMatic-HomeKit

.once('listening', () => {
  testPort.once('close', () => {
    acc.publish({
      username: config.username,
      port: config.port,
      pincode: config.pincode,
      category: Accessory.Categories.CAMERA
    });
    acc._server.on('listening', () => {
      this.log('camera ' + this.name + ' listening on port ' + config.port);
      this.status({fill: 'green', shape: 'ring', text: ' '});
    });
    acc._server.on('pair', username => {
      this.log('camera ' + this.name + ' paired', username);
    });
    acc._server.on('unpair', username => {
      this.log('camera ' + this.name + ' unpaired', username);
    });
    acc._server.on('verify', () => {
      this.log('camera ' + this.name + ' verify');
    });
hap-nodejs(npm)

Most used hap-nodejs functions

  • Accessory.Categories
  • Accessory._server
  • Accessory.on
  • Accessory.publish
  • CAMERA
  • Characteristic.ActiveIdentifier,
  • Characteristic.CONFIGURED,
  • Characteristic.ConfiguredName,
  • Characteristic.CurrentRelativeHumidity,
  • Characteristic.CurrentVisibilityState,
  • Characteristic.FirmwareRevision,
  • Characteristic.Identifier,
  • Characteristic.InputSourceType,
  • Characteristic.IsConfigured,
  • Characteristic.Manufacturer,
  • Characteristic.Model,
  • Characteristic.On,
  • Characteristic.PowerModeSelection,
  • Characteristic.ProgrammableSwitchEvent

Popular in JavaScript

  • redis
    Redis client library
  • ws
    Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js
  • winston
    A logger for just about everything.
  • js-yaml
    YAML 1.2 parser and serializer
  • fs-extra
    fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.
  • debug
    small debugging utility
  • axios
    Promise based HTTP client for the browser and node.js
  • minimatch
    a glob matcher in javascript
  • qs
    A querystring parser that supports nesting and arrays, with a depth limit
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now