IoTagent-LoRaWAN
IoTagent-LoRaWAN copied to clipboard
Unable to send commands to sensor through Orion Context Broker
Hello, I am hoping you can assist me with a problem I am experiencing.
I have set up the LoRaWAN IoT Agent with TTN, correctly providing the ApiKey and establishing the flow between the sensor and Orion. I am able to successfully retrieve and store data from the sensor.
However, I am encountering an issue when attempting to send a command to the sensor through a PATCH request in the Orion Context Broker.
What I send to Orion Context Broker is the following:
curl --location --request PATCH 'http://localhost:4041/v2/entities/urn:LoraDeviceGroup:eui-70b3d57ed8001231/attrs' \
--header 'accept: application/json' \
--header 'Fiware-Service: openiot' \
--header 'Fiware-ServicePath: /' \
--header 'Content-Type: application/json' \
-d '{
"on": {
"type": "command",
"value": ""
}
}'
What I receive is the following (404 not found):
{
"error": "NotFound",
"description": "The requested entity has not been found. Check type and id"
}
That sounds quite weird, since all the entities in the IoTA and Orion Context Broker were automatically created by the IoTA since I've created a sensor group.
This is the body of my POST request that I've sent to the IoTA while creating the service group:
{
"services": [
{
"entity_type": "LoraDeviceGroup",
"apikey": "",
"resource": "XXXXXXXXXX",
"commands":[
{
"object_id": "on",
"name": "on",
"type": "command"
},
{
"object_id": "off",
"name": "off",
"type": "command"
}
],
"attributes": [
{
"object_id": "rh0",
"name": "relative_humidity_0",
"type": "Number"
},
{
"object_id": "t0",
"name": "temperature_0",
"type": "Number"
},
{
"object_id": "bp1",
"name": "barometric_pressure_1",
"type": "hpa"
},
{
"object_id": "t1",
"name": "temperature_1",
"type": "Number"
},
{
"object_id": "t2",
"name": "temperature_2",
"type": "Number"
}
],
"internal_attributes": {
"lorawan": {
"application_server": {
"host": "eu1.cloud.thethings.industries",
"username": "XXXXXXXXXX",
"password": "XXXXXXXXXX",
"provider": "TTN"
},
"app_eui": "XXXXXXXXXX",
"application_id": "XXXXXXXXXX",
"application_key": "XXXXXXXXXX",
"data_model": "application_server"
}
}
}
]
}
If I retrieve the entity from the context broker this is what I get:
{
"id": "urn:LoraDeviceGroup:eui-70b3d57ed8001231",
"type": "LoraDeviceGroup",
"TimeInstant": {
"type": "DateTime",
"value": "2023-04-28T10:01:52.894Z",
"metadata": {}
},
"barometric_pressure_1": {
"type": "hpa",
"value": 1006.9,
"metadata": {
"TimeInstant": {
"type": "DateTime",
"value": "2023-04-28T10:01:52.894Z"
}
}
},
"off_info": {
"type": "commandResult",
"value": " ",
"metadata": {}
},
"off_status": {
"type": "commandStatus",
"value": "UNKNOWN",
"metadata": {}
},
"on_info": {
"type": "commandResult",
"value": " ",
"metadata": {}
},
"on_status": {
"type": "commandStatus",
"value": "UNKNOWN",
"metadata": {}
},
"relative_humidity_0": {
"type": "Number",
"value": 45.5,
"metadata": {
"TimeInstant": {
"type": "DateTime",
"value": "2023-04-28T10:01:52.894Z"
}
}
},
"temperature_0": {
"type": "Number",
"value": 24.1,
"metadata": {
"TimeInstant": {
"type": "DateTime",
"value": "2023-04-28T10:01:52.894Z"
}
}
},
"temperature_1": {
"type": "Number",
"value": 23.8,
"metadata": {
"TimeInstant": {
"type": "DateTime",
"value": "2023-04-28T10:01:52.894Z"
}
}
},
"temperature_2": {
"type": "Number",
"value": 24,
"metadata": {
"TimeInstant": {
"type": "DateTime",
"value": "2023-04-28T10:01:52.894Z"
}
}
},
"on": {
"type": "command",
"value": "",
"metadata": {}
},
"off": {
"type": "command",
"value": "",
"metadata": {}
}
}
Also, all the registrations are correctly set up:
{
"id": "644b98f080c795149570b92e",
"dataProvided": {
"entities": [
{
"id": "urn:LoraDeviceGroup:eui-70b3d57ed8001231",
"type": "LoraDeviceGroup"
}
],
"attrs": [
"on",
"off"
]
},
"provider": {
"http": {
"url": "http://localhost:4041"
},
"supportedForwardingMode": "all",
"legacyForwarding": false
},
"status": "active"
}
These are the logs regarding my PATCH request:
docker-orion-1 | time=2023-04-28T10:52:49.459Z | lvl=WARN | corr=d12ba9ea-e5b2-11ed-8bf4-0242ac120003 | trans=1682679098-198-00000000009 | from=192.168.191.10 | srv=openiot | subsrv=/ | comp=Orion | op=AlarmManager.cpp[598]:badInputReset | msg=Releasing alarm BadInput 192.168.191.10
docker-orion-1 | time=2023-04-28T10:52:49.461Z | lvl=ERROR | corr=d12ba9ea-e5b2-11ed-8bf4-0242ac120003 | trans=1682679098-198-00000000009 | from=192.168.191.10 | srv=openiot | subsrv=/ | comp=Orion | op=postUpdateContext.cpp[644]:postUpdateContext | msg=Internal Error (attribute 'on' not found)
docker-orion-1 | time=2023-04-28T10:52:49.461Z | lvl=ERROR | corr=d12ba9ea-e5b2-11ed-8bf4-0242ac120003 | trans=1682679098-198-00000000009 | from=192.168.191.10 | srv=openiot | subsrv=/ | comp=Orion | op=postUpdateContext.cpp[683]:postUpdateContext | msg=Orion Bug (empty contextAttributeVector for ContextElementResponse 1)
docker-orion-1 | time=2023-04-28T10:52:49.461Z | lvl=INFO | corr=d12ba9ea-e5b2-11ed-8bf4-0242ac120003 | trans=1682679098-198-00000000009 | from=192.168.191.10 | srv=openiot | subsrv=/ | comp=Orion | op=logTracing.cpp[164]:logInfoFwdStart | msg=Starting forwarding for PATCH /v2/entities/urn:LoraDeviceGroup:eui-70b3d57ed8001231/attrs
docker-iotagent-lora-1 | time=2023-04-28T10:52:49.462Z | lvl=DEBUG | corr=d12ba9ea-e5b2-11ed-8bf4-0242ac120003; cbfwd=1 | trans=80c75dea-3429-488b-9bc2-e10d0f2f14ff | op=IoTAgentNGSI.GenericMiddlewares | from=n/a | srv=openiot | subsrv=/ | msg=Request for path [//op/update] from [192.168.191.21:4041] | comp=IoTAgent
docker-iotagent-lora-1 | time=2023-04-28T10:52:49.463Z | lvl=DEBUG | corr=d12ba9ea-e5b2-11ed-8bf4-0242ac120003; cbfwd=1 | trans=80c75dea-3429-488b-9bc2-e10d0f2f14ff | op=IoTAgentNGSI.GenericMiddlewares | from=n/a | srv=openiot | subsrv=/ | msg=Body:
docker-iotagent-lora-1 |
docker-iotagent-lora-1 | {
docker-iotagent-lora-1 | "entities": [
docker-iotagent-lora-1 | {
docker-iotagent-lora-1 | "id": "urn:LoraDeviceGroup:eui-70b3d57ed8001231",
docker-iotagent-lora-1 | "type": "LoraDeviceGroup",
docker-iotagent-lora-1 | "on": {
docker-iotagent-lora-1 | "type": "command",
docker-iotagent-lora-1 | "value": "",
docker-iotagent-lora-1 | "metadata": {}
docker-iotagent-lora-1 | }
docker-iotagent-lora-1 | }
docker-iotagent-lora-1 | ],
docker-iotagent-lora-1 | "actionType": "update"
docker-iotagent-lora-1 | }
docker-iotagent-lora-1 |
docker-iotagent-lora-1 | | comp=IoTAgent
docker-iotagent-lora-1 | time=2023-04-28T10:52:49.463Z | lvl=ERROR | corr=d12ba9ea-e5b2-11ed-8bf4-0242ac120003; cbfwd=1 | trans=80c75dea-3429-488b-9bc2-e10d0f2f14ff | op=IoTAgentNGSI.ContextServer-v2 | from=n/a | srv=openiot | subsrv=/ | msg=Tried to handle an update request before the update handler was stablished. | comp=IoTAgent
docker-iotagent-lora-1 | time=2023-04-28T10:52:49.463Z | lvl=DEBUG | corr=d12ba9ea-e5b2-11ed-8bf4-0242ac120003; cbfwd=1 | trans=80c75dea-3429-488b-9bc2-e10d0f2f14ff | op=IoTAgentNGSI.ContextServer-v2 | from=n/a | srv=openiot | subsrv=/ | msg=Update NGSIv2 error [Error] handing request: [object Object] | comp=IoTAgent
docker-iotagent-lora-1 | time=2023-04-28T10:52:49.464Z | lvl=DEBUG | corr=d12ba9ea-e5b2-11ed-8bf4-0242ac120003; cbfwd=1 | trans=80c75dea-3429-488b-9bc2-e10d0f2f14ff | op=IoTAgentNGSI.DomainControl | from=n/a | srv=openiot | subsrv=/ | msg=response-time: 1 | comp=IoTAgent
docker-orion-1 | time=2023-04-28T10:52:49.464Z | lvl=WARN | corr=d12ba9ea-e5b2-11ed-8bf4-0242ac120003; cbfwd=1 | trans=1682679098-198-00000000010 | from=192.168.191.10 | srv=openiot | subsrv=/ | comp=Orion | op=httpRequestSend.cpp[651]:httpRequestSend | msg=Notification response NOT OK, http code: 500
docker-orion-1 | time=2023-04-28T10:52:49.464Z | lvl=INFO | corr=d12ba9ea-e5b2-11ed-8bf4-0242ac120003; cbfwd=1 | trans=1682679098-198-00000000010 | from=192.168.191.10 | srv=openiot | subsrv=/ | comp=Orion | op=logTracing.cpp[230]:logInfoFwdRequest | msg=Request forwarded (regId: 644b98f080c795149570b92e): POST http://192.168.191.21:4041/op/update, request payload (160 bytes): {"entities":[{"id":"urn:LoraDeviceGroup:eui-70b3d57ed8001231","type":"LoraDeviceGroup","on":{"type":"command","value":"","metadata":{}}}],"actionType":"update"}, response payload (0 bytes): , response code: 500
docker-orion-1 | time=2023-04-28T10:52:49.464Z | lvl=WARN | corr=d12ba9ea-e5b2-11ed-8bf4-0242ac120003; cbfwd=1 | trans=1682679098-198-00000000010 | from=192.168.191.10 | srv=openiot | subsrv=/ | comp=Orion | op=postUpdateContext.cpp[350]:updateForward | msg=Forwarding Error (unexpected response from context provider: HTTP/1.1 500 Internal Server Error
docker-orion-1 | X-Powered-By: Express
docker-orion-1 | Fiware-Correlator: d12ba9ea-e5b2-11ed-8bf4-0242ac120003; cbfwd=1
docker-orion-1 | Content-Type: application/json; charset=utf-8
docker-orion-1 | Content-Length: 49
docker-orion-1 | ETag: W/"31-WEsudpeiyUmasYMUiU+Jg4Br//w"
docker-orion-1 | Date: Fri, 28 Apr 2023 10:52:49 GMT
docker-orion-1 | Connection: keep-alive
docker-orion-1 | Keep-Alive: timeout=5
docker-orion-1 |
docker-orion-1 | {"error":"Error","description":"[object Object]"})
docker-orion-1 | time=2023-04-28T10:52:49.464Z | lvl=INFO | corr=d12ba9ea-e5b2-11ed-8bf4-0242ac120003 | trans=1682679098-198-00000000009 | from=192.168.191.10 | srv=openiot | subsrv=/ | comp=Orion | op=logTracing.cpp[148]:logInfoRequestWithPayload | msg=Request received: PATCH /v2/entities/urn:LoraDeviceGroup:eui-70b3d57ed8001231/attrs, request payload (68 bytes): {
docker-orion-1 | "on": {
docker-orion-1 | "type": "command",
docker-orion-1 | "value": ""
docker-orion-1 | }
docker-orion-1 | }, response code: 404
Could somebody help me with this issue?
Best regards, Andrea