Skip to content

Commit 609639b

Browse files
committed
Updated MQTT connector documentation
1 parent 3cbfb2f commit 609639b

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

docs/iot-gateway/config/mqtt.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ Then, connector will subscribe to a list of topics using topic filters from mapp
7272
"type": "double",
7373
"key": "humidity",
7474
"value": "${hum}"
75+
},
76+
{
77+
"type": "string",
78+
"key": "combine",
79+
"value": "${hum}:${temp}"
7580
}
7681
]
7782
}
@@ -137,8 +142,17 @@ Then, connector will subscribe to a list of topics using topic filters from mapp
137142
"deviceNameTopicExpression": "(?<=sensor\/)(.*?)(?=\/disconnect)"
138143
}
139144
],
145+
"attributeRequests": [
146+
{
147+
"retain": false,
148+
"topicFilter": "v1/devices/me/attributes/request",
149+
"topicExpression": "${SerialNumber}",
150+
"valueExpression": "${sensorModel}"
151+
}
152+
],
140153
"attributeUpdates": [
141154
{
155+
"retain": false,
142156
"deviceNameFilter": "SmartMeter.*",
143157
"attributeFilter": "uploadFrequency",
144158
"topicExpression": "sensor/${deviceName}/${attributeKey}",
@@ -158,7 +172,7 @@ Then, connector will subscribe to a list of topics using topic filters from mapp
158172
"deviceNameFilter": ".*",
159173
"methodFilter": "no-reply",
160174
"requestTopicExpression": "sensor/${deviceName}/request/${methodName}/${requestId}",
161-
"valueExpression": "${params}"
175+
"valueExpression": "${params.hum}::${params.temp}"
162176
}
163177
]
164178
}
@@ -228,6 +242,39 @@ custom<small>Recommended if bytes or anything else will be received in response<
228242

229243
**Note**: You can specify multiple mapping objects inside the array.
230244

245+
Also, you can combine values from MQTT message in attributes, telemetry and serverSideRpc section, for example:
246+
{% highlight json %}
247+
{
248+
{
249+
"topicFilter": "/sensor/data",
250+
"converter": {
251+
"type": "json",
252+
"deviceNameJsonExpression": "${serialNumber}",
253+
"deviceTypeJsonExpression": "${sensorType}",
254+
"timeout": 60000,
255+
"attributes": [],
256+
"timeseries": [
257+
{
258+
"type": "double",
259+
"key": "temperature",
260+
"value": "${temp}"
261+
},
262+
{
263+
"type": "double",
264+
"key": "humidity",
265+
"value": "${hum}"
266+
},
267+
{
268+
"type": "string",
269+
"key": "combine",
270+
"value": "${hum}:${temp}"
271+
}
272+
]
273+
}
274+
}
275+
}
276+
{% endhighlight %}
277+
231278
Mapping process subscribes to the MQTT topics using **topicFilter** parameter of the mapping object.
232279
Each message that is published to this topic by other devices or applications is analyzed to extract device name, type and data (attributes and/or timeseries values).
233280
By default, gateway uses Json converter, but it is possible to provide custom converter. See examples in the source code.
@@ -332,6 +379,7 @@ The "**attributeRequests**" configuration allows configuring the format of the c
332379

333380
| **Parameter** | **Default value** | **Description** |
334381
|:-|:-|-
382+
| retain | **false** | If set to true, the message will be set as the "last known good"/retained message for the topic |
335383
| deviceNameFilter | **SmartMeter.\*** | Regular expression device name filter, uses to determine, which function to execute. |
336384
| attributeFilter | **uploadFrequency** | Regular expression attribute name filter, uses to determine, which function to execute. |
337385
| topicExpression | **sensor/${deviceName}/${attributeKey}** | JSON-path expression uses for creating topic address to send a message. |
@@ -344,6 +392,7 @@ This section in configuration file looks like:
344392
```json
345393
"attributeUpdates": [
346394
{
395+
"retain": false,
347396
"deviceNameFilter": "SmartMeter.*",
348397
"attributeFilter": "uploadFrequency",
349398
"topicExpression": "sensor/${deviceName}/${attributeKey}",
@@ -391,7 +440,7 @@ This section in configuration file looks like:
391440
"deviceNameFilter": ".*",
392441
"methodFilter": "no-reply",
393442
"requestTopicExpression": "sensor/${deviceName}/request/${methodName}/${requestId}",
394-
"valueExpression": "${params}"
443+
"valueExpression": "${params.hum}::${params.temp}"
395444
}
396445
]
397446
```

0 commit comments

Comments
 (0)