Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/include entity id and type as measures when ngsi payload #807

Merged
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Fix: include entity id and entity type as measure value when measure is an ngsi (both NGSIv2 and NGSI-LD) payload

3 changes: 1 addition & 2 deletions docs/usermanual.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ Examples of these `ngsiv2` payloads are the following ones:
}
```


Example of these `ngsild` payloads are the following ones:

(1) NGSI-LD entities array format:
Expand Down Expand Up @@ -212,7 +211,7 @@ Example of these `ngsild` payloads are the following ones:
},
...
]
````
```

(2) NGSI-LD single entity format:

Expand Down
5 changes: 3 additions & 2 deletions lib/commonBindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ function extractAttributes(device, current, payloadType) {
for (const k in entity) {
if (entity.hasOwnProperty(k)) {
if (['id', 'type'].includes(k)) {
// Include ngsi id and type as measures
// Include ngsi id and type as measures by inserting here as is
// and later in iota-node-lib sendUpdateValueNgsi2 rename as measure_X
valuesEntity.push({
name: constants.NGSI + k,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NGSI constant should be removed from constant.js file, shouldn't it?

name: k,
type: guessType(k, device, null),
value: entity[k]
});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/ngsiv2/contextRequests/ngsildPayloadMeasure.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"id": "Second MQTT Device",
"type": "AnMQTTDevice",
"ngsi_id": {
"measure_id": {
"type": "string",
"value": "urn:ngsi-ld:ParkingSpot:santander:daoiz_velarde_1_5:3"
},
"ngsi_type": {
"measure_type": {
"type": "string",
"value": "ParkingSpot"
},
Expand Down
4 changes: 2 additions & 2 deletions test/unit/ngsiv2/contextRequests/ngsildPayloadMeasure2.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"id": "Second MQTT Device",
"type": "AnMQTTDevice",
"ngsi_id": {
"measure_id": {
"type": "string",
"value": "urn:ngsi-ld:ParkingSpot:santander:reyes_magos_1_1:1"
},
"ngsi_type": {
"measure_type": {
"type": "string",
"value": "ParkingSpot"
},
Expand Down
4 changes: 2 additions & 2 deletions test/unit/ngsiv2/contextRequests/ngsiv2PayloadMeasure.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"id":"Second MQTT Device",
"type":"AnMQTTDevice",
"ngsi_id": {
"measure_id": {
"type": "string",
"value": "urn:ngsiv2:Streetlight:Streetlight-Mylightpoint-2"
},
"ngsi_type": {
"measure_type": {
"type": "string",
"value": "Streetlight"
},
Expand Down
4 changes: 2 additions & 2 deletions test/unit/ngsiv2/contextRequests/ngsiv2PayloadMeasure2.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"id": "Second MQTT Device",
"type": "AnMQTTDevice",
"ngsi_id": {
"measure_id": {
"type": "string",
"value": "urn:ngsiv2:Streetlight:Streetlight-Mylightpoint-3"
},
"ngsi_type": {
"measure_type": {
"type": "string",
"value": "Streetlight"
},
Expand Down
Loading