英文:
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!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论