Models #
In order to model a use case, it is possible to define models of sensors and assets that will be used when creating digital twins.
Each sensor or asset is an instance of a previously defined model.
Models can be defined upstream through the backend framework but also dynamically using the API.
Sensor Model #
A sensor model contains the following information:
model
: model namemeasures
: received measurementsdecoder
: (optional) instance of a [Decoder] to normalize the datametadataMappings
: (optional) metadata mappings (See Collection Mappings)defaultMetadata
: (optional) default metadata values
It is possible to create new models on the Kuzzle IoT Platform using either:
- the API through the action
device-manager/models:writeDevice
- the framework with the method
deviceManager.models.registerDevice
Example: declaration of a model via API
import {
ApiModelWriteDeviceRequest,
ApiModelWriteDeviceResult,
} from "kuzzle-device-manager-types";
(await sdk.query) < ApiModelWriteDeviceRequest,
ApiModelWriteDeviceResult >
{
controller: "device-manager/models",
action: "writeDevice",
body: {
model: "Enginko",
measurements: [
{ name: "temperatureInternal", type: "temperature" },
{ name: "temperatureExternal", type: "temperature" },
],
},
};
The API also allows to:
- list available models
device-manager/models:listDevices
- get a model
device-manager/models:getDevices
Asset Model #
Unlike sensors and metrics which are available for all engine groups, asset models are specific to a particular engine group.
An asset model contains the following information:
model
: model nameengineGroup
: engine group to which the model belongs.measures
: received measurementsmetadataMappings
: (optional) metadata mappings (See Collection Mappings)defaultMetadata
: (optional) default metadata values
It is possible to create new models on the Kuzzle IoT Platform using either:
- the API through the
device-manager/models:writeAsset
action - the framework with the method
deviceManager/models.registerAsset
Example: declaration of a model via API
import {
ApiModelWriteAssetRequest,
ApiModelWriteAssetResult,
} from "kuzzle-device-manager-types";
(await sdk.query) < ApiModelWriteAssetRequest,
ApiModelWriteAssetResult >
{
controller: "device-manager/models",
action: "writeAsset",
engineGroup: "asset_tracking",
body: {
model: "Container",
measurements: [
{ name: "temperatureInternal", type: "temperature" },
{ name: "temperatureExternal", type: "temperature" },
],
},
};
The API also allows to:
- list available models
device-manager/models:listAssets
- get a model
device-manager/models:getAssets