diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 8b1378917..1917fbef0 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1 +1 @@ - +- Fix attribute loss during device update when both name and object_id are defined by filtering only object_id (#1660) \ No newline at end of file diff --git a/lib/services/ngsi/entities-NGSI-v2.js b/lib/services/ngsi/entities-NGSI-v2.js index e180e607a..d39dbedb7 100644 --- a/lib/services/ngsi/entities-NGSI-v2.js +++ b/lib/services/ngsi/entities-NGSI-v2.js @@ -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 && diff --git a/test/functional/testCases.js b/test/functional/testCases.js index b2f850aa5..1411165cf 100644 --- a/test/functional/testCases.js +++ b/test/functional/testCases.js @@ -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: [] @@ -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', @@ -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: { @@ -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 } } }