How to use the node-tradfri-client.AccessoryTypes.motionSensor function in node-tradfri-client

To help you get started, we’ve selected a few node-tradfri-client 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 thkl / Homematic-Virtual-Interface / plugins / IkeaTradfri / TradfriPlatform.js View on Github external
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

        }
    }
github fvanwijk / tradfri-app / server / api / devices.js View on Github external
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;
}