telefonicaid / telefonicaid/iotagent-node-lib

Some data are not reported to Orion when updating a device

Open
#1,660 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug NGSIv2
Dominant language
JavaScript
Stars
62
Forks
90
Avg merge
2h 35m
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in entities-NGSI-v2.js at sendUpdateValueNgsi2() and inspect how preprocessedAttr and originTypeInformation affect the measures filter. Compare the 3.3.4 and 4.6.0 behavior using the shown update call; done means the generated Orion NGSIv2 payload retains the value attribute and updates the device.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.