telefonicaid / iotagent-json

IoT Agent for a JSON based protocol (with HTTP, MQTT and AMQP transports)
https://fiware-iotagent-json.rtfd.io/
GNU Affero General Public License v3.0
51 stars 88 forks source link

Device provisioning is failing due to command registration is failing with orion #517

Closed achandana closed 3 years ago

achandana commented 3 years ago

We are not able to register the device with iot agent.

Device provisioning : curl --location --request POST 'http://localhost:4041/iot/devices/' \ --header 'fiware-service: openiot' \ --header 'fiware-servicepath: /' \ --header 'Content-Type: application/json' \ --data-raw'{ "devices": [ { "device_id": "lamp001", "entity_name": "urn:ngsi-ld:Lamp:001", "entity_type": "Lamp", "transport": "MQTT", "commands": [ {"name": "on","type": "command"}, {"name": "off","type": "command"} ], "attributes": [ {"object_id": "s", "name": "state", "type":"Text"}, {"object_id": "l", "name": "luminosity", "type":"Integer", "metadata":{ "unitText":{ "type":"Text",
"value":"degree Celsius" }, "Point_Class":{ "type":"Text",
"value":"Sensor" }, "Category":{ "type":"Text",
"value":"HVAC" }, "Kind":{ "type":"Text",
"value":"AC" }, "Setpoint_Min":{ "type":"Text",
"value":"0" }, "Setpoint_Max":{ "type":"Text",
"value":"0" }, "Frequency":{ "type":"Text",
"value":"" } }} ] } ] }'

we are getting the below error { "name": "BAD_REQUEST", "message": "Request error connecting to the Context Broker: 400" }

We are getting below error in iot agent logs

time=2020-12-03T08:08:03.476Z | lvl=ERROR | corr=fdaad05a-174f-4e13-b8a7-e450dc848aaf | trans=fdaad05a-174f-4e13-b8a7-e450dc848aaf | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=Registration error connecting to the Context Broker: 400 | comp=IoTAgent

time=2020-12-03T08:08:03.476Z | lvl=DEBUG | corr=fdaad05a-174f-4e13-b8a7-e450dc848aaf | trans=fdaad05a-174f-4e13-b8a7-e450dc848aaf | op=IoTAgentNGSI.DeviceProvisioning | srv=n/a | subsrv=n/a | msg=Device provisioning failed due to the following error: | comp=IoTAgent Request error connecting to the Context Broker: 400 | time=2020-12-03T08:08:03.476Z | lvl=DEBUG | corr=fdaad05a-174f-4e13-b8a7-e450dc848aaf | trans=fdaad05a-174f-4e13-b8a7-e450dc848aaf | op=IoTAgentNGSI.DeviceProvisioning | srv=n/a | subsrv=n/a | msg=Device provisioning failed due to the following error: | comp=IoTAgent Request error connecting to the Context Broker: 400

Can anyone please help to fix this issue.

fgalan commented 3 years ago

Which IOTA-JSON and Orion version are you using?

AlvaroVega commented 3 years ago

I've being testing and it works:

(master) curl -i --location --request POST 'http://localhost:4052/iot/devices/' \
--header 'fiware-service: smartcity' \
--header 'fiware-servicepath: /' \
--header 'Content-Type: application/json' \
--data-raw '{
        "devices": [{
                "device_id": "lamp002",
                "entity_name": "urn:ngsi-ld:Lamp:001",
                "entity_type": "Lamp",
                "transport": "MQTT",
                "commands": [{
                                "name": "on",
                                "type": "command"
                        },
                        {
                                "name": "off",
                                "type": "command"
                        }
                ],
                "attributes": [{
                                "object_id": "s",
                                "name": "state",
                                "type": "Text"
}'      }]      ]       }       }       }       "value": ""xt",r"Celsius"
HTTP/1.1 201 Created
X-Powered-By: Express
Fiware-Correlator: b9bba845-4492-4091-aee6-1a0848e8f79e
Content-Type: application/json; charset=utf-8
Content-Length: 2
ETag: W/"2-vyGp6PvFo4RvsFtPoIWeCReyIC8"
Date: Thu, 28 Jan 2021 08:56:37 GMT
Connection: keep-alive
achandana commented 3 years ago

We have resolved this error

fgalan commented 3 years ago

We have resolved this error

Great!

Could you provide some detail on how do you solved it, please? It could be very useful for other users :)