Skip to content

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

@kandarp-n

Description

@kandarp-n

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:

if (
'autoprovision' in typeInformation &&
/* jshint -W101 */
typeInformation.autoprovision === undefined
? typeInformation.autoprovision === true
: config.getConfig().appendMode === true
) {

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
    ) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions