Setting a property alias (Amazon CLI)
Use the Amazon Command Line Interface (Amazon CLI) to set an alias for an asset property.
You must know your asset's assetId
and property's
propertyId
to complete this procedure. You can also use the external ID. If you created an
asset and don't know its assetId
, use the ListAssets API to list all the assets
for a specific model. Use the DescribeAsset operation to view your asset's
properties including property IDs.
Use the UpdateAssetProperty operation, to map a data stream to your asset's property. Specify the following parameters:
-
assetId
– The asset's ID or external ID. For more information, see Referencing objects with external IDs in the Amazon IoT SiteWise User Guide. -
propertyId
– The asset property's ID or external ID. -
propertyAlias
– The data stream's path to alias to the property. -
propertyNotificationState
– The property value notification state:ENABLED
orDISABLED
. Specify the property's existing notification state when you update the property alias. You can retrieve the existing notification state with the DescribeAssetProperty operation.If you omit this parameter, the new notification state is
DISABLED
. For more information about property notifications, see Interacting with other Amazon services.
To set a property alias (Amazon CLI)
-
Run the following command to retrieve the property's current notification state. Replace
asset-id
andproperty-id
with the asset property's IDs.aws iotsitewise describe-asset-property \ --asset-id
asset-id
\ --property-idproperty-id
The operation returns a response that contains the asset property's details in the following format. The property notification state is in
assetProperty.notification.state
in the JSON object.{ "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": {} } } }
-
Run the following command to set the asset property's alias. Replace
property-alias
with the property alias andnotification-state
with the notification state, or omit--property-notification-state
to disable notifications. You can optionally update the asset's unit with a newunit
and--property-unit
.aws iotsitewise update-asset-property \ --asset-id
asset-id
\ --property-idproperty-id
\ --property-aliasproperty-alias
\ --property-notification-statenotification-state
\ --property-unitunit
-
To verify the alias has been set, run the following command to retrieve the property's details. Replace
asset-id
andproperty-id
with the asset property's IDs.aws iotsitewise describe-asset-property \ --asset-id
asset-id
\ --property-idproperty-id
The operation returns a response that contains the asset property's details in the following format. The property alias is
assetProperty.alias
in the JSON object and is set tomyAlias
in this example.{ "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": {} } } }