Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Use GetAssetPropertyValue with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use GetAssetPropertyValue with an AWS SDK or CLI

The following code examples show how to use GetAssetPropertyValue.

CLI
AWS CLI

To retrieve an asset property's current value

The following get-asset-property-value example retrieves a wind turbine asset's current total power.

aws iotsitewise get-asset-property-value \ --asset-id a1b2c3d4-5678-90ab-cdef-33333EXAMPLE \ --property-id a1b2c3d4-5678-90ab-cdef-66666EXAMPLE

Output:

{ "propertyValue": { "value": { "doubleValue": 6890.8677520453875 }, "timestamp": { "timeInSeconds": 1580853000, "offsetInNanos": 0 }, "quality": "GOOD" } }

For more information, see Querying current asset property values in the AWS IoT SiteWise User Guide.

Java
SDK for Java 2.x
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

/** * Fetches the value of an asset property. * * @param propId the ID of the asset property to fetch. * @param assetId the ID of the asset to fetch the property value for. * @return a {@link CompletableFuture} that represents a {@link Double} result. The calling code can attach * callbacks, then handle the result or exception by calling {@link CompletableFuture#join()} or * {@link CompletableFuture#get()}. * <p> * If any completion stage in this method throws an exception, the method logs the exception cause and keeps * it available to the calling code as a {@link CompletionException}. By calling * {@link CompletionException#getCause()}, the calling code can access the original exception. */ public CompletableFuture<Double> getAssetPropValueAsync(String propId, String assetId) { GetAssetPropertyValueRequest assetPropertyValueRequest = GetAssetPropertyValueRequest.builder() .propertyId(propId) .assetId(assetId) .build(); return getAsyncClient().getAssetPropertyValue(assetPropertyValueRequest) .handle((response, exception) -> { if (exception != null) { logger.error("Error occurred while fetching property value: {}.", exception.getCause().getMessage()); throw (CompletionException) exception; } return response.propertyValue().value().doubleValue(); }); }
JavaScript
SDK for JavaScript (v3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

import { GetAssetPropertyValueCommand, IoTSiteWiseClient, } from "@aws-sdk/client-iotsitewise"; import { parseArgs } from "node:util"; /** * Describe an asset property value. * @param {{ entryId : string }} */ export const main = async ({ entryId }) => { const client = new IoTSiteWiseClient({}); try { const result = await client.send( new GetAssetPropertyValueCommand({ entryId: entryId, // The ID of the Gateway to describe. }), ); console.log("Asset property information retrieved successfully."); return result; } catch (caught) { if (caught instanceof Error && caught.name === "ResourceNotFound") { console.warn( `${caught.message}. The asset property entry could not be found. Please check the entry id.`, ); } else { throw caught; } } };
Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

class IoTSitewiseWrapper: """Encapsulates AWS IoT SiteWise actions using the client interface.""" def __init__(self, iotsitewise_client: client) -> None: """ Initializes the IoTSitewiseWrapper with an AWS IoT SiteWise client. :param iotsitewise_client: A Boto3 AWS IoT SiteWise client. This client provides low-level access to AWS IoT SiteWise services. """ self.iotsitewise_client = iotsitewise_client self.entry_id = 0 # Incremented to generate unique entry IDs for batch_put_asset_property_value. @classmethod def from_client(cls) -> "IoTSitewiseWrapper": """ Creates an IoTSitewiseWrapper instance with a default AWS IoT SiteWise client. :return: An instance of IoTSitewiseWrapper initialized with the default AWS IoT SiteWise client. """ iotsitewise_client = boto3.client("iotsitewise") return cls(iotsitewise_client) def get_asset_property_value( self, asset_id: str, property_id: str ) -> Dict[str, Any]: """ Gets the value of an AWS IoT SiteWise Asset Property. :param asset_id: The ID of the asset. :param property_id: The ID of the property. :return: A dictionary containing the value of the property. """ try: response = self.iotsitewise_client.get_asset_property_value( assetId=asset_id, propertyId=property_id ) return response["propertyValue"] except ClientError as err: if err.response["Error"]["Code"] == "ResourceNotFoundException": logger.error( "Asset %s or property %s does not exist.", asset_id, property_id ) else: logger.error( "Error getting asset property value. Here's why %s", err.response["Error"]["Message"], ) raise
AWS CLI

To retrieve an asset property's current value

The following get-asset-property-value example retrieves a wind turbine asset's current total power.

aws iotsitewise get-asset-property-value \ --asset-id a1b2c3d4-5678-90ab-cdef-33333EXAMPLE \ --property-id a1b2c3d4-5678-90ab-cdef-66666EXAMPLE

Output:

{ "propertyValue": { "value": { "doubleValue": 6890.8677520453875 }, "timestamp": { "timeInSeconds": 1580853000, "offsetInNanos": 0 }, "quality": "GOOD" } }

For more information, see Querying current asset property values in the AWS IoT SiteWise User Guide.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.