Chandana buduru
Chandana buduru

Reputation: 11

Not supporting NGSIv2 metadata in device provisioned attributes

We have used IoT agent -1.14.0 version from docker hub. We have given the service and servicepath as follows fiware-service:testiotagent fiware-servicepath:/

Device registration payload :

{
"devices": [
{
"device_id":"Motion-10",
"entity_name":"urn:ngsi-ld:SENSOR:Motion-10",
"entity_type":"SENSOR",
"transport": "MQTT",
"attributes": [
{"object_id": "s", "name": "state", "type":"Text"},
{"object_id": "l", "name": "luminosity", "type":"Integer",
"metadata":{ "unitCode":{"type": "Text", "value" :"CAL"}
}
}
]
}
]
}

As per iotagent node lib version 2.12.0 ,IoT agent json -1.14.0 version should support the metadata in device provisioned attributes. But still facing issue. When we try to provision the above device we are getting the below error:

{
"name": "WRONG_SYNTAX",
"message": "Wrong syntax in request: Errors found validating request."
}

I found that iotagent-node-lib have the schema to validate against device registration payload

https://github.com/telefonicaid/iotagent-node-lib/blob/master/lib/templates/createDevice.json

In this json schema there is no metadata schema mentioned in attributes.

I have followed the below steps for metadata in Entity level:

I have removed the metadata in IoT agent Updated the entity 'urn:ngsi-ld:SENSOR:Motion-10' as below

{
"id":"urn:ngsi-ld:SENSOR:Motion-10",
"type":"SENSOR",
"luminosity":{
"type":"Integer",
"value":"0",
"metadata":{ "unitCode":{"type": "Text", "value" :"CAL"}
}
}

Tried to send measurement and metadata got overriden and got the empty metadata

{
"id":"urn:ngsi-ld:SENSOR:Motion-10",
"type":"SENSOR",
"luminosity":{
"type":"Integer",
"value":"15",
"metadata":{}
}
}

Is it due to the fix given for issue 1788 in fiware-orion ,https://github.com/telefonicaid/fiware-orion/issues?q=1788. Need some qucik confirmation and help from Fiware experts to overcome this issue, it is very much appreciated.

Upvotes: 1

Views: 154

Answers (1)

Jason Fox
Jason Fox

Reputation: 5290

The templates checking a valid provisioning request currently does not accept the metadata attribute. There is an outstanding PR for this. At the moment you would be better off defining the Entities with the metadata in a config.js file instead.

e.g.:

 iotAgentConfig = {
        contextBroker: {
            host: '192.168.1.1',
            port: '1026',
            ngsiVersion: 'v2'
        },
        server: {
            port: 4041
        },
        types: {
            'WeatherStation': {
                commands: [],
                type: 'WeatherStation',
                lazy: [],
                active: [
                    {
                        object_id: 'p',
                        name: 'pressure',
                        type: 'Hgmm'
                    },
                    {
                        object_id: 'h',
                        name: 'humidity',
                        type: 'Percentage',
                        entity_name: 'Higro2000',
                        entity_type: 'Higrometer',
                        metadata:{
                            unitCode:{
                                type: "Text", value :"Hgmm"
                            }
                        }
                    }
                ]
            },
    ....etc

Upvotes: 1

Related Questions