How to use the hap-nodejs.uuid 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 jensweigele / ioBroker.yahka / yahka.homekit-bridge.js View on Github external
THomeKitBridge.prototype.createDevice = function (device) {
        var _this = this;
        var e_2, _a;
        var devName = device.name;
        var deviceID = HAP.uuid.generate(this.config.ident + ':' + devName);
        var i = 0;
        while (this.bridgeObject.bridgedAccessories.some(function (a) { return a.UUID == deviceID; })) {
            devName = device.name + '_' + ++i;
            deviceID = HAP.uuid.generate(this.config.ident + ':' + devName);
        }
        this.FLogger.info('adding ' + devName + ' with UUID: ' + deviceID);
        var hapDevice = new HAP.Accessory(devName, deviceID);
        hapDevice.getService(exports.HAPService.AccessoryInformation)
            .setCharacteristic(exports.HAPCharacteristic.Manufacturer, device.manufacturer || 'not configured')
            .setCharacteristic(exports.HAPCharacteristic.Model, device.model || 'not configured')
            .setCharacteristic(exports.HAPCharacteristic.SerialNumber, device.serial || 'not configured');
        hapDevice.on('identify', function (paired, callback) {
            _this.FLogger.debug('device identify');
            callback();
        });
        try {
            for (var _b = __values(device.services), _c = _b.next(); !_c.done; _c = _b.next()) {
                var serviceConfig = _c.value;
                this.initService(hapDevice, serviceConfig);
            }
github nfarina / homebridge / lib / platformAccessory.js View on Github external
var uuid = require("hap-nodejs").uuid;
var Accessory = require("hap-nodejs").Accessory;
var Service = require("hap-nodejs").Service;
var Characteristic = require("hap-nodejs").Characteristic;
var inherits = require('util').inherits;
var EventEmitter = require('events').EventEmitter;

'use strict';

module.exports = {
  PlatformAccessory: PlatformAccessory
}

function PlatformAccessory(displayName, UUID, category) {
  if (!displayName) throw new Error("Accessories must be created with a non-empty displayName.");
  if (!UUID) throw new Error("Accessories must be created with a valid UUID.");
  if (!uuid.isValid(UUID)) throw new Error("UUID '" + UUID + "' is not a valid UUID. Try using the provided 'generateUUID' function to create a valid UUID from any arbitrary string, like a serial number.");
github jensweigele / ioBroker.yahka / yahka.homekit-bridge.js View on Github external
THomeKitBridge.prototype.createDevice = function (device) {
        var _this = this;
        var e_2, _a;
        var devName = device.name;
        var deviceID = HAP.uuid.generate(this.config.ident + ':' + devName);
        var i = 0;
        while (this.bridgeObject.bridgedAccessories.some(function (a) { return a.UUID == deviceID; })) {
            devName = device.name + '_' + ++i;
            deviceID = HAP.uuid.generate(this.config.ident + ':' + devName);
        }
        this.FLogger.info('adding ' + devName + ' with UUID: ' + deviceID);
        var hapDevice = new HAP.Accessory(devName, deviceID);
        hapDevice.getService(exports.HAPService.AccessoryInformation)
            .setCharacteristic(exports.HAPCharacteristic.Manufacturer, device.manufacturer || 'not configured')
            .setCharacteristic(exports.HAPCharacteristic.Model, device.model || 'not configured')
            .setCharacteristic(exports.HAPCharacteristic.SerialNumber, device.serial || 'not configured');
        hapDevice.on('identify', function (paired, callback) {
            _this.FLogger.debug('device identify');
            callback();
        });
        try {
github jensweigele / ioBroker.yahka / yahka.homekit-ipcamera.js View on Github external
THomeKitIPCamera.prototype.createCameraDevice = function () {
        var _this = this;
        var deviceID = HAP.uuid.generate(this.camConfig.ident + ':' + this.camConfig.name);
        var hapDevice = new HAP.Accessory(this.camConfig.name, deviceID);
        hapDevice.getService(HAPService.AccessoryInformation)
            .setCharacteristic(HAPCharacteristic.Manufacturer, this.camConfig.manufacturer || 'not configured')
            .setCharacteristic(HAPCharacteristic.Model, this.camConfig.model || 'not configured')
            .setCharacteristic(HAPCharacteristic.SerialNumber, this.camConfig.serial || 'not configured');
        hapDevice.on('identify', function (paired, callback) {
            _this.FLogger.debug('camera identify');
            callback();
        });
        hapDevice.cameraSource = this;
        this._camera = hapDevice;
    };
    THomeKitIPCamera.prototype.createCameraControlService = function () {
github jensweigele / ioBroker.yahka / yahka.homekit-ipcamera.js View on Github external
sessionInfo["audio_port"] = targetPort;
            sessionInfo["audio_srtp"] = Buffer.concat([srtp_key, srtp_salt]);
            sessionInfo["audio_ssrc"] = 1;
        }
        var currentAddress = ip.address();
        var addressResp = {
            address: currentAddress
        };
        if (ip.isV4Format(currentAddress)) {
            addressResp["type"] = "v4";
        }
        else {
            addressResp["type"] = "v6";
        }
        response["address"] = addressResp;
        this.pendingSessions[hap_nodejs_1.uuid.unparse(sessionID, 0)] = sessionInfo;
        callback(response);
    };
    THomeKitIPCamera.prototype.handleStreamRequest = function (request) {
github adafruit / adafruit-io-node / cli / homekit.js View on Github external
'use strict';

const Client = require('../client'),
      CLI = require('./index'),
      Yargs = require('yargs'),
      uuid = require('hap-nodejs').uuid,
      storage = require('node-persist'),
      Bridge = require('hap-nodejs').Bridge,
      Accessory = require('hap-nodejs').Accessory,
      inquirer = require('inquirer'),
      Accessories = require('../homekit'),
      crypto = require('crypto');

storage.initSync();


class HomekitCLI extends CLI {

  constructor() {

    super('homekit');
github agrippa1994 / FS20 / devices / steckdose_accessory.js View on Github external
const hap = require("hap-nodejs");

var device = new hap.Accessory('Steckdose', hap.uuid.generate('hap-nodejs:accessories:steckdose'));

device
  .getService(hap.Service.AccessoryInformation)
  .setCharacteristic(hap.Characteristic.Manufacturer, "FS20")
  .setCharacteristic(hap.Characteristic.Model, "Socket")
  .setCharacteristic(hap.Characteristic.SerialNumber, "None");

device.on('identify', function (paired, callback) {
  callback();
});

device
  .addService(hap.Service.Switch, "Steckdose")
  .getCharacteristic(hap.Characteristic.On)
  .on('set', function (value, callback) {
    device.stateChange(value, callback);
github rdmtc / RedMatic-HomeKit / nodes / redmatic-homekit-bridge.js View on Github external
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);
github nfarina / homebridge / lib / server.js View on Github external
var path = require('path');
var fs = require('fs');
var uuid = require("hap-nodejs").uuid;
var accessoryStorage = require('node-persist').create();
var Bridge = require("hap-nodejs").Bridge;
var Accessory = require("hap-nodejs").Accessory;
var Service = require("hap-nodejs").Service;
var Characteristic = require("hap-nodejs").Characteristic;
var AccessoryLoader = require("hap-nodejs").AccessoryLoader;
var once = require("hap-nodejs/lib/util/once").once;
var Plugin = require('./plugin').Plugin;
var User = require('./user').User;
var API = require('./api').API;
var PlatformAccessory = require("./platformAccessory").PlatformAccessory;
var BridgeSetupManager = require("./bridgeSetupManager").BridgeSetupManager;
var log = require("./logger")._system;
var Logger = require('./logger').Logger;
var mac = require("./util/mac");
var chalk = require('chalk');
github mrsharpoblunto / it-gets-the-hose-again / web / lib / valve-accessory.js View on Github external
export default function(valveController) {
    const valveUUID = hap.uuid.generate('hap-nodejs:accessories:valve');

    const valve = new hap.Accessory('Water valve', valveUUID);

    valve
        .getService(hap.Service.AccessoryInformation)
        .setCharacteristic(hap.Characteristic.Manufacturer, config.MANUFACTURER)
        .setCharacteristic(hap.Characteristic.Model, config.MODEL)
        .setCharacteristic(hap.Characteristic.SerialNumber, config.SERIAL);

    valve.on('identify', function(paired, cb) {
        valveController.identify();
        cb();
    });

    valve
        .addService(hap.Service.Switch, 'It gets the hose again')