如何使用 AWS IoT 查询语言在 AWS IoT 规则中按嵌套 属性 进行搜索

How to search by nested property in AWS IoT Rules using AWS IoT query language

我正在尝试让 AWS IoT 规则触发我的操作。但是文档很差。出于某种原因,文档认为我将拥有 json 嵌套级别 = 1 顶部的有效载荷。 我的 JSON 负载示例:

"state": { "reported": { "movement": "yes" } } }

我在规则内使用的查询 SELECT * FROM '$aws/things/thing-name/shadow/update/accepted' WHERE state.reported.movement="yes"

文档,我正在使用:http://docs.aws.amazon.com/iot/latest/developerguide/iot-sql-where.html

有关于扁平 JSON 对象的信息,我确实尝试使用 state.reported.movement、reported.movement,只是移动,看起来 none 有效

好的,我的问题的答案是:AWS IoT Supports nested properties in WHERE statements。出于某种原因,当我创建规则时它不起作用。也许 SNS 主题在传递消息时有一些延迟。

我的情况是,AWS IoT 接受的主题是这样的:

{
  "state": {
    "reported": {
      "system": "armed",
      "movement": "yes"
    }
  },
  "metadata": {
    "reported": {
      "system": {
        "timestamp": 1509207282
      },
      "movement": {
        "timestamp": 1509207282
      }
    }
  },
  "version": 618,
  "timestamp": 1509207282,
  "clientToken": "xxxxxxxx"
}

要查询 JSON 我正在使用以下查询:

SELECT * FROM '$aws/things/myThing/shadow/update/accepted' WHERE state.reported.movement="yes" and state.reported.system="armed"