diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index e69de29bb..051ef991d 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -0,0 +1 @@ +- Fix attribute loss during device update when both name and object_id are defined by filtering only object_id (#1660) 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..7dec4b0a4 100644 --- a/test/functional/testCases.js +++ b/test/functional/testCases.js @@ -591,6 +591,81 @@ const testCases = [ } ] }, + { + describeName: '0021c - Simple group with active attributes with special names in 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, + psSMDUHPower14: 2 + } + }, + expectation: { + id: globalEnv.entity_name, + type: globalEnv.entity_type, + mainDoorEvent: { + type: 'Boolean', + value: 1 + }, + psSMDUHPower17: { + type: 'Number', + value: 3 + }, + psSMDUHPower14: { + type: 'Text', + value: 2 + } + } + } + ] + }, { describeName: '0022 - Simple group with active attributes and multimeasures', provision: {