Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
minValue: 0,
maxValue: 1,
minStep: 1,
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
});
this.stateCharacteristic.value = 0;
this.service.addCharacteristic(this.stateCharacteristic);
this.versionCharacteristic = new Characteristic("Version", "FD9FE4CC-D06F-4FFE-96C6-595D464E1026", {
format: Characteristic.Formats.STRING,
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
});
this.versionCharacteristic.value = "1.0";
this.service.addCharacteristic(this.versionCharacteristic);
this.controlPointCharacteristic = new Characteristic("Control Point", "5819A4C2-E1B0-4C9D-B761-3EB1AFF43073", {
format: Characteristic.Formats.DATA,
perms: [Characteristic.Perms.READ, Characteristic.Perms.WRITE, Characteristic.Perms.NOTIFY]
})
this.controlPointCharacteristic.on('get', function(callback, context) {
this.handleReadRequest(callback, context);
}.bind(this));
this.controlPointCharacteristic.on('set', function(newValue, callback, context) {
this.handleWriteRequest(newValue, callback, context);
}.bind(this));
this.controlPointCharacteristic.value = null;
this.service.addCharacteristic(this.controlPointCharacteristic);
}
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')
.getCharacteristic(hap.Characteristic.On)
.on('set', function(value, cb) {
valveController.setOpen(!!value, config.HOMEKIT_USER, cb);
});
valve
.getService(hap.Service.Switch)
.getCharacteristic(hap.Characteristic.On)
.on('get', function(cb) {
cb(valveController.getOpen() ? 1 : 0);
});
valveController.on('setOpen', function({
open, source
}) {
if (source !== config.HOMEKIT_USER) {
valve
const DeviceIp = function () {
const char = new Characteristic('IP Address', DeviceIpUUID);
char.setProps({
format: Characteristic.Formats.STRING,
perms: [Characteristic.Perms.READ],
});
char.value = char.getDefaultValue();
return char;
};
DeviceIp.UUID = DeviceIpUUID;
function BridgeSetupManager() {
this.session;
this.service = new Service(null, "49FB9D4D-0FEA-4BF1-8FA6-E7B18AB86DCE");
this.stateCharacteristic = new Characteristic("State", "77474A2F-FA98-485E-97BE-4762458774D8", {
format: Characteristic.Formats.UINT8,
minValue: 0,
maxValue: 1,
minStep: 1,
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
});
this.stateCharacteristic.value = 0;
this.service.addCharacteristic(this.stateCharacteristic);
this.versionCharacteristic = new Characteristic("Version", "FD9FE4CC-D06F-4FFE-96C6-595D464E1026", {
format: Characteristic.Formats.STRING,
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
});
this.versionCharacteristic.value = "1.0";
this.service.addCharacteristic(this.versionCharacteristic);
const DeviceId = function () {
const char = new Characteristic('ID', DeviceIdUUID);
char.setProps({
format: Characteristic.Formats.STRING,
perms: [Characteristic.Perms.READ],
});
char.value = char.getDefaultValue();
return char;
};
DeviceId.UUID = DeviceIdUUID;
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')
.getCharacteristic(hap.Characteristic.On)
.on('set', function(value, cb) {
valveController.setOpen(!!value, config.HOMEKIT_USER, cb);
});
valve
const DeviceType = function () {
const char = new Characteristic('Type', DeviceTypeUUID);
char.setProps({
format: Characteristic.Formats.STRING,
perms: [Characteristic.Perms.READ],
});
char.value = char.getDefaultValue();
return char;
};
DeviceType.UUID = DeviceTypeUUID;
function BridgeSetupManager() {
this.session;
this.service = new Service(null, "49FB9D4D-0FEA-4BF1-8FA6-E7B18AB86DCE");
this.stateCharacteristic = new Characteristic("State", "77474A2F-FA98-485E-97BE-4762458774D8", {
format: Characteristic.Formats.UINT8,
minValue: 0,
maxValue: 1,
minStep: 1,
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
});
this.stateCharacteristic.value = 0;
this.service.addCharacteristic(this.stateCharacteristic);
this.versionCharacteristic = new Characteristic("Version", "FD9FE4CC-D06F-4FFE-96C6-595D464E1026", {
format: Characteristic.Formats.STRING,
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
});
this.versionCharacteristic.value = "1.0";
this.service.addCharacteristic(this.versionCharacteristic);
this.controlPointCharacteristic = new Characteristic("Control Point", "5819A4C2-E1B0-4C9D-B761-3EB1AFF43073", {
format: Characteristic.Formats.DATA,
perms: [Characteristic.Perms.READ, Characteristic.Perms.WRITE, Characteristic.Perms.NOTIFY]
})
this.controlPointCharacteristic.on('get', function(callback, context) {
this.handleReadRequest(callback, context);
}.bind(this));
this.controlPointCharacteristic.on('set', function(newValue, callback, context) {
this.handleWriteRequest(newValue, callback, context);
}.bind(this));
this.UUID = data.UUID;
this.category = data.category;
this.context = data.context;
this.reachable = false;
var services = [];
var servicesMap = {};
for (var index in data.services) {
var service = data.services[index];
var hapService = new Service(service.displayName, service.UUID, service.subtype);
var characteristics = [];
for (var cIndex in service.characteristics) {
var characteristic = service.characteristics[cIndex];
var hapCharacteristic = new Characteristic(characteristic.displayName, characteristic.UUID, characteristic.props);
hapCharacteristic.eventOnlyCharacteristic = characteristic.eventOnlyCharacteristic;
hapCharacteristic.value = characteristic.value;
characteristics.push(hapCharacteristic);
}
hapService._sideloadCharacteristics(characteristics);
servicesMap[service.UUID + (service.subtype || "")] = hapService;
services.push(hapService);
}
if (data.linkedServices) {
var linkedServices = data.linkedServices;
for (var key in linkedServices) {
var primaryService = servicesMap[key];
if (primaryService) {