首页 文章

Orion CB在'id'字段中使用'entity_name'值保存设备

提问于
浏览
1

我正在尝试使用延迟属性开发IoTA . 并且发现Context Broker将设备'entity_name'字段保存在'id'中,因此当CB请求延迟属性时,IoTA找不到具有这种id的设备 .

为了创建设备实体,我向IoTA提出了这个请求:

'devices': [{
    'device_id': 'idSensor14',
    'entity_name': 'nameSensor14',
    'entity_type': 'anysensor',
    'attributes': [
        {
            'name': 't',
            'type': 'celsius'
        }
    ],
    'lazy': [
        {
            'name': 'b',
            'type': 'mybits'
        }
    ]                 
}]

然后,如果我们在CB('v2 / entities /')中请求授权列表,我们会发现:

{ "id":"nameSensor15",
    "type":"anysensor",
    "t":{"type":"celsius","value":"","metadata":{}}}

似乎CB使用错误的id保存设备 . 这是对延迟属性的请求:

data = {
    "entities": [{
        "isPattern": "false",
        "id": myid,
        "type": entity_type
    },
    "attributes": ["b"]
]}

这是IoA日志中的错误:

op = IoTAgentNGSI.ContextServer | srv = myhome | subsrv = / sensors | msg =查询错误[DEVICE_NOT_FOUND]处理请求:未找到ID为:nameSensor15的设备

如果从注册请求中删除entity_name,则CB将使用device id ='anysensors:idSensor14' . 我的Orion版本是1.7.0,iotagent-node-lib版本是2.5.1 .

2 回答

  • 0

    原因是在软件服务名称中使用大写字母作为设备注册头和iota配置,因此我应该使用 myhome 而不是 myHome . 对于内存和mongo设备注册表类型也是如此 .

  • 1

    IOTAgent应使用 entity_name 作为 id 在CB中创建实体 . 在您的情况下,这意味着 nameSensor14 .

    也许您看到的 nameSensor15 对应于其他一些配置操作 .

    我建议做一个干净的测试 . 我的意思是:

    • 停止所有进程(IOTA和CB) .

    • 清理所有数据库(在Mongo shell中查找以 orioniot 开头的数据库)

    • 启动CB

    • 启动IOTAgent

    • 运行创建设备请求

    • 在运行任何其他请求之前,检查CB上的实体( GET /v2/entities )和注册( GET v1/registry/contextEntities/<entity_id> ),以便查看实体是使用正确的id创建的,以及与lazy属性对应的注册 .

相关问题