Execution of the tutorial command results in an error.
$ curl -iX POST \
> 'http://localhost:4041/iot/devices' \
> -H 'Content-Type: application/json' \
> -H 'fiware-service: openiot' \
> -H 'fiware-servicepath: /' \
> -d '{
> "devices": [
> {
> "device_id": "lamp001",
> "entity_name": "urn:ngsi-ld:Lamp:001",
> "entity_type": "Lamp",
> "protocol": "PDI-IoTA-UltraLight",
> "transport": "HTTP",
> "endpoint": "http://iot-sensors:3001/iot/lamp001",
> "commands": [
> {"name": "on","type": "command"},
> {"name": "off","type": "command"}
> ],
> "attributes": [
> {"object_id": "s", "name": "state", "type":"Text"},
> {"object_id": "l", "name": "luminosity", "type":"Integer"}
> ],
> "static_attributes": [
> {"name":"refStore", "type": "Relationship","value": "urn:ngsi-ld:Store:001"}
> ]
> }
> ]
> }
> '
HTTP/1.1 409 Conflict
X-Powered-By: Express
Fiware-Correlator: e2dfb1c9-f8fb-458c-8f53-ebc569e4fa87
Content-Type: application/json; charset=utf-8
Content-Length: 108
ETag: W/"6c-MXV0ASHmZcVgSm+giF5KNzT8oKg"
Date: Thu, 29 Dec 2022 13:41:59 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{"name":"DUPLICATE_DEVICE_ID","message":"A device with the same pair (Service, DeviceId) was found:lamp001"}
The details of lamp001 at this time are as follows.
$ curl -iX GET \
> 'http://localhost:4041/iot/devices/lamp001' \
> -H 'Content-Type: application/json' \
> -H 'fiware-service: openiot' \
> -H 'fiware-servicepath: /'
HTTP/1.1 200 OK
X-Powered-By: Express
Fiware-Correlator: 9137758e-ffec-4183-b2cb-64764bac4582
Content-Type: application/json; charset=utf-8
Content-Length: 170
ETag: W/"aa-DtkbAvlQAzPkTzVDNEWEFDN2uS0"
Date: Thu, 29 Dec 2022 14:23:32 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{"device_id":"lamp001","service":"openiot","service_path":"/","entity_name":"Thing:lamp001","entity_type":"Thing","transport":"HTTP","commands":[],"static_attributes":[]}
I deleted lamp001 and tried again but got the same error.
$ curl -iX DELETE \
> 'http://localhost:4041/iot/devices/lamp001' \
> -H 'fiware-service: openiot' \
> -H 'fiware-servicepath: /'
HTTP/1.1 204 No Content
X-Powered-By: Express
Fiware-Correlator: 13850b76-210f-4fea-b43f-cd6922988d06
Date: Thu, 29 Dec 2022 14:21:27 GMT
Connection: keep-alive
Keep-Alive: timeout=5
-----
$ curl -iX GET \
> 'http://localhost:4041/iot/devices/lamp001' \
> -H 'Content-Type: application/json' \
> -H 'fiware-service: openiot' \
> -H 'fiware-servicepath: /'
HTTP/1.1 404 Not Found
X-Powered-By: Express
Fiware-Correlator: 7969f9a8-8126-42c3-adf9-4e6ab03075c7
Content-Type: application/json; charset=utf-8
Content-Length: 75
ETag: W/"4b-K4b3wKcdA3xs//EOZUi47GwR6k0"
Date: Thu, 29 Dec 2022 14:21:52 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{"name":"DEVICE_NOT_FOUND","message":"No device was found with id:lamp001"}
Please let me know how I can avoid this.
{"log":"time=2023-01-04T14:15:51.229Z | lvl=ERROR | corr=ebf236d8-e24d-4dbd-9cfc-20fd509c4213 | trans=ebf236d8-e24d-4dbd-9cfc-20fd509c4213 | op=IOTAUL.AMQP.Binding | from=n/a | srv=n/a | subsrv=n/a | msg=connect ECONNREFUSED 127.0.0.1:5672 | comp=IoTAgent\n","stream":"stdout","time":"2023-01-04T14:15:51.234099317Z"}