Setting a property alias (Amazon CLI) - Amazon IoT SiteWise
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

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 or DISABLED. 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)
  1. Run the following command to retrieve the property's current notification state. Replace asset-id and property-id with the asset property's IDs.

    aws iotsitewise describe-asset-property \ --asset-id asset-id \ --property-id property-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": {} } } }
  2. Run the following command to set the asset property's alias. Replace property-alias with the property alias and notification-state with the notification state, or omit --property-notification-state to disable notifications. You can optionally update the asset's unit with a new unit and --property-unit.

    aws iotsitewise update-asset-property \ --asset-id asset-id \ --property-id property-id \ --property-alias property-alias \ --property-notification-state notification-state \ --property-unit unit
  3. To verify the alias has been set, run the following command to retrieve the property's details. Replace asset-id and property-id with the asset property's IDs.

    aws iotsitewise describe-asset-property \ --asset-id asset-id \ --property-id property-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 to myAlias 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": {} } } }