Details
-
Type: Monitor
-
Status: Open
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: FIWARE-TECH-HELP
-
HD-Chapter:Unknown
-
HD-Enabler:Unknown
-
HD-Node:Unknown
Description
Created question in FIWARE Q/A platform on 25-05-2021 at 16:05
Please, ANSWER this question AT https://stackoverflow.com/questions/67691885/iot-agent-checks-default-attributes-that-are-not-in-the-iot-payload
Question:
IoT-Agent checks default attributes that are not in the iot payload
Description:
I have a test environment where I have configured a service group for the JSON IoT Agent with a legacy expression in it:
{
"_id": "60acc2d549e4721ae5087356",
"__v": 0,
"iotagent": "http://10.0.0.2:4062",
"apikey": "apikeyTest2",
"entity_type": "WasteContainer",
"service_path": "/subservice",
"service": "service",
"resource": "/iot/json",
"description": "IoTAgent JSON - Node.js",
"protocol": "IoTA-JSON",
"internal_attributes": [],
"attributes": [
,
{
"name": "fillingLevel",
"expression": "$
"type": "Number"
}
],
"lazy": [],
"static_attributes": [],
"commands": []
}
Apart from that I register manually a device with a "jexl" as expression language:
curl --location --request POST 'https://host/iot/devices' \
--header 'Fiware-Service: service' \
--header 'Fiware-ServicePath: /subservice' \
--header 'X-Auth-Token: gAAAAABgrQm..._R8r98aeNWQ' \
--header 'Content-Type: application/json' \
--data-raw '{
"devices": [
{
"device_id": "deviceJSON1",
"entity_name": "device:entity01",
"entity_type": "device",
"expressionLanguage": "jexl",
"attributes": [
{ "object_id": "b", "name": "position", "type": "Number", "expression": "(a+b)" }
],
"protocol": "IoTA-JSON",
"transport": "HTTP"
}
]
}
'
Then I send data from the device using the apikey of the previous service group, but without using any attribute configured there:
curl --location --request POST 'http://host/iot/json?k=apikeyTest2&i=deviceJSON1&getCmd=0' \
--header 'Content-Type: application/json' \
--data-raw '{
"a": 4,
"b": 5
}'
The response is 400 Bad Request:
{
"name": "INVALID_EXPRESSION",
"message": "Invalid expression in evaluation [${@level/100}
]"
}
Is this the expected result or should the agent try to use the "jexl" to transform the payload as there is not level attribute in the iot data?
To solve this I can create another service group with a different apikey and without default attributes, but just wanted to know if the result was the expected.
Activity
- All
- Comments
- History
- Activity
- Transitions