Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some data are not reported to Orion when updating a device #1660

Open
GuillaumeOd opened this issue Sep 30, 2024 · 0 comments
Open

Some data are not reported to Orion when updating a device #1660

GuillaumeOd opened this issue Sep 30, 2024 · 0 comments

Comments

@GuillaumeOd
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant