Skip to content

JEXL expressions are not working in simplifiedKeyValues, keyValues and values notifications #4645

Description

@fgalan

Subs

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

Entity before update:

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

PATCH entity

{\n  "TimeInstant": {\n    "type": "DateTime",\n    "value": "2025-02-10T16:43:00.000Z",\n    "metadata": {}\n  },\n  "waterConsumption": {\n    "type": "Number",\n    "value": 25,\n    "metadata": {}\n  }\n}

Notification (JEXL expression is not evaluated, NOK)

{
  "id": "contador1",
  "type": "WaterMeter",
  "TimeInstant": "2025-02-10T16:43:00.000Z",
  "vol": "${waterConsumption - metadata.waterConsumption.previousValue}",
  "waterConsumption": 25,
  "alterationType": "entityChange"
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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