Details
-
Type: Monitor
-
Status: Open
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: FIWARE-TECH-HELP
Description
Created question in FIWARE Q/A platform on 25-02-2021 at 14:02
Please, ANSWER this question AT 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 =
data = {
"services": [
]
}
Then I registered the device.
url = 'http://localhost:4041/iot/devices'
headers =
data = {
"devices": [
{
"device_id": "711",
"entity_name": "urn:ngsi-ld:Pmr:711",
"entity_type": "PMR",
"timezone": "Europe/Berlin",
"attributes": [
,
,
{ "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": [
],
"condition":
},
"notification": {
"http":
,
"attrs": [
"SlotStatus"
],
"attrsFormat": "legacy"
}
}'
After I send some measurement from the device.
url = 'http://localhost:7896/iot/d?i=711&k=4jggokgpepnvsb2uv4s40d59ov'
headers =
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":[
],"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":[
],"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":
}},"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,
Activity
Field | Original Value | New Value |
---|---|---|
Component/s | FIWARE-TECH-HELP [ 10278 ] |
Assignee | Fermín Galán [ fermin ] |
2021-03-01 09:40|CREATED monitor | # answers= 0, accepted answer= False