AWS.IoTSiteWise reference
Source:
src/AWS/IoTSiteWise/Asset.ts
An AWS IoT SiteWise asset — an instance of an asset model representing a physical piece of industrial equipment or a logical grouping.
Asset creation and updates are asynchronous (CREATING/UPDATING →
ACTIVE); the provider waits for the asset to converge to ACTIVE
before returning.
Asset: Creating Assets
Section titled “Asset: Creating Assets”import * as AWS from "alchemy/AWS";
const model = yield* AWS.IoTSiteWise.AssetModel("PumpModel", { assetModelProperties: [ { name: "Temperature", dataType: "DOUBLE", type: { measurement: {} } }, ],});
const asset = yield* AWS.IoTSiteWise.Asset("Pump1", { assetModelId: model.assetModelId, assetDescription: "Pump #1 on the west line",});AssetModel
Section titled “AssetModel”Source:
src/AWS/IoTSiteWise/AssetModel.ts
An AWS IoT SiteWise asset model — a standardized definition of properties (attributes, measurements, transforms, metrics) and hierarchies from which industrial assets are created.
Asset model creation and updates are asynchronous
(CREATING/UPDATING → ACTIVE); the provider waits for the model to
converge to ACTIVE before returning.
AssetModel: Creating Asset Models
Section titled “AssetModel: Creating Asset Models”import * as AWS from "alchemy/AWS";
const model = yield* AWS.IoTSiteWise.AssetModel("PumpModel", { assetModelDescription: "A pump on the factory floor", assetModelProperties: [ { name: "SerialNumber", dataType: "STRING", type: { attribute: { defaultValue: "unknown" } }, }, { name: "Temperature", dataType: "DOUBLE", unit: "Celsius", type: { measurement: {} }, }, ],});AssetModel: Hierarchies
Section titled “AssetModel: Hierarchies”const pump = yield* AWS.IoTSiteWise.AssetModel("PumpModel", { assetModelProperties: [ { name: "Temperature", dataType: "DOUBLE", type: { measurement: {} } }, ],});
const site = yield* AWS.IoTSiteWise.AssetModel("SiteModel", { assetModelHierarchies: [ { name: "Pumps", childAssetModelId: pump.assetModelId }, ],});BatchPutAssetPropertyValue
Section titled “BatchPutAssetPropertyValue”Source:
src/AWS/IoTSiteWise/BatchPutAssetPropertyValue.ts
Runtime binding for iotsitewise:BatchPutAssetPropertyValue — ingest
timestamped property values (measurements) into the bound asset’s data
streams from a deployed Lambda or Task.
BatchPutAssetPropertyValue: Ingesting Property Values
Section titled “BatchPutAssetPropertyValue: Ingesting Property Values”Provide the BatchPutAssetPropertyValueHttp implementation layer on the
Function effect, bind the asset in the init phase, then call the returned
client at runtime. The binding grants
iotsitewise:BatchPutAssetPropertyValue on the asset and injects its id
into every entry automatically.
// initconst asset = yield* AWS.IoTSiteWise.Asset("Pump1", { assetModelId: model.assetModelId,});const putValues = yield* AWS.IoTSiteWise.BatchPutAssetPropertyValue(asset);
// runtimeconst now = yield* Effect.sync(() => Math.floor(Date.now() / 1000));const { errorEntries } = yield* putValues({ entries: [ { entryId: "temp-1", propertyId, propertyValues: [ { value: { doubleValue: 23.5 }, timestamp: { timeInSeconds: now }, quality: "GOOD", }, ], }, ],});// on the Function effect:// .pipe(Effect.provide(AWS.IoTSiteWise.BatchPutAssetPropertyValueHttp))DescribeAsset
Section titled “DescribeAsset”Source:
src/AWS/IoTSiteWise/DescribeAsset.ts
Runtime binding for iotsitewise:DescribeAsset — read the bound asset’s
full description (including its properties with their service-assigned
ids and names) from a deployed Lambda or Task. Use it to resolve a
property’s id by name before reading or ingesting values.
DescribeAsset: Describing the Bound Asset
Section titled “DescribeAsset: Describing the Bound Asset”Provide the DescribeAssetHttp implementation layer on the Function
effect, bind the asset in the init phase, then call the returned client
at runtime.
// initconst describeAsset = yield* AWS.IoTSiteWise.DescribeAsset(asset);
// runtimeconst described = yield* describeAsset();const propertyId = described.assetProperties.find( (p) => p.name === "Temperature",)?.id;// on the Function effect:// .pipe(Effect.provide(AWS.IoTSiteWise.DescribeAssetHttp))ExecuteQuery
Section titled “ExecuteQuery”Source:
src/AWS/IoTSiteWise/ExecuteQuery.ts
Runtime binding for iotsitewise:ExecuteQuery — run a SiteWise SQL
query across all asset models, assets, measurements, metrics, and
transforms in the account from a deployed Lambda or Task.
The query surface is account-wide, so the binding grants the action on
Resource: ["*"] and takes no bound resource.
ExecuteQuery: Querying Asset Data with SQL
Section titled “ExecuteQuery: Querying Asset Data with SQL”Provide the ExecuteQueryHttp implementation layer on the Function
effect, bind in the init phase (no resource argument), then call the
returned client at runtime.
// init — account-level binding takes no resourceconst executeQuery = yield* AWS.IoTSiteWise.ExecuteQuery();
// runtimeconst { rows } = yield* executeQuery({ queryStatement: "SELECT asset_id, asset_name FROM asset WHERE asset_name = 'Pump1'",});// on the Function effect:// .pipe(Effect.provide(AWS.IoTSiteWise.ExecuteQueryHttp))Gateway
Section titled “Gateway”Source:
src/AWS/IoTSiteWise/Gateway.ts
An AWS IoT SiteWise gateway — the ingestion point that connects on-premises industrial data sources (e.g. OPC UA servers) to IoT SiteWise, hosted on an IoT Greengrass V2 core device or a Siemens Industrial Edge device.
The cloud-side gateway resource registers immediately; the edge software syncs to it asynchronously once the referenced core device is online (the device does not need to exist to create the gateway).
Gateway: Creating Gateways
Section titled “Gateway: Creating Gateways”import * as AWS from "alchemy/AWS";
const gateway = yield* AWS.IoTSiteWise.Gateway("FactoryGateway", { gatewayPlatform: { greengrassV2: { coreDeviceThingName: "FactoryCoreDevice" }, },});GetAssetPropertyAggregates
Section titled “GetAssetPropertyAggregates”Source:
src/AWS/IoTSiteWise/GetAssetPropertyAggregates.ts
Runtime binding for iotsitewise:GetAssetPropertyAggregates — read
pre-computed aggregates (AVERAGE, MINIMUM, MAXIMUM, SUM, COUNT,
STANDARD_DEVIATION) of one property of the bound asset over a time
range at a fixed resolution from a deployed Lambda or Task.
GetAssetPropertyAggregates: Reading Aggregates
Section titled “GetAssetPropertyAggregates: Reading Aggregates”Provide the GetAssetPropertyAggregatesHttp implementation layer on the
Function effect, bind the asset in the init phase, then call the returned
client at runtime.
// initconst getAggregates = yield* AWS.IoTSiteWise.GetAssetPropertyAggregates(asset);
// runtimeconst now = yield* Effect.sync(() => new Date());const { aggregatedValues } = yield* getAggregates({ propertyId, aggregateTypes: ["AVERAGE"], resolution: "1h", startDate: new Date(now.getTime() - 86_400_000), endDate: now,});// on the Function effect:// .pipe(Effect.provide(AWS.IoTSiteWise.GetAssetPropertyAggregatesHttp))GetAssetPropertyValue
Section titled “GetAssetPropertyValue”Source:
src/AWS/IoTSiteWise/GetAssetPropertyValue.ts
Runtime binding for iotsitewise:GetAssetPropertyValue — read the
current (latest) timestamp-quality-value of one property of the bound
asset from a deployed Lambda or Task.
GetAssetPropertyValue: Reading Current Values
Section titled “GetAssetPropertyValue: Reading Current Values”Provide the GetAssetPropertyValueHttp implementation layer on the
Function effect, bind the asset in the init phase, then call the returned
client at runtime.
// initconst getValue = yield* AWS.IoTSiteWise.GetAssetPropertyValue(asset);
// runtimeconst { propertyValue } = yield* getValue({ propertyId });const celsius = propertyValue?.value.doubleValue;// on the Function effect:// .pipe(Effect.provide(AWS.IoTSiteWise.GetAssetPropertyValueHttp))GetAssetPropertyValueHistory
Section titled “GetAssetPropertyValueHistory”Source:
src/AWS/IoTSiteWise/GetAssetPropertyValueHistory.ts
Runtime binding for iotsitewise:GetAssetPropertyValueHistory — read the
historical timestamp-quality-values of one property of the bound asset
over a time range from a deployed Lambda or Task.
GetAssetPropertyValueHistory: Reading Value History
Section titled “GetAssetPropertyValueHistory: Reading Value History”Provide the GetAssetPropertyValueHistoryHttp implementation layer on
the Function effect, bind the asset in the init phase, then call the
returned client at runtime. Page through large ranges with nextToken.
// initconst getHistory = yield* AWS.IoTSiteWise.GetAssetPropertyValueHistory(asset);
// runtimeconst now = yield* Effect.sync(() => new Date());const { assetPropertyValueHistory } = yield* getHistory({ propertyId, startDate: new Date(now.getTime() - 3_600_000), endDate: now, timeOrdering: "DESCENDING",});// on the Function effect:// .pipe(Effect.provide(AWS.IoTSiteWise.GetAssetPropertyValueHistoryHttp))GetInterpolatedAssetPropertyValues
Section titled “GetInterpolatedAssetPropertyValues”Source:
src/AWS/IoTSiteWise/GetInterpolatedAssetPropertyValues.ts
Runtime binding for iotsitewise:GetInterpolatedAssetPropertyValues —
compute interpolated values (LINEAR_INTERPOLATION or
LOCF_INTERPOLATION) of one property of the bound asset at a fixed
interval from a deployed Lambda or Task.
GetInterpolatedAssetPropertyValues: Reading Interpolated Values
Section titled “GetInterpolatedAssetPropertyValues: Reading Interpolated Values”Provide the GetInterpolatedAssetPropertyValuesHttp implementation layer
on the Function effect, bind the asset in the init phase, then call the
returned client at runtime.
// initconst getInterpolated = yield* AWS.IoTSiteWise.GetInterpolatedAssetPropertyValues(asset);
// runtimeconst now = yield* Effect.sync(() => Math.floor(Date.now() / 1000));const { interpolatedAssetPropertyValues } = yield* getInterpolated({ propertyId, startTimeInSeconds: now - 3600, endTimeInSeconds: now, intervalInSeconds: 60, quality: "GOOD", type: "LINEAR_INTERPOLATION",});// on the Function effect:// .pipe(Effect.provide(AWS.IoTSiteWise.GetInterpolatedAssetPropertyValuesHttp))ListAssetProperties
Section titled “ListAssetProperties”Source:
src/AWS/IoTSiteWise/ListAssetProperties.ts
Runtime binding for iotsitewise:ListAssetProperties — page through the
bound asset’s property summaries (ids, aliases, paths) from a deployed
Lambda or Task.
ListAssetProperties: Listing Asset Properties
Section titled “ListAssetProperties: Listing Asset Properties”Provide the ListAssetPropertiesHttp implementation layer on the
Function effect, bind the asset in the init phase, then call the returned
client at runtime. Pass filter: "ALL" to include properties inherited
from composite models.
// initconst listProperties = yield* AWS.IoTSiteWise.ListAssetProperties(asset);
// runtimeconst { assetPropertySummaries } = yield* listProperties({ filter: "ALL" });// on the Function effect:// .pipe(Effect.provide(AWS.IoTSiteWise.ListAssetPropertiesHttp))