问题描述
错误:无法将字符串强制转换为 nodeId
嗨, 我正忙于使用 opcua iotagent 代理在 Orion broker 和带有 OPC-UA 服务器的 PLC 之间建立连接。 我设法设置了所有部分,并且能够接收(测试)数据,但是我无法按照教程使用 json 文件将实体添加到 Orion-broker:
curl http://localhost:4001/iot/devices -H "fiware-service: plcservice" -H "fiware-servicepath: /demo" -H "Content-Type: application/json" -d @add_device.json
预期的结果是使用提供的数据向 Orionbroker 添加实体,但这只会导致错误消息:
{"name":"Error","message":"String cannot be coerced to a nodeId : ns*4:s*MAIN.mainVar"}
疑似错误
iotagent 是否可能无法很好地处理嵌套变量?
采取的步骤
附加信息:
add_device.json 文件:
{
"devices": [
{
"device_id": "plc1","entity_name": "PLC1","entity_type": "plc","attributes": [
{
"object_id": "ns*4:s*MAIN.mainVar","name": "main","type": "Number"
}
],"lazy": [
],"commands" : []
}
]
}
IOT-agent 的配置(来自 localhost:4081/config):
{
"config": {
"logLevel": "DEBUG","contextbroker": {
"host": "orion","port": 1026
},"server": {
"port": 4001,"baseRoot": "/"
},"deviceRegistry": {
"type": "memory"
},"mongodb": {
"host": "iotmongo","port": "27017","db": "iotagent","retries": 5,"retryTime": 5
},"types": {
"plc": {
"service": "plcservice","subservice": "/demo","active": [
{
"name": "main","type": "Int16"
},{
"name": "test1",{
"name": "test2","type": "Int16"
}
],"lazy": [],"commands": []
}
},"browseServerOptions": null,"service": "plc","providerUrl": "http://iotage:4001","pollingExpiration": "200000","pollingDaemonFrequency": "20000","deviceRegistrationDuration": "P1M","defaultType": null,"contexts": [
{
"id": "plc_1","type": "plc","service": "plcservice","polling": false,"mappings": [
{
"ocb_id": "test1","opcua_id": "ns=4;s=test.Testvar.test1","object_id": null,"inputArguments": []
},{
"ocb_id": "test2","opcua_id": "ns=4;s=test.Testvar.test2",{
"ocb_id": "main","opcua_id": "ns=4;s=MAIN.mainVar","inputArguments": []
}
]
}
]
}
}
解决方法
我是 iotagent-opcua 存储库的维护者之一,我们已经确定并修复了您要解决的错误,请将您的代理更新到最新版本 (1.4.0)
如果您从未听说过它,从 1.3.8 开始,我们引入了一个名为“relaxTemplateValidation”的新配置属性,它允许您使用以前禁止的字符(例如 = 和 ; )。建议你看一下提供的配置示例。