You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/iot-gateway/config/ftp.md
+93-1Lines changed: 93 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -193,7 +193,7 @@ Let's look at how we can configure this section for different file extensions:
193
193
}
194
194
]
195
195
```
196
-
196
+
197
197
That means that FTP converter will look for the following file structure:
198
198
```txt
199
199
temp,hum
@@ -312,6 +312,98 @@ Let's look at how we can configure this section for different file extensions:
312
312
]
313
313
```
314
314
315
+
#### Subsection "converter"
316
+
317
+
This configuration section is **optional** and is used only when you want to process incoming data with a custom FTP converter.
318
+
319
+
Typical use cases:
320
+
321
+
- Files with **extensions not supported** by default, or supported extensions, but with a different data structure, for example:
322
+
- CSV files without a header line
323
+
- CSV lines where fields are located at fixed column positions
324
+
325
+
In this example, we show a configuration for a **CSV file without headers**, where device name, attributes and telemetry values are taken by column index.
326
+
327
+
Mapping subsection in the configuration looks like:
328
+
329
+
```json
330
+
{
331
+
"converter": {
332
+
"type": "custom",
333
+
"extension": "CustomFTPtUplinkConverter",
334
+
"extension-config": {
335
+
"devicePatternName": 0,
336
+
"devicePatternType": 1,
337
+
"attributes": [
338
+
{
339
+
"key": "meterAddress",
340
+
"column": 0,
341
+
"type": "string"
342
+
}
343
+
],
344
+
"timeseries": [
345
+
{
346
+
"key": "meterReading",
347
+
"column": 2,
348
+
"type": "double"
349
+
},
350
+
{
351
+
"key": "batteryAlert",
352
+
"column": 3,
353
+
"type": "int"
354
+
}
355
+
]
356
+
}
357
+
}
358
+
}
359
+
```
360
+
{:.copy-code}
361
+
362
+
Below are description of each parameter used in this configuration for the custom converter.
363
+
364
+
Top-level converter parameters:
365
+
366
+
1.**converter.type**
367
+
Must be set to **custom**. This tells the FTP connector to use a custom converter instead of the built-in ones.
368
+
369
+
2.**converter.extension**
370
+
Name of the Python class that implements the custom converter, for example **CustomFTPtUplinkConverter**.
371
+
372
+
373
+
Extension-config fields:
374
+
375
+
1.**devicePatternName**
376
+
Column index used to resolve the device name. In the example, **0** means that the device name is taken from column 0.
377
+
378
+
2.**devicePatternType**
379
+
Column index or literal used to resolve the device type. In the example, **1** means that the device type is taken from column 1.
380
+
381
+
3.**attributes**
382
+
An array of attribute mappings. Each item describes how to read a single device attribute from a specific CSV column.
383
+
384
+
4.**timeseries**
385
+
An array of telemetry mappings. Each item describes how to read a single telemetry value from a specific CSV column.
386
+
387
+
388
+
Attributes and timeseries items:
389
+
Each element of attributes and timeseries has the same structure:
390
+
391
+
1.**key**
392
+
Attribute or telemetry key that will appear on the created device in the ThingsBoard Platform (for example, **meterAddress**, **meterReading**).
393
+
394
+
2.**column**
395
+
Zero-based column index in the CSV line from which the value is taken.
396
+
397
+
3.**type**
398
+
Target value type. The custom converter will cast the raw string to this type (for example, **string**, **int**, **double**).
399
+
400
+
{% capture difference %}
401
+
The exact behavior will depend on your own `CustomFTPtUplinkConverter` implementation, but this configuration shows a working example for headerless CSV files.
402
+
You will most likely change the mapping values (devicePatternName, devicePatternType, attributes, timeseries) to match your file format, but the parameter names and structure must remain the same.
403
+
{% endcapture %}
404
+
{% include templates/info-banner.md content=difference %}
0 commit comments