This file displays IoT Agent datamodel stored in the MongoDB database.
The collection 'devices' sotres information about the iotagent devices
Fields:
- _ID ObjectId: unique object ID used by mongoDB
- id string: id of device
- type string: entity type used
- name string: entity name used
- lazy array: array of lazy attributes of device
- active array: array of active attributes of device
- commands array: array of commands of device
- apikey string: apikey of device
- endpoint string: endpoint used by push commands when http
- resource string: iotagent resource
- protocol string: device protocol (JSON)
- transport string: device transport (http, mqtt, amqp)
- staticAttributes array: array of static attributes of device
- subscriptions array: subscriptions of device
- service string: service which the device belongs to
- subservice string: subservice which the rule belongs to.
- polling boolean: if device uses polling for commands
- timezone string: timezone of device
- timestamp boolean timestamp of device
- registrationId string: registrationId of device
- internalId string: internalId of device
- creationDate date: creationDate of device
- internalAttributes object: internalAttributes of device
- autoprovision boolean: if device support autoprovision
- explicitAttrs enum:
- ngsiVersion string: ngsi version used by device
- payloadType string: payloadType used by device
- useCBflowControl boolean: if CBFlow will be used by device when updates in CB
- storeLastMeasure boolean: if device store last measure received
- lastMeasure object: last measure received by device
- oldCtxt object: jexl Ctxt used at last measure
Example:
{
"_id": {
"$oid": "680b4b338d0e60f98718a8b2"
},
"lazy": [],
"commands": [
{
"name": "reset",
"type": "command",
"value": "",
"expression": "{ set: brand + '_' + reset }",
"object_id": "reset"
},
{
"name": "cmd1",
"type": "command",
"value": "",
"expression": "brand",
"object_id": "cmd1"
},
{
"name": "cmd2",
"type": "command",
"value": "",
"expression": "reset",
"object_id": "cmd2"
}
],
"staticAttributes": [],
"creationDate": {
"$date": {
"$numberLong": "1745570611491"
}
},
"id": "disp",
"type": "thing",
"name": "thing:disp",
"service": "smartcity",
"subservice": "/",
"registrationId": "680b4b33956cc1ed0205840a",
"apikey": "APIKEY",
"protocol": "IoTA-JSON",
"transport": "HTTP",
"polling": false,
"active": [],
"oldCtxt": {
"level": "33",
"brand": "o1",
"id": "disp",
"type": "thing",
"service": "smartcity",
"subservice": "/",
"entity_name": "thing:disp",
"TimeInstant": "2025-04-25T08:43:31.496Z"
},
"subscriptions": []
}The collection groups' stores information about the iotagent groups of devices
Fields:
- _ID ObjectId: unique object ID used by mongoDB
- url string: url used by group of devices
- resource string: iotagent resource
- apikey string: apikey used by group of devices
- endpoint string: endpoint used by push commands when http
- transport string: group transport (http, mqtt, amqp)
- type string: entity type used
- service string: service which the group of device belongs to
- subservice string: subservice which the group of devices belongs to
- description string: description of group of devices
- trust string: keystone trust id used when devices of this group request to CB
- cbHost string: CB endpoint used by devices of this group
- timezone string: timezone used by group of devices
- timestamp boolean: timestamp of group
- commands array: array of commands of device group
- staticAttributes array: array of static attributes of device group
- lazy array: array of lazy attributes of device group
- attributes array: array of active attributes of device group
- internalAttributes array: array of internal attributes used by devices of group
- autoprovision boolean: if devices of group supports autoprovision
- explicitAttrs enum: explicit attributes configuration used by devices of group
- defaultEntityNameConjunction string:
- ngsiVersion string: ngsi version used by devices of group
- entityNameExp string: entity name expression used by devics of group
- payloadType string: payloadType used by devices of group
- useCBflowControl boolean: payloadType used by device group
- storeLastMeasure boolean: if devices of group store last measure received
Example:
{
"_id": {
"$oid": "67a1e6447ae8b4ba4478f019"
},
"commands": [
{
"name": "reset",
"type": "command",
"value": "",
"expression": "{ set: brand + '_' + reset }"
},
{
"name": "cmd1",
"type": "command",
"value": "",
"expression": "brand"
},
{
"name": "cmd2",
"type": "command",
"value": "",
"expression": "reset"
}
],
"staticAttributes": [
{
"name": "brand",
"type": "Text",
"value": "o1",
"metadata": {}
}
],
"attributes": [],
"resource": "/iot/json",
"apikey": "APIKEY",
"type": "thing",
"service": "smartcity",
"subservice": "/",
"description": "miJSON",
"timestamp": true,
"internalAttributes": [],
"lazy": [],
"transport": "HTTP",
"endpoint": "'https://eoykcmmm.m.pipedream.net' + '/' + service + '/' + subservice + '/' + id + '/' + type"
}The collection 'commands' stores information about the commands
Fields:
- _ID ObjectId: unique object ID used by mongoDB
- deviceId string: device ID of the device
- type string: type of the command
- name string: name of the command
- value object: value of the command
- service string: service which the device command belongs to
- subservice string: subservice which the device command belongs to
- execTs date: related with new commands functionality (stored but not yet in use)
- status string: related with new commands functionality (stored but not yet in use)
- info string: related with new commands functionality (stored but not yet in use)
- onDelivered Object: related with new commands functionality (stored but not yet in use)
- onOk: Object: related with new commands functionality (stored but not yet in use)
- onError Object: related with new commands functionality (stored but not yet in use)
- onInfo Object: related with new commands functionality (stored but not yet in use)
- cmdExecution Boolean_: related with new commands functionality (stored but not yet in use)
- dateExpiration: { type: Date }: related with new commands functionality (stored but not yet in use)
- creationDate date: creation date of command
Example:
{
"_id": {
"$oid": "680b4b538d0e60f98718a8eb"
},
"creationDate": {
"$date": {
"$numberLong": "1745570643252"
}
},
"name": "cmd1",
"type": "command",
"value": "on",
"deviceId": "disp3",
"service": "smartcity",
"subservice": "/"
}An index guarantees that every device is identified by the tuple (service, subservice, apikey, id)
The index is created/ensured when iotagent starts, but it can be created from a mongoDB shell with
db.devices.ensureIndex({ service: 1, subservice: 1, apikey: 1, id: 1 }, { unique: true });An index guarantees that every group is identified by the tuple (apikey, resource)
The index is created/ensured when iotagent starts, but it can be created from a mongoDB shell with
db.groups.ensureIndex({ apikey: 1, resource: 1 }, { unique: true });None index is defined