Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function HuePlatform (log, configJson, homebridge) {
this.log = log
this.api = homebridge
this.packageJson = packageJson
this.configJson = configJson
const my = new homebridgeLib.MyHomeKitTypes(homebridge)
const eve = new homebridgeLib.EveHomeKitTypes(homebridge)
HueBridgeModule.setHomebridge(homebridge, my, eve)
this.config = {
excludeSensorTypes: {},
groups: false,
group0: false,
heartrate: 5,
hosts: [],
lights: false,
lowBattery: 25,
nativeHomeKitLights: true,
nativeHomeKitSensors: true,
nupnp: true,
resetTimeout: 500,
resource: true,
rooms: false,
return this.deviceServices;
}
this.deviceServices = [];
const deviceService = new this.Service.Outlet(this.config.name);
this.deviceServices.push(deviceService);
const onCharacteristic = deviceService.getCharacteristic(this.Characteristic.On)
.on('get', callback => this.getOnOff(this.dpsOnOff, callback))
.on('set', (onOff, callback) => this.setOnOff(this.dpsOnOff, onOff, callback));
const inUseCharacteristic = deviceService.getCharacteristic(this.Characteristic.OutletInUse)
.on('get', this.getInUse.bind(this));
if (this.isMonitoring) {
const Eve = new homebridgeLib.EveHomeKitTypes(this.hb);
deviceService.addOptionalCharacteristic(Eve.Characteristics.Voltage);
deviceService.addOptionalCharacteristic(Eve.Characteristics.ElectricCurrent);
deviceService.addOptionalCharacteristic(Eve.Characteristics.CurrentConsumption);
const voltageCharacteristic = deviceService.getCharacteristic(Eve.Characteristics.Voltage)
.on('get', this.getVoltage.bind(this));
const currentCharacteristic = deviceService.getCharacteristic(Eve.Characteristics.ElectricCurrent)
.on('get', this.getCurrent.bind(this));
const consumptionCharacteristic = deviceService.getCharacteristic(Eve.Characteristics.CurrentConsumption)
.on('get', this.getConsumption.bind(this));
if (this.interval) {
let [totalConsumption, resetTotal] = this.readTotalConsumption();
this.debug('readed totalConsumption & resetTotal', totalConsumption, resetTotal);
deviceService.addOptionalCharacteristic(Eve.Characteristics.TotalConsumption);
const totalConsumptionCharacteristic = deviceService.getCharacteristic(Eve.Characteristics.TotalConsumption)
.on('get', callback => callback(null, totalConsumption));
module.exports = function (homebridge) {
Service = homebridge.hap.Service;
Characteristic = homebridge.hap.Characteristic;
Eve = new homebridgeLib.EveHomeKitTypes(homebridge);
HistoryService = fakegatoHistory(homebridge);
homebridgePath = homebridge.user.storagePath();
homebridge.registerAccessory("homebridge-mqttthing", "mqttthing", makeThing);
}