Skip to content

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/UPDATINGACTIVE); the provider waits for the asset to converge to ACTIVE before returning.

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",
});

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/UPDATINGACTIVE); the provider waits for the model to converge to ACTIVE before returning.

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: {} },
},
],
});
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 },
],
});

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.

// init
const asset = yield* AWS.IoTSiteWise.Asset("Pump1", {
assetModelId: model.assetModelId,
});
const putValues = yield* AWS.IoTSiteWise.BatchPutAssetPropertyValue(asset);
// runtime
const 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))

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.

Provide the DescribeAssetHttp implementation layer on the Function effect, bind the asset in the init phase, then call the returned client at runtime.

// init
const describeAsset = yield* AWS.IoTSiteWise.DescribeAsset(asset);
// runtime
const described = yield* describeAsset();
const propertyId = described.assetProperties.find(
(p) => p.name === "Temperature",
)?.id;
// on the Function effect:
// .pipe(Effect.provide(AWS.IoTSiteWise.DescribeAssetHttp))

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 resource
const executeQuery = yield* AWS.IoTSiteWise.ExecuteQuery();
// runtime
const { 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))

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).

import * as AWS from "alchemy/AWS";
const gateway = yield* AWS.IoTSiteWise.Gateway("FactoryGateway", {
gatewayPlatform: {
greengrassV2: { coreDeviceThingName: "FactoryCoreDevice" },
},
});

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.

// init
const getAggregates = yield* AWS.IoTSiteWise.GetAssetPropertyAggregates(asset);
// runtime
const 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))

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.

// init
const getValue = yield* AWS.IoTSiteWise.GetAssetPropertyValue(asset);
// runtime
const { propertyValue } = yield* getValue({ propertyId });
const celsius = propertyValue?.value.doubleValue;
// on the Function effect:
// .pipe(Effect.provide(AWS.IoTSiteWise.GetAssetPropertyValueHttp))

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.

// init
const getHistory = yield* AWS.IoTSiteWise.GetAssetPropertyValueHistory(asset);
// runtime
const 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))

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.

// init
const getInterpolated =
yield* AWS.IoTSiteWise.GetInterpolatedAssetPropertyValues(asset);
// runtime
const 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))

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.

// init
const listProperties = yield* AWS.IoTSiteWise.ListAssetProperties(asset);
// runtime
const { assetPropertySummaries } = yield* listProperties({ filter: "ALL" });
// on the Function effect:
// .pipe(Effect.provide(AWS.IoTSiteWise.ListAssetPropertiesHttp))