首先我使用此脚本注册服务
卷曲-H"内容类型:application / json" -H" Fiware-Service: 开罗大学" -H" Fiware-ServicePath:/ FCI / ICDL" \ http://X.X.X.X:4041/iot/services -d' {"服务":[ { " apikey":" api1", " cbroker":" http://0.0.0.0:1026", " entity_type":" Camps", "资源":" / iot / d" }]}'
然后我使用此
注册设备卷曲http://X.X.X.X:4041/iot/devices \ -H"内容类型: 应用/ JSON" -H" Fiware-Service:cairoUniversity" -H " Fiware-ServicePath:/ FCI / ICDL" \ -d' {"设备":[ { " device_id":" smartmeter2", " entity_name":" ICDL2", " entity_type":" Camps", " protocol":" PDI-IoTA-UltraLight", "时区":"欧洲/马德里", "属性":[ { " object_id":" c", " name":" Conscemption", "输入":" int" } ] }]}'
然后我订阅orion
curl -X POST -H" Content-Type:application / json" -H"接受: 应用/ JSON" -H" Fiware-Service:cairoUniversity" \ -H" Fiware-ServicePath:/ FCI / ICDL" -H"缓存控制:无缓存" -d' { "实体":[ { "输入":" Camps", " isPattern":" false", " id":" ICDL2" } ] 的> "属性":[ " Conscemption" ] "参考":" http ://X.X.X.X:8666 / notify", "持续时间":" P1M", " notifyConditions":[ { "输入":" ONCHANGE", " condValues":[ " Conscemption" ] } ]}' " http://X.X.X.X:1026/v1/subscribeContext" }
之后我发送观察
卷曲" http://X.X.X.X:7896/iot/d?k=api1&i=smartmeter2" -d' c | 47' -H "内容类型: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'接受:application / json' \ -H'缓存控制:无缓存' \
-H' content-type:application / json' \ -H' fiware-service:cairoUniversity' \ -H' fiware-servicepath:/ FCI / ICDL' |蟒蛇 -mjson.tool}
我得到了这个回复
" contextResponses":[ { " contextElement":{ "属性":[ { " name":" Conscemption", "值":[] } ] " id":" ICDL", " isPattern":false, "输入":" Camps" }, " statusCode":{ "代码":" 200", " reasonPhrase":" OK" } } ]
这就是日志
sth-comet |时间= 2017-09-04T14:26:44.782Z | lvl = INFO | corr = n / a | trans = n / a | op = OPER_STH_SERVER_LOG | from = n / a | srv =不适用| subsrv = n / a | comp = STH | msg =一切都好,过去60年代有0个请求 间隔sth-comet |时间= 2017-09-04T14:27:44.787Z | lvl = INFO | corr = n / a | trans = n / a | op = OPER_STH_SERVER_LOG | from = n / a | srv =不适用| subsrv = n / a | comp = STH | msg =一切正常,0请求参加 过去60s间隔sth-comet |时间= 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 =开罗大学| subsrv = / FCI / ICDL | comp = STH |> msg =获取聚合数据集合以进行检索时出错 (该集合可能不存在)
sth-comet |时间= 2017-09-04T14:28:44.792Z | lvl = INFO | corr = n / a | trans = n / a | op = OPER_STH_SERVER_LOG | from = n / a | srv =不适用| subsrv = n / a | comp = STH | msg =一切都好,过去60年代有0个请求 间隔sth-comet |时间= 2017-09-04T14:29:44.797Z | lvl = INFO | corr = n / a | trans = n / a | op = OPER_STH_SERVER_LOG | from = n / a | srv =不适用| subsrv = n / a | comp = STH | msg =一切正常,0请求参加 过去60s间隔sth-comet |时间= 2017-09-04T14:30:44.805Z | lvl = INFO | corr = n / a | trans = n / a | op = OPER_STH_SERVER_LOG | from = n / a | srv =不适用| subsrv = n / a | comp = STH | msg =一切正常,0请求 参加过去60年代的间隔期间 时间= 2017-09-04T14:31:44.811Z | lvl = INFO | corr = n / a | trans = n / a | op = OPER_STH_SERVER_LOG | from = n / a | srv =不适用| subsrv = n / a | comp = STH | msg =一切正常,在过去的60s间隔内有0个请求
这个问题可以解决这个问题以及如何解决它
答案 0 :(得分:1)
根据您发布的日志,通知永远不会到达SHT服务,这就是为什么在获取用于检索的聚合数据集合时收到msg =错误(集合可能不存在)所以问题看起来与如何你在猎户座创建实体。
我注意到你已经创建了一个名为ICDL2的实体,在这个实体中你包含了属性" name":" Conscemption"," type":& #34; INT"但从不包括"价值"属性,因此当您发送数据时,它永远不会在该实体中更新。
其次,您以这种方式将数据发送到您的设备" curl" http://X.X.X.X:7896/iot/d?k=api1&i=smartmeter2" -d' c | 47' -H"内容类型:text / plain"但正如我之前告诉你的那样,47' 47'永远不会写在实体中,因为它没有被创建,你把触发器关联到值" name":" Conscemption"但它永远不会改变,因为它没有属性值。
因此,管理您的实体和订阅ORION似乎是一个问题,您可以找到有关如何在ORION中创建和更新实体的更多信息以及如何在https://fiware-orion.readthedocs.io/en/master/user/walkthrough_apiv1/index.html#introduction中进行一些测试。在您确定Orion向您发送通知后,您可以在STH彗星中查看您的数据。此外,如果您有关于软件产品的问题,您可以在https://jira.fiware.org中发布问题,并直接回答每个软件组件的团队。