Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getServices: function() {
// you can OPTIONALLY create an information service if you wish to override
// the default values for things like serial number, model, etc.
var informationService = new Service.AccessoryInformation();
informationService
.setCharacteristic(Characteristic.Manufacturer, "HTTP Manufacturer")
.setCharacteristic(Characteristic.Model, "HTTP Model")
.setCharacteristic(Characteristic.SerialNumber, "HTTP Serial Number");
var lightbulbService = new Service.Lightbulb();
lightbulbService
.getCharacteristic(Characteristic.On)
.on('set', this.setPowerState.bind(this));
lightbulbService
.addCharacteristic(new Characteristic.Brightness())
.on('set', this.setBrightness.bind(this));
return [informationService, lightbulbService];
}
};
if (finished === 4) {
this.updatingFromOpenHAB = false;
}
}.bind(this)
);
// set saturation
this.getCharacteristic(Characteristic.Saturation).setValue(saturation,
function() { // callback to signal us iOS did process the update
finished++;
if (finished === 4) {
this.updatingFromOpenHAB = false;
}
}.bind(this)
);
// update ON/OFF state
this.getCharacteristic(Characteristic.On).setValue(power,
function() { // callback to signal us iOS did process the update
finished++;
if (finished === 4) {
this.updatingFromOpenHAB = false;
}
}.bind(this)
);
};
const outlet = new Accessory(switchConfig.name, outletUUID);
outlet
.getService(Service.AccessoryInformation)
.setCharacteristic(Characteristic.Manufacturer, 'HALBERT')
.setCharacteristic(Characteristic.Model, `${switchConfig.type}-${switchConfig.protocol}-switch`)
.setCharacteristic(Characteristic.SerialNumber, switchConfig.id);
outlet.on('identify', (paired, callback) => {
console.logger.info(`${switchConfig.name} was identified. Paired: ${paired}.`);
callback();
});
outlet
.addService(Service.Outlet, switchConfig.name)
.getCharacteristic(Characteristic.On)
.on('set', (value, callback) => {
const action = value
? 'switch.on'
: 'switch.off';
runAction(action, {
switchId: switchConfig.id
});
callback();
});
outlet
.getService(Service.Outlet)
.getCharacteristic(Characteristic.On)
.on('get', (callback) => {
getServices: function() {
var informationService = new Service.AccessoryInformation();
informationService
.setCharacteristic(Characteristic.Manufacturer, "MPD")
.setCharacteristic(Characteristic.Model, "MPD Client")
.setCharacteristic(Characteristic.SerialNumber, "81536334");
var switchService = new Service.Switch();
switchService.getCharacteristic(Characteristic.On)
.on('get', this.getPowerState.bind(this))
.on('set', this.setPowerState.bind(this));
return [informationService, switchService];
}
};
WeMoAccessory.prototype.getServices = function() {
if (this.service == "Switch") {
var switchService = new Service.Switch(this.name);
switchService
.getCharacteristic(Characteristic.On)
.on('get', this.getPowerOn.bind(this))
.on('set', this.setPowerOn.bind(this));
return [switchService];
}
else if (this.service == "GarageDoor") {
var garageDoorService = new Service.GarageDoorOpener("Garage Door Opener");
garageDoorService
.getCharacteristic(Characteristic.TargetDoorState)
.on('set', this.setTargetDoorState.bind(this));
return [garageDoorService];
}
else if (this.service == "Light") {
var lightbulbService = new Service.Lightbulb(this.name);
getServices: function() {
var switchService = new Service.Switch(this.name);
var informationService = new Service.AccessoryInformation();
informationService
.setCharacteristic(Characteristic.Manufacturer, this.manufacturer)
.setCharacteristic(Characteristic.Model, this.model_name)
.setCharacteristic(Characteristic.SerialNumber, this.id);
switchService
.getCharacteristic(Characteristic.On)
.on('set', this.setPowerState.bind(this));
return [informationService, switchService];
}
}
buildAccessory(state) {
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(state === 'ON');
charactersiticOnOff.on('set', this.updateOpenHabItem.bind(this));
charactersiticOnOff.on('get', this.readOpenHabPowerState.bind(this));
return accessory;
};
getServices: function() {
var informationService = new Service.AccessoryInformation();
informationService
.setCharacteristic(Characteristic.Manufacturer, "MiLight")
.setCharacteristic(Characteristic.Model, this.type)
.setCharacteristic(Characteristic.SerialNumber, "MILIGHT12345");
var lightbulbService = new Service.Lightbulb();
lightbulbService
.getCharacteristic(Characteristic.On)
.on('set', this.setPowerState.bind(this));
lightbulbService
.addCharacteristic(new Characteristic.Brightness())
.on('set', this.setBrightness.bind(this));
lightbulbService
.addCharacteristic(new Characteristic.Hue())
.on('set', this.setHue.bind(this));
return [informationService, lightbulbService];
}
};
ISYOutletAccessory.prototype.getServices = function() {
var informationService = new Service.AccessoryInformation();
informationService
.setCharacteristic(Characteristic.Manufacturer, "SmartHome")
.setCharacteristic(Characteristic.Model, this.device.deviceFriendlyName)
.setCharacteristic(Characteristic.SerialNumber, this.device.address);
var outletService = new Service.Outlet();
this.outletService = outletService;
this.informationService = informationService;
outletService
.getCharacteristic(Characteristic.On)
.on('set', this.setOutletState.bind(this));
outletService
.getCharacteristic(Characteristic.On)
.on('get', this.getOutletState.bind(this));
outletService
.getCharacteristic(Characteristic.OutletInUse)
.on('get', this.getOutletInUseState.bind(this));
return [informationService, outletService];
}
outlet
.addService(Service.Outlet, switchConfig.name)
.getCharacteristic(Characteristic.On)
.on('set', (value, callback) => {
const action = value ? 'switch.on' : 'switch.off';
runAction(action, {
switchId: switchConfig.id
});
callback();
});
outlet
.getService(Service.Outlet)
.getCharacteristic(Characteristic.On)
.on('get', callback => {
callback(null, getState(`switch_${switchConfig.id}`).state);
});
return outlet;
}
};