Skip to content

Commit

Permalink
fix: attribute loss when updating entity
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeOd authored and GuillaumeOdile committed Nov 14, 2024
1 parent 518d322 commit d9e6fdf
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/services/ngsi/entities-NGSI-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation,
}
//remove measures that has been shadowed by an alias (some may be left and managed later)
//Maybe we must filter object_id if there is name == object_id
measures = measures.filter((item) => item.name !== currentAttr.object_id && item.name !== currentAttr.name);
measures = measures.filter((item) => item.name !== currentAttr.object_id);

if (
currentAttr.expression !== undefined &&
Expand Down
40 changes: 40 additions & 0 deletions test/functional/testCases.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,11 @@ const testCases = [
object_id: '.1.0.0.1',
name: 'psBatteryVoltage',
type: 'Number'
},
{
object_id: 'f_dt',
name: 'fireDetectionThreshold',
type: 'Number'
}
],
static_attributes: []
Expand Down Expand Up @@ -588,6 +593,41 @@ const testCases = [
value: 23.5
}
}
},
{
shouldName:
'A - WHEN sending defined measures by attribute names 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: {
a: false,
fireDetectionThreshold: 10
}
},
expectation: {
id: globalEnv.entity_name,
type: globalEnv.entity_type,
attr_a: {
value: false,
type: 'Boolean',
metadata: {
accuracy: {
value: 0.8,
type: 'Float'
}
}
},
fireDetectionThreshold: {
type: 'Number',
value: 10
}
}
}
]
},
Expand Down

0 comments on commit d9e6fdf

Please sign in to comment.