Skip to content
Closed
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
2 changes: 1 addition & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@

- Fix attribute loss during device update when both name and object_id are defined by filtering only object_id (#1660)
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 @@ -467,7 +467,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
29 changes: 27 additions & 2 deletions test/functional/testCases.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,16 @@ const testCases = [
object_id: '.1.0.0.1',
name: 'psBatteryVoltage',
type: 'Number'
},
{
object_id: 'fdt',
name: 'fireDetectionThreshold',
type: 'Number'
},
{
object_id: 'fireDetectionThreshold3',
name: 'fireDetectionThreshold3',
type: 'Number'
}
],
static_attributes: []
Expand All @@ -556,7 +566,7 @@ const testCases = [
should: [
{
shouldName:
'A - WHEN sending defined object_ids with special format names (measures) through http IT should send measures to Context Broker preserving value types, name mappings and metadatas',
'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',
Expand All @@ -567,7 +577,10 @@ const testCases = [
},
json: {
a: false,
'.1.0.0.1': 23.5
'.1.0.0.1': 23.5,
fdt: 10,
fireDetectionThreshold2: 20,
fireDetectionThreshold3: 30
}
},
expectation: {
Expand All @@ -586,6 +599,18 @@ const testCases = [
psBatteryVoltage: {
type: 'Number',
value: 23.5
},
fireDetectionThreshold: {
type: 'Number',
value: 10
},
fireDetectionThreshold2: {
type: 'Text',
value: 20
},
fireDetectionThreshold3: {
type: 'Number',
value: 30
}
}
}
Expand Down