json - 不支持设备配置属性中的 NGSIv2 元数据
问题描述
我们使用了 docker hub 的 IoT 代理 -1.14.0 版本。我们给出的服务和服务路径如下 fiware-service:testiotagent fiware-servicepath:/
设备注册负载:
{
"devices": [
{
"device_id":"Motion-10",
"entity_name":"urn:ngsi-ld:SENSOR:Motion-10",
"entity_type":"SENSOR",
"transport": "MQTT",
"attributes": [
{"object_id": "s", "name": "state", "type":"Text"},
{"object_id": "l", "name": "luminosity", "type":"Integer",
"metadata":{ "unitCode":{"type": "Text", "value" :"CAL"}
}
}
]
}
]
}
根据 iotagent 节点库版本 2.12.0 ,IoT 代理 json -1.14.0 版本应支持设备配置属性中的元数据。但仍然面临问题。当我们尝试配置上述设备时,我们收到以下错误:
{
"name": "WRONG_SYNTAX",
"message": "Wrong syntax in request: Errors found validating request."
}
我发现 iotagent-node-lib 具有验证设备注册有效负载的架构
https://github.com/telefonicaid/iotagent-node-lib/blob/master/lib/templates/createDevice.json
在这个 json 模式中,属性中没有提到元数据模式。
对于实体级别的元数据,我已按照以下步骤操作:
我已删除 IoT 代理中的元数据 更新了实体 'urn:ngsi-ld:SENSOR:Motion-10' 如下
{
"id":"urn:ngsi-ld:SENSOR:Motion-10",
"type":"SENSOR",
"luminosity":{
"type":"Integer",
"value":"0",
"metadata":{ "unitCode":{"type": "Text", "value" :"CAL"}
}
}
试图发送测量结果和元数据被覆盖并得到空的元数据
{
"id":"urn:ngsi-ld:SENSOR:Motion-10",
"type":"SENSOR",
"luminosity":{
"type":"Integer",
"value":"15",
"metadata":{}
}
}
是由于在 fiware-orion 中为问题 1788 提供的修复,https: //github.com/telefonicaid/fiware-orion/issues?q=1788 。需要 Fiware 专家的一些快速确认和帮助来解决这个问题,非常感谢。
解决方案
检查有效供应请求的模板当前不接受元数据属性。为此有一个出色的公关。目前,您最好使用metadata
文件中的来定义实体config.js
。
例如:
iotAgentConfig = {
contextBroker: {
host: '192.168.1.1',
port: '1026',
ngsiVersion: 'v2'
},
server: {
port: 4041
},
types: {
'WeatherStation': {
commands: [],
type: 'WeatherStation',
lazy: [],
active: [
{
object_id: 'p',
name: 'pressure',
type: 'Hgmm'
},
{
object_id: 'h',
name: 'humidity',
type: 'Percentage',
entity_name: 'Higro2000',
entity_type: 'Higrometer',
metadata:{
unitCode:{
type: "Text", value :"Hgmm"
}
}
}
]
},
....etc
推荐阅读
- postgresql - 是否可以在无需查询的情况下为 GCP Postgres 用户提供 r/w 访问权限?
- spring - 为什么@Service 不创建 bean?
- pyspark - PySpark 中的分位数转换器
- powerapps - 我们可以用 ms 流的结果填充画布应用程序中的下拉列表吗
- c# - 在带有隐藏 asp-for 输入的剃须刀页面中使用 foreach 会导致在浏览器控制台中找到具有非唯一 ID 的元素
- forms - 如何获取访问表单中显示的行数
- npm - NPM 中的依赖解析
- javascript - 我的 Discord 机器人多次重复相同的消息
- r - 通过格式不一致的 id 将空间特征与数据框连接起来
- java - JPF 符号字符串未生成预期 PC 的 [Java 路径查找器]