IoT Agent Node Lib version the issue has been seen with
4.6.0
Bound or port used (API interaction)
Southbound (Devices data API)
NGSI version
NGSIv2
Are you running a container?
Yes, I am using a contaner (Docker, Kubernetes...)
Image type
normal
Expected behaviour you didn't see
When upgrading iot-agent-node-lib from 3.3.4 to 4.6.0
It should correctly updating a device attribute when using iotAgentLib.update(device.name, device.type, "", [ { name: 'value', type: 'number', value: '10' }], device)
iot-agent-node-lib 3.3.4 is still working perfectly
Unexpected behaviour you saw
The payload request made to Orion is perfectly sent but does not contain de requested change on the device attribute
Here's what is sent to Orion in 3.3.4 :
{ op: 'IoTAgentNGSI.Request' } Options: %s {
"url": "http://orion:1026/v2/entities?options=upsert",
"method": "POST",
"headers": {
"fiware-service": "ngeconnect",
"fiware-servicepath": "/"
},
"json": {
"id": "urn:ngsild:TemperatureSensor:CypressDeviceA1A",
"type": "TemperatureSensor",
"value": {
"value": "10",
"type": "number",
"metadata": {
"TimeInstant": {
"type": "DateTime",
"value": "2024-09-30T08:41:12.495Z"
}
}
}
(.........)
}
}
In 4.6.0 the payload is exactly the same but the "value" attribute in the request has disappeared, so the request is sent to Orion but without the updated value on the device. End to end, this leads to having the exact same device in orion as the upsert request did not sent the attribute to update.
I believe this comes from sendUpdateValueNgsi2() in entities-NGSI-v2.js as this function changed a lot between 3.3.4 and 4.6.0.
After some debugging and analysis, it's coming from the line measures = measures.filter((item) => item.name !== currentAttr.object_id && item.name !== currentAttr.name); that removes the measures value. The second part of the filter item.name !== currentAttr.name is going to filter all attributes names that are present in preprocessedAttr but it contains typeInformation.active from originTypeInformation which contains the value attribute...
Steps to reproduce the problem
No response
Configs
environment:
- "IOTA_CB_HOST=orion"
- "IOTA_CB_PORT=1026"
- "IOTA_NORTH_PORT=5005"
- "IOTA_REGISTRY_TYPE=mongodb"
- "IOTA_MONGO_HOST=mongodb"
- "IOTA_MONGO_PORT=27017"
- "IOTA_MONGO_DB=iotagent-json"
- "IOTA_HTTP_PORT=5004"
- "IOTA_PROVIDER_URL=http://localhost:5005"
iot-agent-node-lib config
iotAgentLib.activate({
logLevel: process.env.LOG_LEVEL, // 'info'
ngsiVersion: 'v2',
providerUrl: process.env.EXTERNAL_PROVIDER_URL, // 'http://localhost:5005'
service: process.env.SERVICE_NAME, // 'iotagent'
subservice: process.env.SERVICE_PATH, // '/'
deviceRegistry: {
type: 'mongodb'
},
server:{
port: process.env.NORTH_PORT // '5005'
},
defaultType: "Thing",
types: {},
apiKey: process.env.IOT_AGENT_API_KEY
})
Log output
No response
IoT Agent Node Lib version the issue has been seen with
4.6.0
Bound or port used (API interaction)
Southbound (Devices data API)
NGSI version
NGSIv2
Are you running a container?
Yes, I am using a contaner (Docker, Kubernetes...)
Image type
normal
Expected behaviour you didn't see
When upgrading iot-agent-node-lib from 3.3.4 to 4.6.0
It should correctly updating a device attribute when using
iotAgentLib.update(device.name, device.type, "", [ { name: 'value', type: 'number', value: '10' }], device)iot-agent-node-lib 3.3.4 is still working perfectly
Unexpected behaviour you saw
The payload request made to Orion is perfectly sent but does not contain de requested change on the device attribute
Here's what is sent to Orion in 3.3.4 :
{ op: 'IoTAgentNGSI.Request' } Options: %s { "url": "http://orion:1026/v2/entities?options=upsert", "method": "POST", "headers": { "fiware-service": "ngeconnect", "fiware-servicepath": "/" }, "json": { "id": "urn:ngsild:TemperatureSensor:CypressDeviceA1A", "type": "TemperatureSensor", "value": { "value": "10", "type": "number", "metadata": { "TimeInstant": { "type": "DateTime", "value": "2024-09-30T08:41:12.495Z" } } } (.........) } }In 4.6.0 the payload is exactly the same but the "value" attribute in the request has disappeared, so the request is sent to Orion but without the updated value on the device. End to end, this leads to having the exact same device in orion as the upsert request did not sent the attribute to update.
I believe this comes from
sendUpdateValueNgsi2()inentities-NGSI-v2.jsas this function changed a lot between 3.3.4 and 4.6.0.After some debugging and analysis, it's coming from the line
measures = measures.filter((item) => item.name !== currentAttr.object_id && item.name !== currentAttr.name);that removes the measuresvalue. The second part of the filteritem.name !== currentAttr.nameis going to filter all attributes names that are present inpreprocessedAttrbut it containstypeInformation.activefromoriginTypeInformationwhich contains thevalueattribute...Steps to reproduce the problem
No response
Configs
iot-agent-node-lib config
Log output
No response