telefonicaid / iotagent-json

IoT Agent for a JSON based protocol (with HTTP, MQTT and AMQP transports)
https://fiware-iotagent-json.rtfd.io/
GNU Affero General Public License v3.0
51 stars 88 forks source link

Not supporting NGSIv2 metadata in device provisioned attributes #479

Closed achandana closed 4 years ago

achandana commented 4 years ago

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:

  1. I have removed the metadata in IoT agent
  2. 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"} } }
  3. 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.

fgalan commented 4 years ago

I think something related with metadata was implemented in last versions of the IOTA Node Lib (and in the last versions of IOTA-JSON, which uses that version of the library).

However, I don't remember pretty well... Maybe @jason-fox (with I think was involved in such implementation) could provide more information.

Thanks for the feedback!

jason-fox commented 4 years ago

There were two underlying issues, the main one being that metadata could only be set up in config. I've just raised a PR to fix this and a related issue.

see: https://github.com/telefonicaid/iotagent-node-lib/pull/870

achandana commented 4 years ago

jason..Is that metadata issue fixed and is it available in new version?

jason-fox commented 4 years ago

@achandana - I am just a Contributor to these projects and not an Administrator, so I do not have the rights to create new releases.

fgalan commented 4 years ago

Don't worry @achandana ... small fixes are usually merged very quicky ;) Thanks @jason-fox for the fix!

I understand that having merged PR https://github.com/telefonicaid/iotagent-node-lib/pull/870 this issue is solved, so I'm closing (if I'm wrong, please tell me and we'll reopen it).

@achandana which docker image are you using for IOTA-JSON? You should use :latest to benefit from this fix until it lands numbered version.

achandana commented 4 years ago

yeah @fgalan i am using latest version only

Thanks a lot jason and fgalan for greate support

fgalan commented 4 years ago

Which exact image? (I mean, not only the tag, but the full line that starts with image: in your docker-compose.yml, file, if I'm remembering correctly)

achandana commented 4 years ago

I am using fiware/iotagent-json:latest image. is there any another image i have to use in docker-compose.yml

achandana commented 4 years ago

@fgalan Could you please let me know when will be the changes reflected in docker hub

fgalan commented 4 years ago

I have re-launched the build of fiware/iotagent-json:latest. If you pull again the container the new version should have the fix included.

achandana commented 4 years ago

Thank you very much @fgalan