Skip to content

Commit 4e6bcef

Browse files
samson0vashvayka
authored andcommitted
Updated BACnet connector old examples
1 parent c992d3c commit 4e6bcef

File tree

5 files changed

+113
-28
lines changed

5 files changed

+113
-28
lines changed
Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,58 @@
1-
Let's review more examples of alternative responses addresses.
1+
Alternative response addresses field allows you to specify an alternative IP address for device responses.
2+
It is especially useful when the gateway and the BACnet device are located in different networks.
23

3-
This field allows you to specify an alternative address for responses from the device.
4-
It is useful when the gateway and BACnet device are located in different networks.
4+
For example, consider the following network setup:
5+
6+
![image](/images/gateway/bacnet-connector/examples/alternative-responses-addresses-network-setup.png)
7+
8+
In this setup, the gateway runs inside a Docker container and the BACnet device is located on a local network with IP
9+
address `192.168.1.200:45606` and is not directly accessible from the Docker container. BACPypes sends APDUs to the
10+
gateway without including the port number, making it impossible for the connector to determine whether a response came
11+
from an allowed device. When you configure an alternative response address, the connector uses this IP to correctly
12+
recognize and validate the device.
13+
14+
To configure the alternative response address, you need to add the `altResponsesAddresses` field to the device
15+
configuration. Here is an example configuration snippet:
516

6-
For example, if gateway running via the docker container and the BACnet device is located in the local network under
7-
192.168.1.200:45606, you can specify the IP address of the BACnet device in the alternative responses addresses field.
817
```json
9-
"altResponsesAddresses": ["192.168.1.200"]
18+
{
19+
"application": {
20+
"objectName": "TB_gateway",
21+
"host": "0.0.0.0",
22+
"port": 47808,
23+
"mask": 24,
24+
"objectIdentifier": 599,
25+
"maxApduLengthAccepted": 1476,
26+
"segmentationSupported": "segmentedBoth",
27+
"vendorIdentifier": 15,
28+
"deviceDiscoveryTimeoutInSec": 5,
29+
"devicesDiscoverPeriodSeconds": 30
30+
},
31+
"devices": [
32+
{
33+
"deviceInfo": {
34+
"deviceNameExpressionSource": "expression",
35+
"deviceNameExpression": "BACnet Device ${objectName}",
36+
"deviceProfileExpressionSource": "constant",
37+
"deviceProfileExpression": "default"
38+
},
39+
"host": "192.168.1.200",
40+
"port": 45606,
41+
"altResponsesAddresses": ["192.168.1.200"],
42+
"pollPeriod": 10000,
43+
"attributes": [],
44+
"timeseries": "*",
45+
"attributeUpdates": [],
46+
"serverSideRpc": []
47+
}
48+
]
49+
}
1050
```
51+
{:.copy-code}
52+
53+
After applying this configuration, the connector will use the specified alternative response address
54+
`192.168.1.200:45606` to recognize and validate responses from the BACnet device. This ensures that the connector can
55+
communicate effectively with the device even when they are located in different networks. As a result, you should see
56+
created device in ThingsBoard:
1157

12-
This is important because bacpypes provide APDU to the gateway without port number, so the connector can't determine if
13-
it is an allowed device. In this case, the connector will use the alternative address to determine that it is an allowed
14-
device.
58+
![image](/images/gateway/bacnet-connector/examples/alternative-responses-addresses-overview.png)
Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,63 @@
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.
205

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+
![image](/images/gateway/bacnet-connector/examples/dynamic-device-name-and-profile-overview.png)
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 %}
2160
You can find full list of available variables in
2261
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 %}
51.7 KB
Loading
360 KB
Loading
373 KB
Loading

0 commit comments

Comments
 (0)