Skip to content
We're currently creating a lot of content. Sign up to get notified when it's ready.

Warnings

The warnings API lets you read the warning thresholds configured for the assets of the network.

Returns the warning threshold configured for an asset, or undefined if the asset has no threshold.

type AssetWarningThreshold = {
metric: "pressure" | "flow" | "level";
min?: number;
max?: number;
}
getThreshold(assetId: string): AssetWarningThreshold | undefined
  • assetId: The ID of the asset.

An AssetWarningThreshold object with:

  • metric: The metric the threshold applies to: pressure, flow or level.
  • min: Optional. The minimum value of the metric before a warning is raised.
  • max: Optional. The maximum value of the metric before a warning is raised.

Values use the same units as the asset’s simulation values. See getUnits().

Find the junctions whose simulated pressure is below their minimum threshold:

const lowPressureJunctions = sdk.network.getJunctions((junction) => {
const threshold = sdk.warnings.getThreshold(junction.id)
const pressure = junction.simulation?.pressure
return (
threshold?.metric === "pressure" &&
threshold.min !== undefined &&
pressure !== undefined &&
pressure < threshold.min
)
})