【问题标题】:AWS IoT search for dynamic Thing GroupAWS IoT 搜索动态事物组
【发布时间】:2020-02-04 03:24:50
【问题描述】:

我想查找动态事物组的列表。当我转到 AWS IoT Core 中的一个事物组时,我可以看到字段的类型。如何搜索和查找具有 TypeDynamic 的事物组列表?

例如

当我访问 IoT Core 中的某个事物组时。

You do not have a description for the thing group yet.

Created
Jul 26, 2019 11:21:44 AM -0700

Type
Static

0 Attributes

我尝试了一些变体,但它们都不起作用。

Type: Dynamic
attributes.Type: Dynamic
Type == Dynamic

提前感谢您的任何建议。

【问题讨论】:

    标签: amazon-web-services iot aws-iot


    【解决方案1】:
    • 配置Thing Group index on Fleet Indexing
    • 对于创建的每个动态事物组,添加一个属性以将其区分为动态事物组,即attribute.dynamic: true
    • 使用查询 attributes.dynamic: true 在索引上调用 SearchIndex,这将返回所有动态事物组。

    【讨论】:

    • 谢谢,这是个好主意。我们有 100 多个事物组,而当这些事物组已经创建时是不可能的。
    【解决方案2】:

    看起来不是直截了当。感谢我的同事,我创建了一个脚本来获取该列表。

    import boto3
    client = boto3.client('iot')
    
    list_thing_groups = client.list_thing_groups()
    while True:
        for thing_group in list_thing_groups['thingGroups']:
            name = thing_group['groupName']
            response = client.describe_thing_group(
                thingGroupName=name
            )
            query = response.get('queryString')
            if query:
                print(name)
        if list_thing_groups.get('nextToken'):
            list_thing_groups = client.list_thing_groups(nextToken=list_thing_groups.get('nextToken'))
        else:
            break
    

    这个想法是queryString,因为动态事物组不会为空。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-03
      • 2019-11-13
      • 1970-01-01
      • 2020-08-02
      • 2016-10-01
      • 2019-01-27
      • 2020-08-05
      相关资源
      最近更新 更多