[Backlogmanager] [FIWARE-JIRA] (HELP-17429) [fiware-stackoverflow] Getting empty values when querying data from STH-Comet

Fernando Lopez (JIRA) jira-help-desk at jira.fiware.org
Mon Mar 1 10:49:00 CET 2021


     [ https://jira.fiware.org/browse/HELP-17429?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Fernando Lopez reassigned HELP-17429:
-------------------------------------

    Assignee: Fermín Galán

> [fiware-stackoverflow] Getting empty values when querying data from STH-Comet
> -----------------------------------------------------------------------------
>
>                 Key: HELP-17429
>                 URL: https://jira.fiware.org/browse/HELP-17429
>             Project: Help-Desk
>          Issue Type: Monitor
>          Components: FIWARE-TECH-HELP
>            Reporter: Backlog Manager
>            Assignee: Fermín Galán
>              Labels: fiware, fiware-cygnus, fiware-orion, fiware-sth-comet
>
> Created question in FIWARE Q/A platform on 25-02-2021 at 14:02
> {color: red}Please, ANSWER this question AT{color} https://stackoverflow.com/questions/66371017/getting-empty-values-when-querying-data-from-sth-comet
> +Question:+
> Getting empty values when querying data from STH-Comet
> +Description:+
> Here is how I have provisioned the service group on the IoT Agent
> url = 'http://localhost:4041/iot/services'
> headers = {'Content-Type': "application/json", 'fiware-service': "smartparking_pmr", 'fiware-servicepath': "/mtp"}
> data = {
>  "services": [
>    {
>      "apikey":      "4jggokgpepnvsb2uv4s40d59ov",
>      "cbroker":     "http://orion:1026",
>      "entity_type": "PMR",
>      "resource":    "/iot/d"
>    }
>  ]
> }
> Then I registered the device.
> url = 'http://localhost:4041/iot/devices'
> headers = {'Content-Type': "application/json", 'fiware-service': "smartparking_pmr", 'fiware-servicepath': "/mtp"}
> data = {
>  "devices": [
>    {
>      "device_id":   "711",
>      "entity_name": "urn:ngsi-ld:Pmr:711",
>      "entity_type": "PMR",
>      "timezone":    "Europe/Berlin",
>       "attributes": [
>         { "object_id": "s", "name": "SlotStatus", "type": "Integer" },
>         { "object_id": "lat", "name": "Latitude", "type": "Double" },
>         { "object_id": "lon", "name": "Longitude", "type": "Double" }
>       ]
>    }
>  ]
> }
> Next I make a subscription to the Orion Context Broker.
> curl -iX POST \
>   'http://localhost:1026/v2/subscriptions/' \
>   -H 'Content-Type: application/json' \
>   -H 'fiware-service: openiot' \
>   -H 'fiware-servicepath: /' \
>   -d '{
>   "description": "Notify STH-Comet of all smartparking_pmr SlotStatus changes",
>   "subject": {
>     "entities": [
>       {
>         "idPattern": "Pmr.*"
>       }
>     ],
>     "condition": {"attrs": ["SlotStatus"] }
>   },
>   "notification": {
>     "http": {
>       "url": "http://sth-comet:8666/notify"
>     },
>     "attrs": [
>       "SlotStatus"
>     ],
>     "attrsFormat": "legacy"
>   }
> }'
> After I send some measurement from the device.
> url = 'http://localhost:7896/iot/d?i=711&k=4jggokgpepnvsb2uv4s40d59ov'
> headers = {'Content-Type': "text/plain", 'fiware-service': "smartparking_pmr", 'fiware-servicepath': "/mtp"}
> data = "s|0|lat|13.3903|lon|52.5075"
> data_raw = data.encode('utf-8')
> res = requests.post(url, data=data_raw, headers=headers)
> I checked that the subscription exists into Orion.
> curl -X GET 
>   'http://localhost:1026/v2/subscriptions/' 
>   -H 'fiware-service: smartparking_pmr' 
>   -H 'fiware-servicepath: '/mtp"
> And that is the case (you can see the last update coming from the device)
> [{"id":"6037a3e82e21184c83eeeadd","description":"Notify STH-Comet of all smartparking_pmr SlotStatus changes","status":"active","subject":{"entities":[{"idPattern":"Pmr.*"}],"condition":{"attrs":["SlotStatus"]}},"notification":{"timesSent":15,"lastNotification":"2021-02-25T14:35:37.000Z","attrs":["SlotStatus"],"onlyChangedAttrs":false,"attrsFormat":"legacy","http":{"url":"http://sth-comet:8666/notify"},"lastSuccess":"2021-02-25T14:35:37.000Z","lastSuccessCode":200}},{"id":"6037b1742e21184c83eeeade","description":"Notify STH-Comet of all smartparking_pmr SlotStatus changes","status":"active","subject":{"entities":[{"idPattern":"Pmr.*"}],"condition":{"attrs":["s"]}},"notification":{"attrs":["s"],"onlyChangedAttrs":false,"attrsFormat":"legacy","http":{"url":"http://sth-comet:8666/notify"}}},{"id":"6037b91e072e0f6c2a7d46e2","description":"Notify STH-Comet of all smartparking_pmr SlotStatus changes","status":"active","subject":{"entities":[{"idPattern":"Pmr.*"}],"condition":{"attrs":["s"]}},"notification":{"attrs":["s"],"onlyChangedAttrs":false,"attrsFormat":"legacy","http":{"url":"http://sth-comet:8666/notify"}}},{"id":"6037b95c072e0f6c2a7d46e3","description":"Notify STH-Comet of all smartparking_pmr SlotStatus changes","status":"active","subject":{"entities":[{"idPattern":"Pmr.*"}],"condition":{"attrs":["SlotStatus"]}},"notification":{"timesSent":1,"lastNotification":"2021-02-25T14:51:08.000Z","attrs":["SlotStatus"],"onlyChangedAttrs":false,"attrsFormat":"legacy","http":{"url":"http://sth-comet:8666/notify"},"lastSuccess":"2021-02-25T14:51:08.000Z","lastSuccessCode":400}},{"id":"6037b95f072e0f6c2a7d46e4","description":"Notify STH-Comet of all smartparking_pmr SlotStatus changes","status":"active","subject":{"entities":[{"idPattern":"Pmr.*"}],"condition":{"attrs":["SlotStatus"]}},"notification":{"timesSent":1,"lastNotification":"2021-02-25T14:51:11.000Z","attrs":["SlotStatus"],"onlyChangedAttrs":false,"attrsFormat":"legacy","http":{"url":"http://sth-comet:8666/notify"},"lastSuccess":"2021-02-25T14:51:11.000Z","lastSuccessCode":400}}]
> Finally I want to query data from STH-Comet.
> curl "http://localhost:8666/STH/v1/contextEntities/type/PMR/id/Pmr:711/attributes/SlotStatus?lastN=10" --header "fiware-service: smartparking_pmr" --header "fiware-servicepath: /mtp"
> But I get empty values for whatever reason.
> {"contextResponses":[{"contextElement":{"attributes":[{"name":"SlotStatus","values":[]}],"id":"Pmr:711","isPattern":false,"type":"PMR"},"statusCode":{"code":"200","reasonPhrase":"OK"}}]}
> Here are the logs from the STH-Comet console.
> time=2021-02-25T14:56:57.921Z | lvl=DEBUG | corr=2dd3ef29-df47-4520-9ee3-c0dfccd5a51b | trans=2dd3ef29-df47-4520-9ee3-c0dfccd5a51b | op=OPER_STH_GET | from=n/a | srv=smartparking_pmr | subsrv=/mtp | comp=STH | msg=GET /STH/v1/contextEntities/type/PMR/id/Pmr:711/attributes/SlotStatus?lastN=10
> time=2021-02-25T14:56:57.921Z | lvl=DEBUG | corr=2dd3ef29-df47-4520-9ee3-c0dfccd5a51b | trans=2dd3ef29-df47-4520-9ee3-c0dfccd5a51b | op=OPER_STH_GET | from=n/a | srv=smartparking_pmr | subsrv=/mtp | comp=STH | msg=Getting access to the raw data collection for retrieval...
> time=2021-02-25T14:56:57.924Z | lvl=WARN | corr=2dd3ef29-df47-4520-9ee3-c0dfccd5a51b | trans=2dd3ef29-df47-4520-9ee3-c0dfccd5a51b | op=OPER_STH_GET | from=n/a | srv=smartparking_pmr | subsrv=/mtp | comp=STH | msg=Error when getting the raw data collection for retrieval (the collection 'null' may not exist)
> time=2021-02-25T14:56:57.924Z | lvl=DEBUG | corr=2dd3ef29-df47-4520-9ee3-c0dfccd5a51b | trans=2dd3ef29-df47-4520-9ee3-c0dfccd5a51b | op=OPER_STH_GET | from=n/a | srv=smartparking_pmr | subsrv=/mtp | comp=STH | msg=Responding with no points
> This is strange since I can see that the measurement has been recorded by querying Orion.
> curl -v http://localhost:1026/v2/entities/urn:ngsi-ld:Pmr:711 --header "Fiware-Service: smartparking_pmr" --header "Fiware-ServicePath: /mtp"
> Which gives:
> {"id":"urn:ngsi-ld:Pmr:711","type":"PMR","Latitude":{"type":"Double","value":"13.3903","metadata":{"TimeInstant":{"type":"DateTime","value":"2021-02-25T14:35:35.743Z"}}},"Longitude":{"type":"Double","value":"52.5075","metadata":{"TimeInstant":{"type":"DateTime","value":"2021-02-25T14:35:35.743Z"}}},"SlotStatus":{"type":"Integer","value":"0","metadata":{"TimeInstant":{"type":"DateTime","value":"2021-02-25T14:35:35.743Z"}}},"TimeInstant":{"type":"DateTime","value":"2021-02-25T14:35:35.743Z","metadata":{}}}
> Could you please help me out? Thanks in advance.
> Regards,



--
This message was sent by Atlassian JIRA
(v6.4.1#64016)


More information about the Backlogmanager mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy