Skip to content

Issue jexl expressions #167

@arturohu

Description

@arturohu

After running a group provisioning, with jexl expressions, and reporting as dummy device, the jexl expression doesn't seem to work properly.

Deploy stack:

cd examples/dummy-devices/
docker-compose up

Step 1:

curl --location --request POST 'localhost:4041/iot/services' \
--header 'fiware-service: smartgondor' \
--header 'fiware-servicePath: /environment' \
--header 'Content-Type: application/json' \
--data-raw '{
	"services": [{
		"entity_type": "WeatherObserved",
		"apikey": "",
		"resource": "70B3D57ED00006B2",
		"expressionLanguage": "jexl",
		"attributes": [{
				"object_id": "temperature_1",
				"name": "temperature",
				"type": "Number",
				"expression": "temperature_1 + 21.5"

			},
			{
				"object_id": "barometric_pressure_0",
				"name": "pressure",
				"type": "Number"
			},
			{
				"object_id": "relative_humidity_2",
				"name": "relative_humidity",
				"type": "Number",
				"expression": "${@relative_humidity_2 + 21.5}"
			}
		],
		"internal_attributes": {
			"lorawan": {
				"application_server": {
					"host": "mqtt",
					"username": "admin",
					"password": "password",
					"provider": "chirpstack"
				},
				"app_eui": "70B3D57ED00006B2",
				"application_id": "demoChirpstack",
				"application_key": "BE6996EEE2B2D6AFFD951383C1F3C3BD",
				"data_model": "cayennelpp"
			}
		}
	}]
}' | jq

Step 2:

docker exec -ti dummy-devices_mqtt_1 mosquitto_pub -h mqtt -u admin -P password -t application/demoChirpstack/device/test_device/event/up -m '{
  "applicationID": "demoChirpstack",
  "applicationName": "test",
  "deviceName": "test_device",
  "devEUI": "test_device",
  "fPort": 5,
  "data": "AHMnSwFnARYCaFADAGQEAQAFAdc="
}'

Step 3:

curl --location --request GET 'http://localhost:4041/iot/devices' \
--header 'fiware-service: smartgondor' \
--header 'fiware-servicepath: /environment' | jq

Step 4:

curl --location --request GET 'http://localhost:1026/v2/entities/urn:WeatherObserved:test_device' \
--header 'fiware-service: smartgondor' \
--header 'fiware-servicepath: /environment' | jq

Result:

{
  "id": "urn:WeatherObserved:test_device",
  "type": "WeatherObserved",
...
  "relative_humidity": {
    "type": "Number",
    "value": 61.5,
    "metadata": {
      "TimeInstant": {
        "type": "DateTime",
        "value": "2022-09-20T11:23:17.444Z"
      }
    }
  },
  "temperature": {
    "type": "Number",
    "value": "temperature_1 + 21.5",
    "metadata": {
      "TimeInstant": {
        "type": "DateTime",
        "value": "2022-09-20T11:23:17.444Z"
      }
    }
  }
}

Jexl expression it isn't working in spite of the "expressionLanguage" attribute defined on group provisioning. Moreover, the legacy expression ("expression": "${@relative_humidity_2 + 21.5}") is working.

Maybe some bad configuration. I would like to set some ternary operator with jexl expressions.

Metadata

Metadata

Assignees

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