【问题标题】:how to import raw (not json-formatted) mqtt values in thingsboard iot-gateway?如何在 thingsboard iot-gateway 中导入原始(非 json 格式)mqtt 值?
【发布时间】:2018-01-21 20:02:07
【问题描述】:

我在文档和留言板中进行了搜索,但找不到以下内容。

我正在尝试使用 IOT 网关将数据从 mqtt 导入 thingsboard。

文档概述了如何配置 IOT 网关以导入 json 格式的数据。

{
  "topicFilter": "sensors",
  "converter": {
    "type": "json",
    "filterExpression": "",
    "deviceNameJsonExpression": "${$.serialNumber}",
    "attributes": [
      {
        "type": "string",
        "key": "model",
        "value": "${$.model}"
      }
    ],
    "timeseries": [
      {
        "type": "double",
        "key": "temperature",
        "value": "${$.temperature}"
      }
    ]
  }
}

来自 (https://thingsboard.io/docs/iot-gateway/getting-started/#step-81-basic-mapping-example)。

然后,该映射可以导入这样发布的数据: mosquitto_pub -h localhost -p 1883 -t "sensors" -m '{"serialNumber":"SN-001", "model":"T1000", "temperature":36.6}'

我希望也可以导入原始数据,即没有 json 格式,因为我已经有许多带有原始数据有效负载的数据主题。所以,只是原始的 ascii 编码值。所以,像这样: mosquitto_pub -h localhost -p 1883 -t "sensors/livingroom/temperature" -m '36.6'

物联网网关可以做到吗?如果可以,配置会是什么样子?

【问题讨论】:

    标签: mqtt thingsboard


    【解决方案1】:

    这是可能的,但您需要实现新的转换器类型。我们拥有的是使用 JSON。您可以实现自己的接受二进制数据的转换器。因此,您的配置将如下所示:

    {
      "topicFilter": "sensors",
      "converter": {
        "type": "binary",
        /* whatever configuration structure that is applicable to your use case */
      }
    }
    

    【讨论】:

    • 我不完全清楚这是否只能通过新的配置结构来实现,还是需要额外的编码?
    • 我的意思是,我可以通过为“二进制”转换器找到正确的配置来做到这一点,还是需要自己编程该“二进制”转换器类型?
    • 你需要自己编程,或者使用TB专业版来配合基于JS代码的自定义转换器。
    猜你喜欢
    • 2021-03-23
    • 2020-11-04
    • 1970-01-01
    • 2020-12-24
    • 1970-01-01
    • 1970-01-01
    • 2011-07-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多