首页 > 解决方案 > 不支持设备配置属性中的 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 专家的一些快速确认和帮助来解决这个问题,非常感谢。

标签: jsonfiware

解决方案


检查有效供应请求的模板当前不接受元数据属性。为此有一个出色的公关。目前,您最好使用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


推荐阅读