Official Plugins (Kuzzle v2.x)
Device Manager v1.x
2

This plugin is part of the Kuzzle Enterprise Plan. If you are interested, please contact us.

copyToAsset #

Build the measures property that will be persisted in the asset document.

By default this method will copy the measures with device and qos information.

Copied to clipboard!
copyToAsset (device: Device, request: KuzzleRequest): Promise<AssetMeasures>

Arguments Type Description
device
Device
Device document
request
KuzzleRequest
Original request

Returns #

Returns a promise resolving to an AssetMeasures.

Usage #

Copied to clipboard!
import { KuzzleRequest } from 'kuzzle';
import { Decoder, AssetMeasures } from 'kuzzle-plugin-device-manager';

class KarakoyDecoder extends Decoder {
  // [...]
  async copyToAsset (device: Device): Promise<AssetMeasures> {
    const measures = {};

    for (const [measureType, measure] of Object.entries(device._source.measures)) {
      measures[measureType] = {
        id: device._id,
        model: device._source.model,
        reference: device._source.reference,
        ...measure,
        qos: device._source.qos,
      };
    }

    return measures;
  }
}

This is the default code for the copyToAsset method.