|
1 | | -Let’s review more examples of device name expression and device profile expression fields. |
2 | | - |
3 | | -These fields allow for the dynamic construction of a formatted device name/profile using values extracted from a JSON object. |
4 | | -You can specify variables to access the relevant fields in the JSON. |
5 | | - |
6 | | -You can use the following variables to extract specific device information: |
7 | | -- **objectName** - extracts the device's object name (e.g., "Main Controller"); |
8 | | -- **vendorId** - extracts the device's vendor ID, typically a numeric identifier representing the manufacturer (e.g., "1234"); |
9 | | -- **objectId** - extracts the device's unique object identifier (e.g., "999"); |
10 | | -- **address** - extracts the device's network address (e.g., "192.168.1.1"). |
11 | | - |
12 | | -**Examples:** |
13 | | -- "**Device ${objectName}**" If the objectName variable exists and contains "**objectName": "Main Controller**", |
14 | | - the device on platform will have the following name: **Device Main Controller**; |
15 | | -- "**Vendor: ${vendorId}**" If the vendorId variable exists and contains **"vendorId": 1234**, the device on platform |
16 | | - will have the following name: **Vendor: 1234**; |
17 | | -- "**Device ID: ${objectId} at ${address}**" If the objectId variable exists and contains **"vendorId": 999** and |
18 | | - address variable exists and contains **"address": "192.168.1.1"**, the device on platform will have the following |
19 | | - name: **Device ID: 999 at 192.168.1.1**. |
| 1 | +BACnet connector allows you to set dynamic device names and profiles using expressions. This is especially useful when |
| 2 | +you have multiple devices with similar configurations and want to differentiate them based on their properties. |
| 3 | +In this example, we will configure a BACnet device to have a dynamic device name based on its `objectName` and `address` |
| 4 | +properties and a dynamic device profile based on its `vendorId` property. |
20 | 5 |
|
| 6 | +Here is an example configuration snippet for a BACnet device with dynamic device name and profile: |
| 7 | + |
| 8 | +```json |
| 9 | +{ |
| 10 | + "application": { |
| 11 | + "objectName": "TB_gateway", |
| 12 | + "host": "YOUR_HOST", |
| 13 | + "port": 47808, |
| 14 | + "mask": 24, |
| 15 | + "objectIdentifier": 599, |
| 16 | + "maxApduLengthAccepted": 1476, |
| 17 | + "segmentationSupported": "segmentedBoth", |
| 18 | + "vendorIdentifier": 15, |
| 19 | + "deviceDiscoveryTimeoutInSec": 5, |
| 20 | + "devicesDiscoverPeriodSeconds": 30 |
| 21 | + }, |
| 22 | + "devices": [ |
| 23 | + { |
| 24 | + "host": "*", |
| 25 | + "port": "*", |
| 26 | + "pollPeriod": 10000, |
| 27 | + "deviceInfo": { |
| 28 | + "deviceNameExpressionSource": "expression", |
| 29 | + "deviceNameExpression": "${objectName} at ${address}", |
| 30 | + "deviceProfileExpressionSource": "expression", |
| 31 | + "deviceProfileExpression": "${vendorId}_profile" |
| 32 | + }, |
| 33 | + "attributes": [], |
| 34 | + "timeseries": "*", |
| 35 | + "attributeUpdates": [], |
| 36 | + "serverSideRpc": [] |
| 37 | + } |
| 38 | + ] |
| 39 | +} |
| 40 | +``` |
| 41 | +{:.copy-code} |
| 42 | + |
| 43 | +In this configuration: |
| 44 | +- The `deviceNameExpression` is set to `${objectName} at ${address}`, which will create a device name that includes the |
| 45 | + device's object name and address. |
| 46 | +- The `deviceProfileExpression` is set to `${vendorId}_profile`, which will create a device profile name based on the vendor ID of the device. |
| 47 | + |
| 48 | +After applying this configuration, the device will be created with a name and profile that reflect its specific |
| 49 | +properties. The screenshot below shows how the device appears in ThingsBoard with the dynamic name and profile: |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +As you can see, the device name is generated based on the `objectName` and `address`, and the device profile is based |
| 54 | +on the `vendorId`. |
| 55 | + |
| 56 | +Device name/profile dynamic expressions provide flexibility in managing multiple BACnet devices with varying |
| 57 | +configurations and can help in organizing devices effectively within ThingsBoard. |
| 58 | + |
| 59 | +{% capture dynamicDeviceNameProfileExample %} |
21 | 60 | You can find full list of available variables in |
22 | 61 | the [Advanced configuration](/docs/iot-gateway/config/bacnet/#available-variables-for-device-nameprofile-expressions) section. |
| 62 | +{% endcapture %} |
| 63 | +{% include templates/info-banner.md content=dynamicDeviceNameProfileExample %} |
0 commit comments