本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
设置属性别名 (Amazon CLI)
使用 Amazon Command Line Interface (Amazon CLI) 为资产属性设置别名。
您必须知道资产的 assetId
和属性的 propertyId
才能完成此过程。您也可以使用外部 ID。如果您创建了资产但不知道该资产assetId
,请使用 ListAssetsAPI 列出特定模型的所有资产。使用该DescribeAsset操作查看资产的属性,包括财产 ID。
使用UpdateAssetProperty操作将数据流映射到资产的属性。指定以下参数:
-
assetId
— 资产的 ID 或外部 ID。有关更多信息,请参阅《Amazon IoT SiteWise 用户指南》中的 使用外部 ID 引用对象。 -
propertyId
— 资产属性的 ID 或外部 ID。 -
propertyAlias
– 数据流到属性别名的路径。 -
propertyNotificationState
– 属性值通知状态:ENABLED
或DISABLED
。在更新属性别名时指定属性的现有通知状态。您可以通过DescribeAssetProperty操作检索现有的通知状态。如果省略此参数,则新通知状态为
DISABLED
。有关属性通知的更多信息,请参阅与其他 Amazon 服务互动。
要设置属性别名 (Amazon CLI)
-
运行以下命令以检索属性的当前通知状态。将
asset-id
和property-id
替换为资产属性的 ID。aws iotsitewise describe-asset-property \ --asset-id
asset-id
\ --property-idproperty-id
此操作将按以下格式返回包含资产属性的详细信息的响应。属性通知状态位于 JSON 对象的
assetProperty.notification.state
中。{ "assetId": "a1b2c3d4-5678-90ab-cdef-22222EXAMPLE", "assetName": "Wind Turbine 7", "assetModelId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "assetProperty": { "id": "a1b2c3d4-5678-90ab-cdef-33333EXAMPLE", "name": "Wind Speed", "notification": { "topic": "$aws/sitewise/asset-models/a1b2c3d4-5678-90ab-cdef-11111EXAMPLE/assets/a1b2c3d4-5678-90ab-cdef-22222EXAMPLE/properties/a1b2c3d4-5678-90ab-cdef-33333EXAMPLE", "state": "ENABLED" }, "dataType": "DOUBLE", "unit": "m/s", "type": { "measurement": {} } } }
-
运行以下命令以设置资产属性的别名。将
property-alias
替换为属性别名,将notification-state
替换为通知状态,或者省略--property-notification-state
以禁用通知。您可以选择使用新单位更新资产的单位
,以及--property-unit
。aws iotsitewise update-asset-property \ --asset-id
asset-id
\ --property-idproperty-id
\ --property-aliasproperty-alias
\ --property-notification-statenotification-state
\ --property-unitunit
-
要验证是否已设置别名,请运行以下命令来检索属性的详细信息。将
asset-id
和property-id
替换为资产属性的 ID。aws iotsitewise describe-asset-property \ --asset-id
asset-id
\ --property-idproperty-id
此操作将按以下格式返回包含资产属性的详细信息的响应。属性别名
assetProperty.alias
在 JSON 对象中,在本示例中设置为myAlias
。{ "assetId": "a1b2c3d4-5678-90ab-cdef-22222EXAMPLE", "assetName": "Wind Turbine 7", "assetModelId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "assetProperty": { "alias": "myAlias", "id": "a1b2c3d4-5678-90ab-cdef-33333EXAMPLE", "name": "Wind Speed", "notification": { "topic": "$aws/sitewise/asset-models/a1b2c3d4-5678-90ab-cdef-11111EXAMPLE/assets/a1b2c3d4-5678-90ab-cdef-22222EXAMPLE/properties/a1b2c3d4-5678-90ab-cdef-33333EXAMPLE", "state": "ENABLED" }, "dataType": "DOUBLE", "unit": "m/s", "type": { "measurement": {} } } }