lightweightm2m-iotagent icon indicating copy to clipboard operation
lightweightm2m-iotagent copied to clipboard

Cant retrieve an Attribute

Open fermenreq opened this issue 7 years ago • 0 comments

Hi all

I cant recover an attribute that I include in my device.

First I create a service:

(curl localhost:4041/iot/services -s -S --header 'Content-Type: application/json' \
  --header 'Accept: application/json' --header 'fiware-service: Weather' --header 'fiware-servicepath: /baloons' \
  -d @- | python -mjson.tool) <<EOF
{
  "services": [
    {
      "resource": "/weatherBaloon",
      "apikey": "",
      "type": "WeatherBaloon",
      "commands": [],
      "lazy": [
        {
          "name": "Longitude",
          "type": "double"
        },
        {
          "name": "Latitude",
          "type": "double"
        },
        {
          "name": "Temperature Sensor",
          "type": "degrees"
        }
      ],
      "active": [
        {
          "name": "Power Control",
          "type": "Boolean"
        }
      ]
    }
  ]
}
EOF

The IotAgent response:

time=2017-08-24T09:49:47.295Z | lvl=DEBUG | corr=n/a | trans=n/a | op=IOTAgent.LWM2MHandlers | msg=Device register not found. Creating new device.
time=2017-08-24T09:49:47.296Z | lvl=DEBUG | corr=n/a | trans=n/a | op=IOTAgent.LWM2MHandlers | msg=Mapping device found to NGSI register
time=2017-08-24T09:49:47.299Z | lvl=DEBUG | corr=n/a | trans=n/a | op=IoTAgentNGSI.DeviceService | msg=Registering device into NGSI Service:
{
    "id": "weather1",
    "name": "weather1:WeatherBaloon",
    "type": "WeatherBaloon",
    "service": "Weather",
    "subservice": "/baloons",
    "lazy": [
        {
            "type": "double",
            "name": "Longitude"
        },
        {
            "type": "double",
            "name": "Latitude"
        },
        {
            "type": "degrees",
            "name": "Temperature Sensor"
        },
        {
            "name": "Latitude",
            "type": "String",
            "operations": "R"
        },
        {
            "name": "Longitude",
            "type": "String",
            "operations": "R"
        },
        {
            "name": "Altitude",
            "type": "String",
            "operations": "R"
        },
        {
            "name": "Uncertainty",
            "type": "String",
            "operations": "R"
        },
        {
            "name": "Velocity",
            "type": "Opaque",
            "operations": "R"
        },
        {
            "name": "Timestamp",
            "type": "Time",
            "operations": "R"
        },
        {
            "name": "Temperature Sensor#0",
            "type": "string"
        },
        {
            "name": "Power Control#0",
            "type": "string"
        }
    ],
    "active": [
        {
            "type": "Boolean",
            "name": "Power Control"
        }
    ],
    "internalId": 3
}

Before that I created 3 objects like the guide said.

I want to read Latitude attribute so I did a POST request like that:

curl http://localhost:1026/v1/queryContext -s -S --header 'Content-Type: application/json' \
 --header 'Accept: application/json' --header 'fiware-service: Weather' --header 'fiware-servicepath: /baloons' \
 -d '
{
    "entities": [
        {
            "type": "WeatherBaloon",
            "isPattern": "false",
            "id": "weather1:WeatherBaloon"
        }
    ],
    "attributes" : [
        "Latitude"
    ]    
}' 

but the response is :

{ "errorCode" : { "code" : "404", "reasonPhrase" : "No context element found" } }

Need Help !

Thanks

fermenreq avatar Aug 24 '17 09:08 fermenreq