telefonicaid / telefonicaid/iotagent-node-lib

Autoprovision functionality not working as expected when configured at device/group level

Open
#1,003 25 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
62
Forks
90
Avg merge
2h 35m
Merged PRs (30d)
1

Description

Issue: Autoprovision functionality not working as expected when configured at device/group level.

Steps to reproduce:

  1. Register a device with 'autoprovision' flag set to true:
{
"devices": [
   {
     "device_id":   "sensor001",
     "entity_name": "urn:ngsi-ld:Sensor:sensor001",
     "entity_type": "Sensor",
     "timezone":    "Europe/Berlin",
     "attributes": [
       { "object_id": "temperature", "name":"temperature", "type":"number"}
      ],
      "autoprovision":true
   }
 ]
}
  1. Send measurement for this device with an extra measurement attribute. Sample measurement payload:
{
    "temperature":23.4,
    "humidity":40
}

Expected result: As "autoprovision" is "true" for this device, the new attribute "humidity" should get created in the Orion entity with its measurement value.
Actual result: "humidity" attibute is not getting created in Orion entity. HTTP status code 404 is returned. (Note: Measurement of "temperature" is getting updated in Orion though.)

I've identified potential cause of the issue:
https://github.com/telefonicaid/iotagent-node-lib/blob/8a6cbd1a8d4023f239195f1aa1534c75a487f139/lib/services/ngsi/entities-NGSI-v1.js#L243-L249

Below fix is required (line# 246)

    if (
        'autoprovision' in typeInformation &&
        /* jshint -W101 */
        typeInformation.autoprovision !== undefined  //This should be !== operator and not ===
            ? typeInformation.autoprovision === true
            : config.getConfig().appendMode === true
    ) {

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at lib/services/ngsi/entities-NGSI-v1.js around lines 243-249 and reproduce the device-level autoprovision request with the temperature and humidity measurements shown. Verify that the configured autoprovision behavior creates humidity in the Orion entity and that the measurement no longer returns HTTP 404, while temperature continues to update.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.