从 sth-comet 检索数据时出错获取空值

Error get empty value when retriving data from sth-comet

首先我使用这个脚本注册服务

curl -H "Content-type: application/json" -H "Fiware-Service: cairoUniversity" -H "Fiware-ServicePath: /FCI/ICDL" \ http://X.X.X.X:4041/iot/services -d '{ "services": [ { "apikey": "api1", "cbroker": "http://0.0.0.0:1026", "entity_type": "Camps", "resource": "/iot/d" } ] }'

然后我使用这个注册设备

curl http://X.X.X.X:4041/iot/devices \ -H "Content-type: application/json" -H "Fiware-Service:cairoUniversity" -H "Fiware-ServicePath: /FCI/ICDL" \ -d '{ "devices": [ { "device_id": "smartmeter2", "entity_name": "ICDL2", "entity_type": "Camps", "protocol": "PDI-IoTA-UltraLight", "timezone": "Europe/Madrid", "attributes": [ { "object_id": "c", "name": "Conscemption", "type": "int" } ] } ] }'

然后我订阅 orion

curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "Fiware-Service: cairoUniversity" \ -H "Fiware-ServicePath: /FCI/ICDL" -H "Cache-Control: no-cache" -d '{ "entities": [ { "type": "Camps", "isPattern": "false", "id": "ICDL2" } ], > "attributes": [ "Conscemption" ], "reference": "http://X.X.X.X:8666/notify", "duration": "P1M", "notifyConditions": [ { "type": "ONCHANGE", "condValues": [ "Conscemption" ] } ] }' "http://X.X.X.X:1026/v1/subscribeContext" }

之后我发送观察

curl "http://X.X.X.X:7896/iot/d?k=api1&i=smartmeter2" -d 'c|47' -H "Content-type: text/plain"

并最终从某处检索数据

curl -X GET \
'http://X.X.X.X:8666/STH/v1/contextEntities/type/Camps/id/ICDL/attributes/Conscemption?aggrMethod=min&aggrPeriod=day&dateFrom=2015-01-28T00%3A00%3A00&dateTo=2018-01-01T23%3A59%3A59' \ -H 'accept: application/json' \ -H 'cache-control: no-cache' \
-H 'content-type: application/json' \ -H 'fiware-service: cairoUniversity' \ -H 'fiware-servicepath: /FCI/ICDL' | python -mjson.tool }

我收到了这个回复

"contextResponses": [ { "contextElement": { "attributes": [ { "name": "Conscemption", "values": [] } ], "id": "ICDL", "isPattern": false, "type": "Camps" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ]

这是日志

sth-comet | time=2017-09-04T14:26:44.782Z | lvl=INFO | corr=n/a | trans=n/a | op=OPER_STH_SERVER_LOG | from=n/a | srv=n/a | subsrv=n/a | comp=STH | msg=Everything OK, 0 requests attended in the last 60s interval sth-comet | time=2017-09-04T14:27:44.787Z | lvl=INFO | corr=n/a | trans=n/a | op=OPER_STH_SERVER_LOG | from=n/a | srv=n/a | subsrv=n/a | comp=STH | msg=Everything OK, 0 requests attended in the last 60s interval

sth-comet | time=2017-09-04T14:27:52.834Z | lvl=WARN | corr=99577e81-bbd4-4130-95f6-a9d029f84db0 | trans=99577e81-bbd4-4130-95f6-a9d029f84db0 | op=OPER_STH_GET | from=n/a | srv=cairoUniversity | subsrv=/FCI/ICDL | comp=STH |

> msg=获取聚合数据集合进行检索时出错 (该集合可能不存在)

某彗星 |时间=2017-09-04T14:28:44.792Z | lvl=信息 |更正=n/a | 反式=n/a | op=[​​=60=] |来自=n/a | srv=n/a | subsrv=n/a | 比较=某事 | msg=Everything OK, 0 requests attended in the last 60s 间隔某彗星 |时间=2017-09-04T14:29:44.797Z | lvl=信息 | 更正=n/a |反式=n/a | op=[​​=60=] |来自=n/a | srv=n/a | subsrv=n/a |比较=某事 | msg=Everything OK, 0 个请求参加了 最后 60 秒间隔某彗星 |时间=2017-09-04T14:30:44.805Z | lvl=信息 |更正=n/a |反式=n/a | op=[​​=60=] |来自=n/a | srv=n/a | subsrv=n/a |比较=某事 | msg=一切正常,0 个请求 参加了上世纪 60 年代的某彗星 | 时间=2017-09-04T14:31:44.811Z | lvl=信息 |更正=n/a |反式=n/a | op=[​​=60=] |来自=n/a | srv=n/a | subsrv=n/a |比较=某事 | msg=一切正常,在过去的 60 秒间隔内有 0 个请求

什么可能导致这个问题以及如何解决它

根据您发布的日志,通知永远不会到达 SHT 服务,这就是为什么您在获取用于检索的聚合数据集合(集合可能不存在)时收到 msg=Error 的原因,所以问题看起来是相关的了解如何在 Orion 中创建实体。

我注意到您创建了一个名为 ICDL2 的实体,在此实体中您包含属性 "name": "Conscemption", "type": "int" 但从未包含"value" 属性,因此当您发送数据时,它永远不会在该实体中更新。

其次,您以这种方式将数据发送到您的设备 "curl "http://X.X.X.X:7896/iot/d?k=api1&i=smartmeter2" -d 'c|47' -H "Content-type: text/plain" 但正如我之前告诉您的值 ' 47' 永远不会写入实体,因为它未创建,您将触发器关联到值 "name": "Conscemption" 但它永远不会更改,因为没有属性值。

所以管理您的实体和订阅 ORION 似乎是个问题,您可以找到更多关于如何在 ORION 中创建和更新实体以及如何进行一些测试的信息:https://fiware-orion.readthedocs.io/en/master/user/walkthrough_apiv1/index.html#introduction . After you are sure that Orion sends to you the notifications you can look your data in STH comet. Also, if you have questions related to the fiware products you can post the questions in https://jira.fiware.org 并收到fiware各组件团队直答