Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
that.trApiLightbulbs[device.instanceId] = device
that.log.info('new Lamp %s found', device.instanceId)
var tdevice = new TradfriDevice(that, device.instanceId) // (plugin, id)
that.mappedDevices[device.instanceId] = tdevice
} else {
// update the node-tradfri-client lights api object
that.trApiLightbulbs[device.instanceId] = device
that.log.debug('update Lamp %s', device.instanceId)
}
} else if (device.type === AccessoryTypes.remote) {
// fill and update the node-tradfri-client remote api object
// remember it
} else if (device.type === AccessoryTypes.motionSensor) {
// fill and update the node-tradfri-client motionsensor api object
// remember it
} else if (device.type === AccessoryTypes.blind) {
if (that.trApiBlinds[device.instanceId] === undefined) {
that.trApiBlinds[device.instanceId] = device
that.log.info('new Blind %s found', device.instanceId)
var tdevice = new TradfriBlind(that, device.instanceId) // (plugin, id)
that.mappedDevices[device.instanceId] = tdevice
}
} else {
// remember it
}
}
function marshallDevice({ client, ...device }) {
switch (device.type) {
case AccessoryTypes.motionSensor:
device.sensorList = device.sensorList.map(({ client, ...sensor }) => sensor);
break;
case AccessoryTypes.lightbulb:
case 1:
device.lightList = (device.lightList || []).map(({ client, _accessory, ...light }) => light);
break;
case AccessoryTypes.remote:
device.switchList = device.switchList.map(({ client, ...remote }) => remote);
break;
default:
console.log('Not mapped', device);
}
return device;
}