Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can’t[Provisioning a Sensor] #6

Open
hsakamoto123 opened this issue Jan 12, 2023 · 4 comments
Open

Can’t[Provisioning a Sensor] #6

hsakamoto123 opened this issue Jan 12, 2023 · 4 comments

Comments

@hsakamoto123
Copy link

Provisioning a Sensor
3️⃣ Request:
will result in the following error:
Please tell me how to avoid it.

$ curl -iX POST \
>   'http://localhost:4041/iot/devices' \
>   -H 'Content-Type: application/json' \
>   -H 'fiware-service: openiot' \
>   -H 'fiware-servicepath: /' \
>   -d '{
>  "devices": [
>    {
>      "device_id":   "motion001",
>      "entity_name": "urn:ngsi-ld:Motion:001",
>      "entity_type": "Motion",
>      "timezone":    "Europe/Berlin",
>      "attributes": [
>        { "object_id": "c", "name": "count", "type": "Integer" }
>      ],
>      "static_attributes": [
>        { "name":"refStore", "type": "Relationship", "value": "urn:ngsi-ld:Store:001"}
>      ]
>    }
>  ]
> }
> '
HTTP/1.1 500 Internal Server Error
X-Powered-By: Express
Fiware-Correlator: 463d0a57-1870-48c2-b709-d14766ea674f
Content-Type: application/json; charset=utf-8
Content-Length: 83
ETag: W/"53-yJOco57zUHHICXOIMQuA66DVpBQ"
Date: Thu, 12 Jan 2023 15:35:41 GMT
Connection: keep-alive
Keep-Alive: timeout=5

{"name":"TypeError","message":"Cannot read properties of undefined (reading 'id')"}
@hsakamoto123
Copy link
Author

Any new information on how to avoid it?

@jason-fox
Copy link
Member

I am unable to reproduce your error.

tutorials.Custom-IoT-Agent % curl -iX POST \
  'http://localhost:4041/iot/devices' \
  -H 'Content-Type: application/json' \
  -H 'fiware-service: openiot' \
  -H 'fiware-servicepath: /' \
  -d '{
 "devices": [
   {
     "device_id":   "motion001",
     "entity_name": "urn:ngsi-ld:Motion:001",
     "entity_type": "Motion",
     "timezone":    "Europe/Berlin",
     "attributes": [
       { "object_id": "c", "name": "count", "type": "Integer" }
     ],
     "static_attributes": [
       { "name":"refStore", "type": "Relationship", "value": "urn:ngsi-ld:Store:001"}
     ]
   }
 ]
}'

I receive the following:

HTTP/1.1 201 Created
X-Powered-By: Express
Fiware-Correlator: b10c1fef-6077-489a-a38b-83b5143c4e02
Content-Type: application/json; charset=utf-8
Content-Length: 2
ETag: W/"2-vyGp6PvFo4RvsFtPoIWeCReyIC8"
Date: Mon, 20 Feb 2023 08:48:00 GMT
Connection: keep-alive
Keep-Alive: timeout=5

{}

@jason-fox
Copy link
Member

When I run

docker logs fiware-iot-agent  

I receive:

ime=2023-02-20T08:48:00.883Z | lvl=DEBUG | corr=6ce179d9-927e-4e5c-a9b2-ddf0472f6fcf | trans=6ce179d9-927e-4e5c-a9b2-ddf0472f6fcf | op=IoTAgentNGSI.DeviceService | from=n/a | srv=n/a | subsrv=n/a | msg=deviceData after merge with conf: {"id":"motion001","type":"Motion","name":"urn:ngsi-ld:Motion:001","service":"openiot","subservice":"/","active":[{"object_id":"c","name":"count","type":"Integer"}],"staticAttributes":[{"name":"refStore","type":"Relationship","value":"urn:ngsi-ld:Store:001"}],"lazy":null,"commands":[],"timezone":"Europe/Berlin","transport":"HTTP","internalId":null,"subscriptions":[],"polling":true} | comp=IoTAgent
time=2023-02-20T08:48:00.883Z | lvl=DEBUG | corr=6ce179d9-927e-4e5c-a9b2-ddf0472f6fcf | trans=6ce179d9-927e-4e5c-a9b2-ddf0472f6fcf | op=IoTAgentNGSI.DeviceService | from=n/a | srv=n/a | subsrv=n/a | msg=Registering device into NGSI Service:
{
    "id": "motion001",
    "type": "Motion",
    "name": "urn:ngsi-ld:Motion:001",
    "service": "openiot",
    "subservice": "/",
    "active": [
        {
            "object_id": "c",
            "name": "count",
            "type": "Integer"
        }
    ],
    "staticAttributes": [
        {
            "name": "refStore",
            "type": "Relationship",
            "value": "urn:ngsi-ld:Store:001"
        }
    ],
    "lazy": null,
    "commands": [],
    "timezone": "Europe/Berlin",
    "transport": "HTTP",
    "internalId": null,
    "subscriptions": [],
    "polling": true
} | comp=IoTAgent
time=2023-02-20T08:48:00.884Z | lvl=DEBUG | corr=6ce179d9-927e-4e5c-a9b2-ddf0472f6fcf | trans=6ce179d9-927e-4e5c-a9b2-ddf0472f6fcf | op=IoTAgentNGSI.Registration | from=n/a | srv=n/a | subsrv=n/a | msg=Registration with Context Provider is not needed. Device without lazy atts or commands | comp=IoTAgent
time=2023-02-20T08:48:00.884Z | lvl=DEBUG | corr=6ce179d9-927e-4e5c-a9b2-ddf0472f6fcf | trans=6ce179d9-927e-4e5c-a9b2-ddf0472f6fcf | op=IoTAgentNGSI.Devices-v2 | from=n/a | srv=n/a | subsrv=n/a | msg=deviceData: {"id":"motion001","type":"Motion","name":"urn:ngsi-ld:Motion:001","service":"openiot","subservice":"/","active":[{"object_id":"c","name":"count","type":"Integer"}],"staticAttributes":[{"name":"refStore","type":"Relationship","value":"urn:ngsi-ld:Store:001"}],"lazy":null,"commands":[],"timezone":"Europe/Berlin","transport":"HTTP","internalId":null,"subscriptions":[],"polling":true} | comp=IoTAgent
time=2023-02-20T08:48:00.884Z | lvl=DEBUG | corr=6ce179d9-927e-4e5c-a9b2-ddf0472f6fcf | trans=6ce179d9-927e-4e5c-a9b2-ddf0472f6fcf | op=IoTAgentNGSI.Devices-v2 | from=n/a | srv=n/a | subsrv=n/a | msg=config.timestamp undefined true | comp=IoTAgent
time=2023-02-20T08:48:00.885Z | lvl=DEBUG | corr=6ce179d9-927e-4e5c-a9b2-ddf0472f6fcf | trans=6ce179d9-927e-4e5c-a9b2-ddf0472f6fcf | op=IoTAgentNGSI.Devices-v2 | from=n/a | srv=n/a | subsrv=n/a | msg=Creating initial entity in the Context Broker:
 {
    "url": "http://orion:1026/v2/entities?options=upsert",
    "method": "POST",
    "json": {
        "id": "urn:ngsi-ld:Motion:001",
        "type": "Motion",
        "count": {
            "type": "Integer",
            "value": null
        },
        "refStore": {
            "type": "Relationship",
            "value": "urn:ngsi-ld:Store:001"
        },
        "TimeInstant": {
            "type": "DateTime",
            "value": "2023-02-20T08:48:00.884Z"
        }
    },
    "headers": {
        "fiware-service": "openiot",
        "fiware-servicepath": "/",
        "fiware-correlator": "6ce179d9-927e-4e5c-a9b2-ddf0472f6fcf"
    }
} | comp=IoTAgent

@jason-fox
Copy link
Member

I assume that when you do so, you are receiving something different - could you post it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants