---
title: Use Digital Twins to Contextualize Data
slug: bhdo-v1/use-digital-twins-to-contextualize-data
createdAt: 2023-09-25T18:09:50.008Z
---

Refer to the following how-to guide for leveraging Digital Twins for energy monitoring.&#x20;

# User Scenario

Digital Twins will model the asset as an energy monitoring machine located at several plant sites. The instances for the model will be the specific energy monitoring machines at each site.&#x20;

The power generated will be used to generate values for cost, energy used, and energy rate. The timestamp value will be used to generate values for the attributes of season, start hour, and energy-rate description.&#x20;

Values for power generated will be sent through the topic **devicehub.alias.P2\_Electrical\_Panel.L3\_Machine2**.&#x20;

Timestamp values from one of the energy monitoring machines will be sent through the topic **flowToDT.EMD\_L3\_Machine2**.&#x20;

# Sample Output Payload from Instance

This user scenario will be based on the following sample output payload from one instance.&#x20;

```json
{
  "time": "2023-04-13T17:00:00.000Z",
  "plant": "Toronto",
  "line": "Line 1",
  "asset": "Machine 2",
  "shift": 2,
  "energyUsed": 2.51,
  "energyRate": 15.1,
  "energyRateDescription": "On-Peak",
  "season": "Winter",
  "cost": 37.9,
  "timestamp": 1681408544466,
  "startHour": "2023-04-13T17:00:00.000Z"
}
```

# Step 1: Create Digital Twins Model

You will first need to create the model that will store the instances of energy monitoring machines.&#x20;

**To create the model:**

1. Navigate to **Digital Twins**.&#x20;
   The *Models&#x20;*&#x70;ane appears.&#x20;
2. From the *Models&#x20;*&#x70;ane, click the **Create a model&#x20;**&#x74;ile.&#x20;
   The *Create a Model* dialog box appears.&#x20;
3. Click the **Type** drop-down list and select **ASSET**.
4. Enter the name of the model in the **Name** field (for example, **Energy\_Monitoring\_Model**).
5. (Optional) Enter a short description of the model in the **Description** field.
6. Click **Add**.****
   The new model appears in the *Models&#x20;*&#x70;ane.

After creating the model, you can [configure it](docId\:Yv4yvJtjn0CWwEmRrENBl) with the following parameters.&#x20;

## Model Static Attributes

The static attributes will need to be customized for each instance.&#x20;

- Asset
- Line
- Model
- Manufacturer
- Location
- Plant

## Transformations

The transformations are based on the sample payload above. &#x20;

### energyRateDescription

```json
{
  "value": "$energyRateDescription",
  "timestamp": "$timestamp"
}
```

### energyRate

```json
{
  "value": "$energyRate",
  "timestamp": "$timestamp"
}
```

### energyUsed

```json
{
  "value": "$energyUsed",
  "timestamp": "$timestamp"
}
```

### shift

```json
{
  "value": "$shift",
  "timestamp": "$timestamp"
}
```

### startHour

```json
{
  "value": "$startHour",
  "timestamp": "$timestamp"
}
```

### season

```json
{
  "value": "$season",
  "timestamp": "$timestamp"
}
```

### cost

```json
{
  "value": "$cost",
  "timestamp": "$timestamp"
}
```

The list of transformations would display as the following.&#x20;

![](https://api.archbee.com/api/optimize/vAqK-046vdh4I0e1y9cfX/RqjMi5hSpQlxC3yt2pyPQ_image.png "List of transformations")

## Model Dynamic Attributes

The dynamic attributes will use the appropriate schemaID (transformation) to generate values.&#x20;

| **Name**              | **Unit (optional)** | **DataType (optional)** | **SchemaID (optional)** |
| --------------------- | ------------------- | ----------------------- | ----------------------- |
| cost                  | USD                 |                         | cost                    |
| energyRateDescription |                     |                         | energyRateDescription   |
| energyRate            | USD/kWh             |                         | energyRate              |
| energyUsed            |                     |                         | energyUsed              |
| shift                 |                     |                         | shift                   |
| startHour             |                     |                         | startHour               |
| season                |                     |                         | season                  |
| power                 | kW                  |                         |                         |

## Hierarchy

The output for the model will be based on the hierarchy, which would categorize the dynamic and static attributes into **telemetry&#x20;**&#x6F;r **properties**. It would look like the following.&#x20;

![](https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/MlNIsMtER3wa6O54LfDTK_image.png)

# Step 2: Create Instances

Once the model is configured, you will need to [Add an Instance](docId\:zHcDDvWdZV7CtMQHKp6hF) for each energy monitoring device at each site.&#x20;

One of the instances is described below based on the topics for the data in the user scenario description.&#x20;

## Instance Static Attributes

You will customize the model static attributes to the specific instance.&#x20;

| **Attribute Name** | **Attribute Value** |
| ------------------ | ------------------- |
| Asset              | Machine 2           |
| Line               | Line 1              |
| Model              | model\_112233       |
| Manufacturer       | Siemens             |
| Location           | Canada              |
| Plant              | Toronto             |

## Instance Dynamic Attributes

You will configure the appropriate topics in the user scenario description to the dynamic attributes configured in the model.&#x20;

| **Name**              | **Unit** | **DataType** | **Topic**                                          | **SchemaID (optional)** |
| --------------------- | -------- | ------------ | -------------------------------------------------- | ----------------------- |
| power                 | kW       |              | devicehub.alias.P2\_Electrical\_Panel.L3\_Machine2 |                         |
| cost                  | USD      |              | flowToDT.EMD\_L3\_Machine2                         | cost                    |
| energyRateDescription |          |              | flowToDT.EMD\_L3\_Machine2                         | energyRateDescription   |
| energyRate            | USD/kWh  |              | flowToDT.EMD\_L3\_Machine2                         | energyRate              |
| energyUsed            |          |              | flowToDT.EMD\_L3\_Machine2                         | energyUsed              |
| shift                 |          |              | flowToDT.EMD\_L3\_Machine2                         | shift                   |
| startHour             |          |              | flowToDT.EMD\_L3\_Machine2                         | startHour               |
| season                |          |              | flowToDT.EMD\_L3\_Machine2                         | season                  |

