Can't set deviceTypeJsonExpression from mqtt-config.json
See original GitHub issueusing tb-gateway 1.4.0 with mqtt-config.json against demo.thingsboard.io. When I connect first time with new device, it DOES create a new device in Thingsboard but DOES NOT change the deviceType attribute from “default”.
mqtt-config.json:
...
"topicFilter": "sensor/+/mtdotbox",
"converter": {
"type": "json",
"filterExpression": "",
"deviceNameTopicExpression": "(?<=sensor\/)(.*?)(?=\/mtdotbox)",
"deviceTypeJsonExpression": "${$.model}", // <--- this should work?!?
"timeout": 60000,
"attributes": [
...
{
"type": "string",
"key": "model",
"value": "${$.model}"
...
Here is the data I am sending to the tb-gateway from my local gateway
{
"serialNumber": "00-08-00-4A-38-A3",
"model": "MT-DOTBOX-G-915",
"light": 972.75,
"temperature": 25.1875,
"humidity": 101.6765,
"x_acc": 0,
"y_acc": 0,
"z_acc": 1
}
Here is the tb-gateway log showing connect. attributes, telemetry. Seems ok.
2018-12-19 13:50:33,224 [MQTT Call: cfa9d2cb-09fe-4512-a869-5ba9b2694550] INFO o.t.g.s.gateway.MqttGatewayService - [00-08-00-4A-38-A3] Device Connected!
2018-12-19 13:50:33,691 [pool-3-thread-1] INFO o.t.g.service.MqttMessageSender - Sending message [MqttPersistentMessage(id=25c321df-6f6b-4f8e-b5e2-700921d43a18, timestamp=0, deviceId=00-08-00-4A-38-A3, messageId=3, topic=v1/gateway/connect, payload=[123, 34, 100, 101,
118, 105, 99, 101, 34, 58, 34, 48, 48, 45, 48, 56, 45, 48, 48, 45, 52, 65, 45, 51, 56, 45, 65, 51, 34, 125])]
2018-12-19 13:50:33,693 [pool-3-thread-1] INFO o.t.g.service.MqttMessageSender - Sending message [MqttPersistentMessage(id=ff218082-100a-4890-aed6-7eeacc183180, timestamp=0, deviceId=00-08-00-4A-38-A3, messageId=4, topic=v1/gateway/attributes, payload=[123, 34, 48, 48, 45, 48, 56, 45, 48, 48, 45, 52, 65, 45, 51, 56, 45, 65, 51, 34, 58, 123, 34, 115, 101, 114, 105, 97, 108, 78, 117, 109, 98, 101, 114, 34, 58, 34, 48, 48, 45, 48, 56, 45, 48, 48, 45, 52, 65, 45, 51, 56, 45, 65, 51, 34, 44, 34, 109, 111, 100, 101, 108, 34, 58, 34, 77, 84, 45, 68, 79, 84, 66, 79, 88, 45, 71, 45, 57, 49, 53, 34, 125, 125])]
2018-12-19 13:50:33,693 [pool-3-thread-1] INFO o.t.g.service.MqttMessageSender - Sending message [MqttPersistentMessage(id=6a1ffaf9-a855-489c-8c94-533ad869c4aa, timestamp=0, deviceId=00-08-00-4A-38-A3, messageId=5, topic=v1/gateway/telemetry, payload=[123, 34, 48, 48, 45, 48, 56, 45, 48, 48, 45, 52, 65, 45, 51, 56, 45, 65, 51, 34, 58, 91, 123, 34, 116, 115, 34, 58, 49, 53, 52, 53, 50, 50, 55, 52, 51, 51, 50, 48, 49, 44, 34, 118, 97, 108, 117, 101, 115, 34, 58, 123, 34, 108, 105, 103, 104, 116, 34, 58, 57, 55, 50, 46, 55, 53, 44, 34, 116, 101, 109, 112, 101, 114, 97, 116, 117, 114, 101, 34, 58, 50, 53, 46, 49, 56, 55, 53, 44, 34, 104, 117, 109, 105, 100, 105, 116, 121, 34, 58, 49, 48, 49, 46, 54, 55, 54, 53, 44, 34, 120, 95, 97, 99, 99, 34, 58, 48, 46, 48, 44, 34, 121, 95, 97, 99, 99, 34, 58, 48, 46, 48, 44, 34, 122, 95, 97, 99, 99, 34, 58, 49, 46, 48, 125, 125, 93, 125])]
2018-12-19 13:50:33,694 [pool-3-thread-1] INFO o.t.g.service.MqttMessageSender - Outgoing queue is not empty. [3] messages are still in progress
2018-12-19 13:50:33,694 [pool-3-thread-1] INFO o.t.g.service.MqttMessageSender - Waiting until all messages are sent before going to the next bucket
2018-12-19 13:50:33,892 [pool-4-thread-1] INFO o.t.g.s.gateway.MqttGatewayService - [00-08-00-4A-38-A3][3] Device connect event is reported to Thingsboard!
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
help configuring mqtt-config.json / mqtt data scheme
I am getting an error with the mqtt config that I've done, I am starting simple, but eventually I will want to get...
Read more >MQTT Connector Configuration | ThingsBoard IoT Gateway
Simple JSON expression, uses for looking device type in the incoming message (parameter “sensorType” will be used as device type). timeout, 60000, Timeout...
Read more >Common AWS IoT Events issues and solutions
The defined payload type is JSON, so you must specify an expression that AWS IoT Events would evaluate to a string.
Read more >IoT MQTT Panel App Guide | SNR LAB
This article will help to understand architecture and working principle of the IoT MQTT Panel application. This app is useful for DIY Home ......
Read more >The MQTT Adapter
This article describes the configuration concept for the i4connected MQTT ... to a Device filter, it runs the Filter expression against the JSON...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi,
I had the same problem - deviceTypeJsonExpression had no effect in http-config.json and always returned “default” as the device type. Using 1.4.0 now. How to get this resolved? Will the latest version of Gateway help?
Fixed: the environment variable LOADER_PATH must specify the config directory and be available from within the docker container.
in the docker host environment
in the docker-compose.yml