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

Attributes name & static attributes not mapped in Orion when inserted in the Device provisioning phase #832

Closed
ludilorenz opened this issue May 17, 2024 · 6 comments

Comments

@ludilorenz
Copy link

IoT Agent JSON version the issue has been seen with

3.4.0-next

Bound or port used (API interaction)

Northbound (Provision API and NGSI Interactions)

NGSI version

NGSIv2, NGSI-LD

Are you running a container?

Yes, I am using a contaner (Docker, Kubernetes...)

Image type

normal

Expected behaviour you didn't see

Define static attributes and a name mapping for non-static attributes in the provisioning phase of a device, and subsequently find this information within Orion when retrieving the entity created.

Unexpected behaviour you saw

When I retrieve the entity from Orion, the static attributes or name mapping I have defined are not present. The informations are present correctly if the static attributes and name mapping are defined in service group provisioning.

Steps to reproduce the problem

curl --location 'http://localhost:4041/iot/services' \
--header 'Content-Type: application/json' \
--header 'fiware-service: test' \
--header 'fiware-servicepath: /test_path' \
--data '{
 "services": [
   {
    "apikey":      "testService",
    "cbroker":     "http://orion:1026",
    "entity_type": "Thing",
    "resource":    "/iot/json"
   }
 ]
}'
curl --location 'http://localhost:4041/iot/devices' \
--header 'Content-Type: application/json' \
--header 'fiware-service: test' \
--header 'fiware-servicepath: /test_path' \
--data '{
 "devices": [
    {
        "device_id": "testDevice",
        "entity_name": "testDevice",
        "entity_type": "Thing",
        "attributes": [
            { "object_id":"attribute" ,"name": "mapped_attribute"}
        ],
        "static_attributes": [
            {"name": "TEST_STATIC_ATTRIBUTE", "type":"Property", "value":"TEST"}
        ]
    }
 ]
}'
curl --location 'http://localhost:7896/iot/json?k=testService&i=testDevice' \
--header 'Content-Type: application/json' \
--data '{
    "attribute":{
        "a": 15,
        "b": "testData",
        "c": false
    }
}'
curl --location 'http://localhost:1026/v2/entities/Thing:testDevice' \
--header 'fiware-service: test' \
--header 'fiware-servicepath: /test_path'

Configs

    environment:
      - IOTA_CB_HOST=orion
      - IOTA_CB_PORT=1026
      - IOTA_NORTH_PORT=4041
      - IOTA_REGISTRY_TYPE=mongodb
      - IOTA_TIMESTAMP=true
      - IOTA_CB_NGSI_VERSION=v2
      - IOTA_AUTOCAST=true
      - IOTA_MONGO_HOST=mongodb
      - IOTA_MONGO_PORT=27017
      - IOTA_MONGO_DB=iotagent-json-v2
      - IOTA_HTTP_PORT=7896
      - IOTA_PROVIDER_URL=http://iot-agent-v2:4041
      - IOTA_DEFAULT_RESOURCE=/iot/json

Log output

No response

@vivekNEC
Copy link

vivekNEC commented May 29, 2024

Hi, @ludilorenz and @fgalan I would like to contribute to this issue.

Please confirm if the expected response from Orion is correct:

{
    "id": "testDevice",
    "type": "Thing",
    "TEST_STATIC_ATTRIBUTE": {
        "type": "Property",
        "value": "TEST",
        "metadata": {
            "TimeInstant": {
                "type": "DateTime",
                "value": "2024-05-27T11:24:41.396Z"
            }
        }
    },
    "TimeInstant": {
        "type": "DateTime",
        "value": "2024-05-27T11:24:41.396Z",
        "metadata": {}
    },
    "mapped_attribute": {
        "type": "StructuredValue",
        "value": {
            "a": 15,
            "b": "testData",
            "c": false
        },
        "metadata": {
            "TimeInstant": {
                "type": "DateTime",
                "value": "2024-05-27T11:24:41.396Z"
            }
        }
    }
}

Please let me know if this expected response is correct. Thank you!

@ludilorenz
Copy link
Author

Hi, @ludilorenz and @fgalan I would like to contribute to this issue.

Please confirm if the expected response from Orion is correct:

{ "id": "testDevice", "type": "Thing", "TEST_STATIC_ATTRIBUTE": { "type": "Property", "value": "TEST", "metadata": { "TimeInstant": { "type": "DateTime", "value": "2024-05-27T11:24:41.396Z" } } }, "TimeInstant": { "type": "DateTime", "value": "2024-05-27T11:24:41.396Z", "metadata": {} }, "mapped_attribute": { "type": "StructuredValue", "value": { "a": 15, "b": "testData", "c": false }, "metadata": { "TimeInstant": { "type": "DateTime", "value": "2024-05-27T11:24:41.396Z" } } } }

Please let me know if this expected response is correct. Thank you!

Yes, the data I expect from Orion should look like this. In the end, you should obtain the same result as when attribute mapping and static attributes are defined in the provisioning of the service group but, in this case, only for the individual device.

@fgalan
Copy link
Member

fgalan commented May 29, 2024

I would like to contribute to this issue.

Thank for your willingness to work on this! You have been assigned.

We would have a look to the pull request derived from this issue.

@AlvaroVega
Copy link
Member

AlvaroVega commented May 29, 2024

Device provisioning phase only creates group and device in IotAgent. Later, when a measure arrives, iotagent will create a entity in Orion. IMHO this is not a bug, this is the current behavior. Maybe related with structuredValue mapped and measures ?

@ludilorenz
Copy link
Author

Device provisioning phase only creates group and device in IotAgent. Later, when a measure arrives, iotagent will create a entity in Orion. IMHO this is not a bug, this is the current behavior. Maybe related with structuredValue mapped and measures ?

In the FIWARE tutorials on NGSI-V2, it is mentioned that you can define static attributes and attributes when provisioning a device. Furthermore, I did a test using an older version of the agent (3.2.0) and it allows me to define static attributes and attributes for a single device. Obviously I am speaking as a neophyte in FIWARE technologies, so I would like to know what the correct behaviour is.

@fgalan
Copy link
Member

fgalan commented Jun 5, 2024

The behaviour was changed in IOTA Lib version 3.3.0 (used since IOTA-JSON version 2.3.0)

Add: do not create initial entity when a new device is provisioned and appendMode is false or NGSI-LD is used

This can be defined as the (current) "correct behaviour", so I'd suggest to adapt FIWARE tutorial to it (CC: @jason-fox )

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

4 participants