Closed mrutid closed 1 year ago
I'm not able of reproduce it, I'm obtaining an NGSIv2 update to v2/entities/expression007/attrs?type=MySensorGroup2
Hi @mrutid and @AlvaroVega , I'm also investigating this issue. But I'm getting the NSGI update as ""url": "http://localhost:1026/v2/entities/LivingRoomSensor/attrs?type=Device"," The steps, I'm following are:
curl -iX POST \
'http://localhost:4041/iot/services' \
-H 'Content-Type: application/json' \
-H 'fiware-service: smartgondor' \
-H 'fiware-servicepath: /gardens' \
-d '{
"services": [
{
"apikey": "1234",
"cbroker": "http://orion:1026",
"entity_type": "Device",
"resource": "/iot/d",
"entityNameExp": "'LivingRoomSensor' + motion001"
}
]
}'
curl -iX POST -H "Fiware-Service: samrtgondor" -H "Fiware-ServicePath: /gardens" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
"devices": [
{
"device_id": "motion001",
"entity_name": "LivingRoomSensor",
"entity_type": "Device",
"attributes": [
{ "object_id": "t", "name": "Temperature", "type": "celsius" },
{ "object_id": "l", "name": "Luminosity", "type": "lumens" }
]
}
]
}
' 'http://localhost:4041/iot/devices'
mosquitto_pub -t /1234/motion001/attrs -m '{"l":4,"t": "31.5"}'
Could you please let me know the steps to reproduce the expected NGSI-v2 link? PFA.
Maybe related: PR https://github.com/telefonicaid/iotagent-node-lib/pull/1284
Test performed:
iot-agent:
image: telefonicaiot/iotagent-json:latest
hostname: iot-agent
container_name: iot-agent
depends_on:
- mongo-db1
expose:
- "${IOTA_NORTH_PORT}"
- "${IOTA_SOUTH_PORT}"
ports:
- "${IOTA_NORTH_PORT}:${IOTA_NORTH_PORT}"
- "${IOTA_SOUTH_PORT}:${IOTA_SOUTH_PORT}"
environment:
- IOTA_LOG_LEVEL=DEBUG
- IOTA_MONGO_HOST=mongo-db1
- IOTA_MONGO_PORT=${MONGO_DB_PORT}
- IOTA_MONGO_DB=iotagentjson
- IOTA_DEFAULT_RESOURCE=/iot/json
- IOTA_CB_NGSI_VERSION=v2
- IOTA_APPEND_MODE=false
curl -iX POST 'http://localhost:4041/iot/services' \
-H 'fiware-service: service' \
-H 'fiware-servicepath: /' \
-H 'Content-Type: application/json' \
--data-raw '{
"services": [
{
"apikey": "service1",
"cbHost": "http://orion:1026",
"entity_type": "Device-1",
"resource": "/iot/json",
"expressionLanguage" : "jexl",
"entityNameExp": "'EntityNameByExp'",
"attributes": [
{
"object_id": "t",
"name": "status",
"type": "Property"
}
]
}
]
}'
[
{
"TimeInstant": {
"metadata": {},
"type": "DateTime",
"value": "2022-11-30T15:20:15.145Z"
},
"id": "Device-1:dev1",
"status": {
"metadata": {
"TimeInstant": {
"type": "DateTime",
"value": "2022-11-30T15:20:15.145Z"
}
},
"type": "Property",
"value": 5
},
"type": "Device-1"
}
]
It seems entityNameExp is not working since the entity name is the default one (entityType:device_id). The expected ones is EntityNameByExp
. It is "entityNameExp": "'EntityNameByExp'",
well defined?
PD: "entityNameExp": "EntityNameByExp",
(without the single quotes) does not work too, same result.
After review in detail this issue, it was working properly (there was an error with curl bash quotes)
@MayankSingh-NEC taking into account the positive report from @mapedraza I'd suggest you to do exactly the same steps and validate, please?
Hi @fgalan, based on your suggestion, I've perform and validate the same. Below are the steps and results:
# IoT-Agent is configured for the JSON Protocol
iot-agent:
image: fiware/iotagent-json:${JSON_VERSION}
hostname: iot-agent
container_name: fiware-iot-agent
depends_on:
- mongo-db
networks:
- default
expose:
- "${IOTA_NORTH_PORT}"
- "${IOTA_SOUTH_PORT}"
ports:
- "${IOTA_NORTH_PORT}:${IOTA_NORTH_PORT}" # localhost:4041
- "${IOTA_SOUTH_PORT}:${IOTA_SOUTH_PORT}" # localhost:7896
environment:
- IOTA_CB_HOST=orion # name of the context broker to update context
- IOTA_CB_PORT=${ORION_PORT} # port the context broker listens on to update context
- IOTA_NORTH_PORT=${IOTA_NORTH_PORT}
- IOTA_REGISTRY_TYPE=mongodb #Whether to hold IoT device info in memory or in a database
- IOTA_LOG_LEVEL=DEBUG # The log level of the IoT Agent
- IOTA_DEFAULT_EXPRESSION_LANGUAGE=jexl
- IOTA_TIMESTAMP=true # Supply timestamp information with each measurement
- IOTA_CB_NGSI_VERSION=v2 # use NGSIv2 when sending updates for active attributes
- IOTA_AUTOCAST=true # Ensure Ultralight number values are read as numbers not strings
- IOTA_APPEND_MODE=false
- IOTA_MONGO_HOST=mongo-db # The host name of MongoDB
- IOTA_MONGO_PORT=${MONGO_DB_PORT} # The port mongoDB is listening on
- IOTA_MONGO_DB=iotagentjson # The name of the database used in mongoDB
- IOTA_HTTP_PORT=${IOTA_SOUTH_PORT} # The port used for device traffic over HTTP
- IOTA_PROVIDER_URL=http://iot-agent:${IOTA_NORTH_PORT}
- IOTA_DEFAULT_RESOURCE=/iot/json
healthcheck:
interval: 5s
Service Provisioning:
Device Provisioning:
Sending Measurement:
Retrieving details:
Result - Orion
{"status":{
"type":"Property","value":"5",
"metadata":{
"TimeInstant":{
"type":"DateTime",
"value":"2022-12-19T10:12:30.699Z"
}}},
"refStore":{"type":"Relationship","value":"urn:ngsi-ld:Device-1:001",
"metadata":{"TimeInstant":{"type":"DateTime","value":"2022-12-19T10:12:30.699Z"}}},
"TimeInstant":{"type":"DateTime","value":"2022-12-19T10:12:30.699Z"}}
Result - Iot-Agent
I think this issue could be closed given that
Given the following group:
We get the following NGSI update:
http://eob67h2l2jqr93n.m.pipedream.net/v2/entities/MySensorGroup2:007/attrs?type=MySensorGroup2
instead of
http://eob67h2l2jqr93n.m.pipedream.net/v2/entities/expression007/attrs?type=MySensorGroup2