我们已经使用了来自docker hub的IoT代理-1.14.0版本。我们给出的service和servicepath如下: 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 node lib版本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,https://github.com/telefonicaid/fiware-orion/issues?q=1788中给出的问题1788的修复。需要一些qucik确认和Fiware专家的帮助来解决这个问题,非常感谢。
发布于 2020-06-04 21:53:33
检查有效供应请求的模板当前不接受metadata属性。在这方面有一个出色的PR。此时,您最好在config.js文件中使用metadata定义实体。
例如:
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"
}
}
}
]
},
....etchttps://stackoverflow.com/questions/62001030
复制相似问题