Adding datapoints to twins

In the Connect article we explained how to send Data Points to the platform. Now, we will connect them to their respective twin units. Attaching datapoints to our twin units will optimize the visualization on the data explorer and will be helpful for the creation of our solutions inside the AI Lab.

If you haven't read about datapoints, there is a whole article dedicated to them

Linking our datapoints with our digital twins

We will click on Data Points, then search for the name of the data point that we previously uploaded and drag & drop it into the desired twin. In the following example from the provided data sample, we will attach mt1_bearing1 to the respective bearing twin, and so on.

Figure 5. Connecting data points inside digital twin

You will see an orange diamond figure next to the Twin icon, meaning that we have datapoints attached to it.

Additionally, if you are using the Wizata DSAPI, you can automate tasks such as connecting a list of datapoints to a specific unit. In the following example code, we will attach all datapoints starting with mt2_ to the motor 2 twin using the following logic:


datapoint_partial_name = 'mt2_'
i = 1 # Page number
page_size = 20 # Number of datapoints per page
total = None
has_more = True

twin_asset = wizata_dsapi.api().get(key='motor_2',entity=wizata_dsapi.Twin)

while has_more:
    datapoints = wizata_dsapi.api().search_datapoints(hardware_id=datapoint_partial_name, page=i, size=page_size)
    if i == 1:
        total = datapoints.total
        
    for datapoint in datapoints.results:
        datapoint.twin_id = twin_asset.twin_id
        wizata_dsapi.api().upsert_datapoint(datapoint)

# Exit condition if no more datapoints to update
    total -= page_size
    i += 1
    if total < 0:
        has_more = False
       

And then you will visualize the result on the UI:

If we want to remove the link between our digital twin and the data points attached, we just click on the Twin -> Attached Data -> Unlink sensors. Remember that it will unlink datapoints that are checked on the list only.

Now that you understand the basics of the digital twin, we will dive deeper into how to retrieve data from the datapoints attached to your twins. We will also guide you through creating solutions in the AI Lab and deploying them across all your assets.