【问题标题】:AWS IoT Rule Query Statement for the Array JSON payload数组 JSON 负载的 AWS IoT 规则查询语句
【发布时间】:2020-01-04 05:19:32
【问题描述】:

如何使用 AWS IoT 规则查询语句从以下 MQTT 有效负载获取温度和湿度到“示例”主题?

[
  {
    "timestamp": "2019-08-26T14:21:46Z",
    "type": "Gateway",
    "mac": "XXYYZZXXYYZZ",
    "gatewayFree": 96,
    "gatewayLoad": 0.26
  },
  {
    "timestamp": "2019-08-26T14:21:46Z",
    "type": "S1",
    "mac": "XXYYZZXXYYXX",
    "bleName": "",
    "rssi": -53,
    "battery": 100,
    "temperature": 0.69,
    "humidity": 37.28
  },
  {
    "timestamp": "2019-08-26T14:21:46Z",
    "type": "iBeacon",
    "mac": "XXYYZZXXYYYY",
    "bleName": "",
    "ibeaconUuid": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
    "ibeaconMajor": 0,
    "ibeaconMinor": 0,
    "rssi": -64,
    "ibeaconTxPower": -59,
    "battery": 0
  }
]

到目前为止,我在AWS IoT SQL Reference 上找不到它。

【问题讨论】:

    标签: amazon-web-services aws-iot


    【解决方案1】:

    试试这个,它的工作原理!

    SELECT (SELECT temperature, humidity from input) as output FROM 'iot/topic' 
    

    我已将输入 JSON 修改为具有 key -- 见下文。

    这是修改后的输入:

    {
       "input": [ ... your json array elements ... ]
    }
    

    这是输出:

    {
      "output": [
        {},
        {
          "temperature": 0.69,
          "humidity": 37.28
        },
        {}
      ]
    }
    

    干杯,
    内存

    【讨论】:

      【解决方案2】:

      也试试这个...

      {
          "sql": "SELECT * FROM 'iot/example' WHERE mac = 'XXYYZZXXYYXX'",
          ...
      }
      

      干杯!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-02-22
        • 2021-06-14
        • 2018-04-26
        • 2019-05-03
        相关资源
        最近更新 更多