1

When provisioning the Robot example device, the entities are getting created with position_info and position_status attributes but the update Position attribute in Orion is giving an error

{"code": "404", "reasonPhrase": "No context element found", "details": "error forwarding update" }

Device provision req:

curl --location --request POST 'localhost:4041/iot/devices' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'fiware-service: factory' \
--header 'fiware-servicepath: /robots' \
--data-raw '{
  "devices": [
      {
        "device_id": "robot1",
        "entity_type": "Robot",
        "entity_name": "robot01",
        "endpoint": "http://iot-sensors:3001/iot/robot",
        "attributes": [
          {
            "name": "Battery",
            "type": "number"
          }
        ],
        "lazy": [
          {
            "name": "Message",
            "type": "string"
          }
        ],
        "commands": [
          {
            "name": "Position",
            "type": "location"
          }
        ],
      "internal_attributes": {
        "lwm2mResourceMapping": {
          "Battery" : {
            "objectType": 7392,
            "objectInstance": 0,
            "objectResource": 1
          },
          "Message" : {
            "objectType": 7392,
            "objectInstance": 0,
            "objectResource": 2
          },
          "Position" : {
            "objectType": 7392,
            "objectInstance": 0,
            "objectResource": 3
          }
        }
      }
    }
  ]
}'

And Update context request:

curl --location --request POST 'http://localhost:1026/v1/updateContext' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'fiware-service: factory' \
--header 'fiware-servicepath: /robots' \
--data-raw '{
    "contextElements": [
        {
            "type": "Robot",
            "isPattern": "false",
            "id": "Robot:robot1",
            "attributes": [
            {
                "name": "Position",
                "type": "location",
                "value": "[18,3]"
            }
            ]
        }
    ],
    "updateAction": "UPDATE"
}'

As per the documentation, This action should trigger an Execute action in the client. It should also update the "_status" field of the entity with the "PENDING" value, stating the execution is pending of the client result.

I also tried to update the Position attribute using v2 but not working:

curl --location --request PATCH 
'http://localhost:1026/v2/entities/robot01/attrs/' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'fiware-service: factory' \
--header 'fiware-servicepath: /robots' \
-d '{
  "Position": {
      "type" : "location",
      "value" : "[18,3]"
  }
}'
Jitesh Prajapati
  • 2,533
  • 4
  • 29
  • 51

1 Answers1

0

From Orion documentation:

On forwarding, any type of entity in the NGSIv2 update/query matches registrations without entity type. However, the opposite doesn't work, so if you have registrations with types, then you must use ?type in NGSIv2 update/query in order to obtain a match. Otherwise you may encounter problems, like the one described in this post at StackOverflow.

I'd suggest to add ?type to your request. I mean:

curl --location --request PATCH 
'http://localhost:1026/v2/entities/robot01/attrs/?type=Robot' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'fiware-service: factory' \
--header 'fiware-servicepath: /robots' \
-d '{
  "Position": {
      "type" : "location",
      "value" : "[18,3]"
  }
}'
fgalan
  • 11,732
  • 9
  • 46
  • 89