thingsboard / thingsboard-gateway

Open-source IoT Gateway - integrates devices connected to legacy and third-party systems with ThingsBoard IoT Platform using Modbus, CAN bus, BACnet, BLE, OPC-UA, MQTT, ODBC and REST protocols
https://thingsboard.io/docs/iot-gateway/what-is-iot-gateway/
Apache License 2.0
1.72k stars 829 forks source link

[HELP] deviceNamePattern not recognizing certain paths #1475

Closed ivanlr closed 1 month ago

ivanlr commented 1 month ago

Describe the issue Create description about your issue, and your actions to solve it. When I try to set the deviceNamePattern in connector's JSON to "Device ${Root\.Objects\.Facility\.A_5\.Label}", the device is created with the literal name "Device ${Root\.Objects\.Facility\.A_5\.Label}", while it should be created under the name: "Device xXXX", as xXXX is the value of the node ${Root\.Objects\.Facility\.A_5\.Label}.

It is weird, as when I try "deviceNamePattern": "Device ${Root\.Objects\.Server\.Label}", it catchs the value of the node and correctly creates the device with expected name. It seems that paths under Server node are well recognized, but under any other different than Server is not caught.

Configuration (Attach your configuration file) Notate: Remove Access token from file if you want to attach a tb_gateway.yaml Connector JSON: { "server": { "name": "Test", "url": "xxxx", "timeoutInMillis": 5000, "scanPeriodInMillis": 5000, "disableSubscriptions": true, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" }, "mapping": [ { "deviceNodePattern": "Root\.Objects\.Server", "deviceNamePattern": "Device ${Root\.Objects\.Server\.Label}", "attributes": [], "timeseries": [ { "key": "MySampleVar", "path": "${ns=2;xxxxxxxxxxxxxxxxxxxxx}" }, ] }, { "deviceNodePattern": "Root\.Objects\.Server", "deviceNamePattern": "Device ${Root\.Objects\.Facility\.A_5\.Label}", "attributes": [], "timeseries": [ { "key": "MySampleVar", "path": "${ns=2;xxxxxxxxxxxxxxxxxxxxx}" } ] } ] }, "logLevel": "DEBUG", "name": "Test", "enableRemoteLogging": false, "id": "76683839-58df-4d04-9774-xxxxxxxxxxx" }

Connector name (If you need help with some connector/converter): OPC-UA Connector

Error traceback (If it was raised):

Versions (please complete the following information):

samson0v commented 1 month ago

Hi @ivanlr, thanks for your interest in ThingsBoard IoT Gateway! I tried to reproduce your issue but didn't get a result and the device pattern works well. My config was the following:

"deviceNamePattern": "Demo Device ${Root\\.Objects\\.MyObject\\.MyStringVariable}",

Node value on the demo OPC-UA server: image

A created device on ThingsBoard:

image

Please, try to use a version of the gateway from this PR.