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

object_id not recognized if is not equal to the name #1621

Open
tzzed opened this issue Jun 20, 2024 · 7 comments
Open

object_id not recognized if is not equal to the name #1621

tzzed opened this issue Jun 20, 2024 · 7 comments

Comments

@tzzed
Copy link

tzzed commented Jun 20, 2024

IoT Agent Node Lib version the issue has been seen with

4.5.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

The measure should be updated in orion CB.

Unexpected behaviour you saw

The payload is not filled.
The iotagent takes only all static_attributes when I have active attribute with object_id: '.1.3.6.1.4.1.6302.2.1.2.1.0' in this format.

this fails

 {
            name: 'psBatteryVoltage',
            type: 'Number',
            object_id: '.1.0.0.1'
 }

this works

 {
            name: 'psBatteryVoltage',
            type: 'Number',
            object_id: 'psBattery'
 }

Steps to reproduce the problem

curl  -iX POST 'http://localhost:5004/iot/json?k=<API_KEY>&i=device001
 -d '{ 
    ".1.0.0.1": 23.5
  }'

in this case the payload is filled by static_attributes only.

Configs

environment:
    - "IOTA_CB_HOST=orion"
    - "IOTA_CB_PORT=1026"
    - "IOTA_NORTH_PORT=4041"
    - "IOTA_REGISTRY_TYPE=mongodb"
    - "IOTA_MONGO_HOST=mongodb"
    - "IOTA_MONGO_PORT=27017"
    - "IOTA_MONGO_DB=iotagent-json"
    - "IOTA_HTTP_PORT=7896"
    - "IOTA_PROVIDER_URL=http://iot-agent:4041"

Log output

time=2024-06-20T09:48:28.428Z | lvl=DEBUG | corr=n/a | trans=n/a | op=IoTAgentNGSI.Request | msg=Options: {
iot-agent  |     "url": "http://orion:1026/v2/entities?options=upsert",
iot-agent  |     "method": "POST",
iot-agent  |     "headers": {
iot-agent  |         "fiware-service": "service",
iot-agent  |         "fiware-servicepath": "/"
iot-agent  |     },
iot-agent  |     "json": {
iot-agent  |         "id": "urn:ngsild:device:4242",
iot-agent  |         "type": "device",
iot-agent  |         "project": {
iot-agent  |             "type": "Text",
iot-agent  |             "value": "1",
iot-agent  |             "metadata": {
iot-agent  |                 "TimeInstant": {
iot-agent  |                     "type": "DateTime",
iot-agent  |                     "value": "2024-06-20T09:48:28.428Z"
iot-agent  |                 }
iot-agent  |             }
iot-agent  |         },
iot-agent  |         "model": {
iot-agent  |             "type": "Text",
iot-agent  |             "value": "device",
iot-agent  |             "metadata": {
iot-agent  |                 "TimeInstant": {
iot-agent  |                     "type": "DateTime",
iot-agent  |                     "value": "2024-06-20T09:48:28.428Z"
iot-agent  |                 }
iot-agent  |             }
iot-agent  |         },
iot-agent  |        
iot-agent  |         "isPhysical": {
iot-agent  |             "type": "Boolean",
iot-agent  |             "value": true,
iot-agent  |             "metadata": {
iot-agent  |                 "TimeInstant": {
iot-agent  |                     "type": "DateTime",
iot-agent  |                     "value": "2024-06-20T09:48:28.428Z"
iot-agent  |                 }
iot-agent  |             }
iot-agent  |         "TimeInstant": {
iot-agent  |             "type": "DateTime",
iot-agent  |             "value": "2024-06-20T09:48:28.428Z"
iot-agent  |         }
iot-agent  |     }
iot-agent  | }
iot-agent  | time=2024-06-20T09:48:28.437Z | lvl=DEBUG | corr=n/a | trans=n/a | op=IoTAgentNGSI.Request | msg=Response ""
iot-agent  | time=2024-06-20T09:48:28.437Z | lvl=INFO | corr=n/a | trans=n/a | op=IoTAgentNGSI.Entities-v2 | msg=Received the following response from the CB: Value updated successfully
@tzzed tzzed added the bug label Jun 20, 2024
@tzzed
Copy link
Author

tzzed commented Jun 20, 2024

The object_id should be equal to the attribute name to work. It was working before.

@tzzed tzzed changed the title object_id does not work in some different format object_id not recognized if is not equal to the name Jun 20, 2024
@AlvaroVega
Copy link
Member

AlvaroVega commented Jun 20, 2024

Using latest version of iotagent-json (3.5.0) and iotagent-node-lib (4.5.0) This worked to me:

curl -iX POST 'http://localhost:7897/iot/json?k=APIKEY1&i=disp1' -H 'Content-Type: application/json' -d '{".1.0.0.1": 24}'

time=2024-06-20T11:16:48.539Z | lvl=DEBUG | corr=77b99dc2-ab82-425a-88b2-6dd534f487aa | trans=77b99dc2-ab82-425a-88b2-6dd534f487aa | op=IoTAgentNGSI.Request | from=n/a | srv=smartcity | subsrv=/ | msg=Options: {
    "url": "http://iot-orion:1026/v2/entities?options=upsert",
    "method": "POST",
    "headers": {
        "fiware-service": "smartcity",
        "fiware-servicepath": "/"
    },
    "json": {
        "id": "thing:disp1",
        "type": "thing",
        "color": {
            "type": "string",
            "value": "blue",
            "metadata": {
                "units": {
                    "type": "text",
                    "value": "cms"
                },
                "TimeInstant": {
                    "type": "DateTime",
                    "value": "2024-06-20T11:16:48.538Z"
                }
            }
        },
        "c": {
            "type": "Text",
            "value": "9",
            "metadata": {
                "TimeInstant": {
                    "type": "DateTime",
                    "value": "2024-06-20T11:16:48.538Z"
                }
            }
        },
        ".1.0.0.1": {
            "type": "Text",
            "value": 23.5,
            "metadata": {
                "TimeInstant": {
                    "type": "DateTime",
                    "value": "2024-06-20T11:16:48.538Z"
                }
            }
        },
        "TimeInstant": {
            "type": "DateTime",
            "value": "2024-06-20T11:16:48.538Z"
        }
    }
} | comp=IoTAgent

Maybe you are using wrong apikey, some previous provisioned device with some config in explicitAttrs... check that.

@tzzed
Copy link
Author

tzzed commented Jun 20, 2024

if I set the "iotagent-node-lib": "^3.4.4", to 3.4.4. With any version of ^4.0.0 the object_id fails

@AlvaroVega
Copy link
Member

@tzzed Which agent and version are you using?

@tzzed
Copy link
Author

tzzed commented Jun 20, 2024

Customized one, but we use the iotagent node lib.

@AlvaroVega
Copy link
Member

IMHO this is the tests which demonstrates with the behavior described is working in iotagent-library: #1622

@fgalan
Copy link
Member

fgalan commented Jun 26, 2024

IMHO this is the tests which demonstrates with the behavior described is working in iotagent-library: #1622

@tzzed could you have a look? Maybe is there some difference between that test case and your case?

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

3 participants