Skip to content

keyValue notification format is not working in custom notifications using ngsi payload #4644

@fgalan

Description

@fgalan

Sub

{
  "status": "active",
  "subject": {
    "entities": [
      {
        "idPattern": ".*",
        "type": "WaterMeter"
      }
    ],
    "condition": {
      "attrs": [
        "TimeInstant"
      ],
      "alterationTypes": [
        "entityCreate",
        "entityUpdate",
        "entityChange",
        "entityDelete"
      ],
      "notifyOnMetadataChange": true
    }
  },
  "notification": {
    "timesSent": 29,
    "lastNotification": "2025-02-12T10:59:30.000Z",
    "attrs": [
      "TimeInstant",
      "vol",
      "waterConsumption"
    ],
    "onlyChangedAttrs": false,
    "attrsFormat": "keyValues",
    "httpCustom": {
      "url": "https://webhook.site/xxxx",
      "ngsi": {
        "vol": {
          "type": "Number",
          "value": "${waterConsumption - metadata.waterConsumption.previousValue}",
          "metadata": {
            "evalPriority": {
              "type": "Number",
              "value": 1
            }
          }
        }
      }
    },
    "metadata": [
      "previousValue",
      "*"
    ],
    "lastSuccess": "2025-02-12T10:59:30.000Z",
    "lastSuccessCode": 200,
    "covered": false
  }
}

Entity before update:

{
  "id": "contador1",
  "type": "WaterMeter",
  "TimeInstant": {
    "type": "DateTime",
    "value": "2025-02-10T16:41:00.000Z",
    "metadata": {}
  },
  "waterConsumption": {
    "type": "Number",
    "value": 20,
    "metadata": {}
  }
}

PATCH entity

{
  "TimeInstant": {
    "type": "DateTime",
    "value": "2025-02-10T16:42:00.000Z",
    "metadata": {}
  },
  "waterConsumption": {
    "type": "Number",
    "value": 23,
    "metadata": {}
  }
}

Notification (keyValues is not applied, NOK)

{
  "subscriptionId": "...",
  "data": [
    {
      "id": "contador1",
      "type": "WaterMeter",
      "TimeInstant": {
        "type": "DateTime",
        "value": "2025-02-10T16:42:00.000Z",
        "metadata": {
          "previousValue": {
            "type": "DateTime",
            "value": "2025-02-10T16:41:00.000Z"
          }
        }
      },
      "vol": {
        "type": "Number",
        "value": 3,
        "metadata": {
          "evalPriority": {
            "type": "Number",
            "value": 1
          }
        }
      },
      "waterConsumption": {
        "type": "Number",
        "value": 23,
        "metadata": {
          "previousValue": {
            "type": "Number",
            "value": 20
          }
        }
      },
      "alterationType": {
        "type": "Text",
        "value": "entityChange",
        "metadata": {}
      }
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions