AWS IoT规则查询语句用于数组JSON负载。

huangapple go评论64阅读模式
英文:

AWS IoT Rule Query Statement for the Array JSON payload

问题

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

[
  {
    "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参考文档中找不到相关信息。

英文:

How to use AWS IoT Rule Query Statement to get temperature and humidity from the following MQTT payload to 'example' topic?

[
  {
    "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
  }
]

So far, I cannot find it on AWS IoT SQL Reference.

答案1

得分: 2

尝试这个,它正在工作!

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

我已经修改了输入JSON,添加了一个,请参见下面的内容。

这是修改后的输入:

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

这是输出:

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

祝好,
拉姆

英文:

Try this, it's working!

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

I have modified the input JSON to have a key -- see below.

Here is the modified input:

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

Here is the output:

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

cheers,
ram

答案2

得分: 0

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

Cheers!

英文:

Also try this one...

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

Cheers!

huangapple
  • 本文由 发表于 2020年1月4日 01:01:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/59582464.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定