telefonicaid / telefonicaid/iotagent-node-lib
Returning empty value from iotagent-json to Orion in case if no value is passed from Device to iotagent-json
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 62
- Forks
- 90
- Avg merge
- 2h 35m
- Merged PRs (30d)
- 1
Description
Current behaviour
As per the current behaviour of Orion, if some attribute has not passed from device to iotagent-json then in this case, Orion will assign the previous value to those attribute.
Problem:
But if it is required as Orion should consider empty value i.e. "" for such attributes then currently it is not possible.
Please check the below is the example for more understanding:
Device Provisioning:
curl -X POST
'http://localhost:4041/iot/devices'
-H 'Content-Type: application/json'
-H 'fiware-service: openiot'
-H 'fiware-servicepath: /'
-d '{
"devices": [{
"device_id": "device03",
"entity_name": "sensor01",
"entity_type": "sensortest",
"attributes": [{
"object_id": "wagnonNo",
"name": "wagnonNo",
"type": "int"
},{
"object_id": "ContainerNo",
"name": "ContainerNo",
"type": "int"
},{
"object_id":"macAddress",
"name": "macAddress",
"type": "string"
}]}]
}'
First time data passed from device to IOT agent:
curl -X POST
'http://localhost:7896/iot/json?i=device03&k=testkey01'
-H 'content-type: application/json'
-H 'fiware-service: openiot'
-H 'fiware-servicepath: /'
-d '{
"wagnonNo": "900",
"containerNo": "5000",
"macAddress": "84:24:8D:EE:2F:D1"
}'
2nd time data pass from device to iotagent-json
curl -X POST
'http://10.0.2.15:7896/iot/json?i=sensor01&k=testkey01'
-H 'content-type: application/json'
-H 'fiware-service: openiot'
-H 'fiware-servicepath: /'
-d '{
"wagnonNo": "901",
"macAddress": "22:54:8A:EC:2B:B6"
}'
Output at Orion after passing 2nd data as per current feature:
{
"id": "sensor01",
"type": "sensortest",
"TimeInstant": {
"type": "ISO8601",
"value": "2019-04-05T08:44:43.00Z",
"metadata": {}
},
"wagnonNo": {
"type": "string",
"value": "901",
"metadata": {
"TimeInstant": {
"type": "ISO8601",
"value": "2019-04-05T08:44:43.914Z"
} }},
"containerNo": {
"type": "string",
"value": "5000",
"metadata": {
"TimeInstant": {
"type": "ISO8601",
"value": "2019-04-05T08:44:43.914Z"
}}},
"macAddress": {
"type": "string",
"value": "22:54:8A:EC:2B:B6",
"metadata": {
"TimeInstant": {
"type": "ISO8601",
"value": "2019-04-05T08:44:43.914Z"
}} }}
Expected output
{
"id": "sensor01",
"type": "sensortest",
"TimeInstant": {
"type": "ISO8601",
"value": "2019-04-05T08:44:43.00Z",
"metadata": {}
},
"wagnonNo": {
"type": "string",
"value": "901",
"metadata": {
"TimeInstant": {
"type": "ISO8601",
"value": "2019-04-05T08:44:43.914Z"
}} },
"containerNo": {
"type": "string",
"value": "",
"metadata": {
"TimeInstant": {
"type": "ISO8601",
"value": "2019-04-05T08:44:43.914Z"
}} },
"macAddress": {
"type": "string",
"value": "22:54:8A:EC:2B:B6",
"metadata": {
"TimeInstant": {
"type": "ISO8601",
"value": "2019-04-05T08:44:43.914Z"
} }}}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the /iot/json endpoint and compare the first and second request examples with the resulting Orion entity. Trace how provisioned attributes omitted from a device payload are handled; done means an omitted containerNo is sent to Orion with an empty value while supplied attributes retain their new values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100