Skip to content

Commit 3e6d4d8

Browse files
authored
feat: refactor thingsboard flows to modernize them (#109)
1 parent 0b5b953 commit 3e6d4d8

26 files changed

Lines changed: 55 additions & 20 deletions

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"flows/log-surge": "1.4.0",
77
"flows/measurement-aggregator": "0.1.0",
88
"flows/protobuf-xform": "0.2.1",
9-
"flows/thingsboard": "0.1.0",
9+
"flows/thingsboard-telemetry": "0.1.0",
1010
"flows/thingsboard-registration": "0.1.0",
1111
"flows/thingsboard-server-rpc": "0.1.0",
1212
"flows/uptime": "1.3.0",

flows/thingsboard-registration/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ Register the main device beforehand. It must be **gateway**. The device ID and a
3838

3939
### Flow Configuration
4040

41-
Then, set `config.main_device_name` to your device's main name in `flow.toml`.
41+
Then, set `main_device_name` to your device's main name in `params.toml`.
4242

4343
```toml
44-
config.main_device_name = "{{MAIN_DEVICE_NAME}}"
44+
main_device_name = "{{MAIN_DEVICE_NAME}}"
4545
```
4646

4747
If you are unsure which value to use, run the following command to get your device ID:
@@ -126,7 +126,7 @@ For child devices and services, the name is determined by the following priority
126126

127127
Device names are generated by filtering out empty path segments and joining the remaining parts with colons (`:`).
128128

129-
Example: (Assuming `config.main_device_name` is set to **MAIN**)
129+
Example: (Assuming `main_device_name` is set to **MAIN**)
130130

131131
| thin-edge.io Topic Pattern | ThingsBoard Name |
132132
| :--------------------------------- | :------------------------------ |

flows/thingsboard-registration/flow.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ mqtt.topics = [
1111

1212
[[steps]]
1313
script = "lib/main.js"
14-
config.main_device_name = "{{MAIN_DEVICE_NAME}}"
15-
config.default_device_profile = "default"
16-
config.max_pending_messages = 100
14+
config.main_device_name = "${.params.main_device_name}"
15+
config.default_device_profile = "${.params.default_device_profile}"
16+
config.max_pending_messages = "${.params.max_pending_messages}"

flows/thingsboard-registration/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"source": "src/main.ts",
66
"module": "lib/main.js",
77
"type": "module",
8+
"tedge": {
9+
"mapper": "thingsboard"
10+
},
811
"scripts": {
912
"build": "esbuild src/main.ts --target=es2018 --bundle --outfile=lib/main.js --format=esm --drop-labels=DEV,TEST",
1013
"test": "jest --coverageProvider=v8 --coverage"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Name to register the main device as
2+
main_device_name = "{{MAIN_DEVICE_NAME}}"
3+
4+
# ThingsBoard device profile applied when `type` is not specified in registration payload
5+
default_device_profile = "default"
6+
7+
# Maximum number of messages to buffer per unregistered device
8+
max_pending_messages = 100

flows/thingsboard-server-rpc/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"source": "src/main.ts",
66
"module": "lib/main.js",
77
"type": "module",
8+
"tedge": {
9+
"mapper": "thingsboard"
10+
},
811
"scripts": {
912
"build": "esbuild src/main.ts --target=es2018 --bundle --outfile=lib/main.js --format=esm --drop-labels=DEV,TEST",
1013
"test": "jest --coverageProvider=v8 --coverage"
File renamed without changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ For the support of RPC/commands, use a dedicated flow [ThingsBoard RPC flow](../
2525

2626
## Flow Custom Configuration
2727

28+
The following properties can be set in the flow's `params.toml` file. You can copy the `params.toml.template` file to create a new `params.toml` file to customize the values accordingly.
29+
2830
- `add_type_to_key`: `<true|false>`
2931
- Determines whether the measurements/twin type is prefixed to the keys.
3032
- For example,
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ config.reformat = true
1818
script = "lib/main.js"
1919

2020
interval = "10m"
21-
config.add_type_to_key = true
22-
config.alarm_prefix = "alarm::"
23-
config.event_prefix = "event::"
24-
config.enable_heartbeat = true
25-
21+
config.add_type_to_key = "${.params.add_type_to_key}"
22+
config.alarm_prefix = "${.params.alarm_prefix}"
23+
config.event_prefix = "${.params.event_prefix}"
24+
config.enable_heartbeat = "${.params.enable_heartbeat}"
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
2-
"name": "thingsboard",
2+
"name": "thingsboard-telemetry",
33
"version": "0.1.0",
44
"description": "This flow demonstrates how to map thin-edge.io data to ThingsBoard.",
55
"source": "src/main.ts",
66
"module": "lib/main.js",
77
"type": "module",
8+
"tedge": {
9+
"mapper": "thingsboard"
10+
},
811
"scripts": {
912
"build": "esbuild src/main.ts --target=es2018 --bundle --outfile=lib/main.js --format=esm --drop-labels=DEV,TEST",
1013
"test": "jest --coverageProvider=v8 --coverage"

0 commit comments

Comments
 (0)