telefonicaid / iotagent-node-lib

Module to enable IoT Agent developers to build custom agents for their devices that can easily connect to NGSI Context Brokers
https://iotagent-node-lib.rtfd.io/
GNU Affero General Public License v3.0
60 stars 85 forks source link

id of entity (expanded by entityNameExp should be a string, even when result or expression is a number) #1476

Closed AlvaroVega closed 11 months ago

AlvaroVega commented 11 months ago

IoT Agent Node Lib version the issue has been seen with

3.3.0

Bound or port used (API interaction)

Southbound (Devices data API)

NGSI version

NGSIv2

Are you running a container?

None

Image type

None

Expected behaviour you didn't see

Device

{ "_id" : ObjectId("650d35422b1b15d5ca229e46"), "commands" : [ ], "staticAttributes" : [ ], "subscriptions" : [ ], "creationDate" : ISODate("2023-09-22T06:33:38.027Z"), "id" : "2699", "type" : "NoiseLevelObserved", "name" : "2699", "service" : "sc_vlci", "subservice" : "/sonometros", "apikey" : "e1sxijb6hvylgx94wm5k87jgw", "protocol" : "IoTA-JSON", "transport" : "HTTP", "timestamp" : false, "expressionLanguage" : "jexl", "__v" : 0 }

Group

{ "_id" : ObjectId("650bf6b42b1b153011f11629"), "attributes" : [ { "object_id" : "dateObservedFrom", "name" : "dateObservedFrom", "type" : "Timestamp" }, { "object_id" : "dateObservedTo", "name" : "dateObservedTo", "type" : "Timestamp" }, { "object_id" : "LAeq", "name" : "LAeq", "type" : "Float" } ], "resource" : "/iot/json", "apikey" : "e1sxijb6hvylgx94wm5k87jgw", "type" : "NoiseLevelObserved", "service" : "sc_vlci", "subservice" : "/sonometros", "description" : "OTP - VLCI - Sensores BSG - Ruido minutal", "timestamp" : false, "expressionLanguage" : "jexl", "entityNameExp" : "id", "__v" : 0 }

Unexpected behaviour you saw

POST /v2/entities?options=upsert, request payload (237 bytes): {"id":2699,"type":"NoiseLevelObserved","dateObservedFrom":{"value":"2023-10-02T10:58:00+00:00","type":"Timestamp"},"dateObservedTo":{"value":"2023-10-02T10:59:00+00:00","type":"Timestamp"},"LAeq":{"value":63.721833278745,"type":"Float"}}, response code: 400

Steps to reproduce the problem

No response

Configs

environment:
    - "IOTA_CB_HOST=orion"
    - "IOTA_CB_PORT=1026"
    - "IOTA_NORTH_PORT=4041"
    - "IOTA_REGISTRY_TYPE=mongodb"
    - "IOTA_MONGO_HOST=mongodb"
    - "IOTA_MONGO_PORT=27017"
    - "IOTA_MONGO_DB=iotagent-json"
    - "IOTA_HTTP_PORT=7896"
    - "IOTA_PROVIDER_URL=http://iot-agent:4041"

Log output

No response

AlvaroVega commented 11 months ago

entity id must be:

"id" : "2699"

fgalan commented 11 months ago

Fixed in release/3.4.0 in PR #1478 + #1479 + #1480

Pending of a PR with the same accumulated fix for master.

fgalan commented 11 months ago

PR https://github.com/telefonicaid/iotagent-node-lib/pull/1487 (for master)