Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [Metadata support](#metadata-support)
- [NGSI LD data and metadata considerations](#ngsi-ld-data-and-metadata-considerations)
- [Advice on Attribute definitions](#advice-on-attribute-definitions)
- [Using object_id and name at the same time](#using-object_id-and-name-at-the-same-time)
- [Reuse of attribute names](#reuse-of-attribute-names)
- [Reuse of attribute types](#reuse-of-attribute-types)
- [How to specify attribute Units of Measurement](#how-to-specify-attribute-units-of-measurement)
Expand Down Expand Up @@ -489,6 +490,31 @@ Other unrecognised `type` attributes will be passed as NGSI-LD data using the fo

## Advice on Attribute definitions

### Using object_id and name at the same time

In the case a measure includes an object_id and a name that refers to the same attribute the name takes precedence over object_id.

For example, if we have the following provission

```json
{
"name": "psSMDUHPower17",
"type": "Number",
"object_id": "p"
}
```

and the measure is the following

```json
{
"p": 1,
"psSMDUHPower17": 2
}
```

then the attribute at ContextBroker will take value `2`.

### Reuse of attribute names

Check for the existence of the same Attribute on any of the other models and reuse it, if pertinent. Have a look at
Expand Down
71 changes: 71 additions & 0 deletions test/functional/testCases.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,77 @@ const testCases = [
}
]
},
{
describeName: '0021d - Simple group with active attributes with special names in object_id - name overrides object_id',
provision: {
url: 'http://localhost:' + config.iota.server.port + '/iot/services',
method: 'POST',
json: {
services: [
{
resource: '/iot/json',
apikey: globalEnv.apikey,
entity_type: globalEnv.entity_type,
commands: [],
lazy: [],
attributes: [
{
name: 'mainDoorEvent',
type: 'Boolean'
},
{
name: 'psSMDUHPower14',
type: 'Text',
object_id: '.1.3.6.1.4.1.6302.2.1.2.17.1.1.15.1702'
},
{
name: 'psSMDUHPower17',
type: 'Number',
object_id: '.1.3.6.1.4.1.6302.2.1.2.17.1.1.18.1702'
}
],
static_attributes: []
}
]
},
headers: {
'fiware-service': globalEnv.service,
'fiware-servicepath': globalEnv.servicePath
}
},
should: [
{
shouldName:
'A - WHEN sending defined object_ids with special format names in attributes through http IT should send measures to Context Broker preserving value types, name mappings and metadatas',
type: 'single',
measure: {
url: 'http://localhost:' + config.http.port + '/iot/json',
method: 'POST',
qs: {
i: globalEnv.deviceId,
k: globalEnv.apikey
},
json: {
'.1.3.6.1.4.1.6302.2.1.2.17.1.1.18.1702': 3,
mainDoorEvent: 1,
psSMDUHPower17: 2
}
},
expectation: {
id: globalEnv.entity_name,
type: globalEnv.entity_type,
mainDoorEvent: {
type: 'Boolean',
value: 1
},
psSMDUHPower17: {
type: 'Number',
value: 2
}
}
}
]
},
{
describeName: '0022 - Simple group with active attributes and multimeasures',
provision: {
Expand Down
Loading