The chat responses are generated using Generative AI technology for intuitive search and may not be entirely accurate. They are not intended as professional advice. For full details, including our use rights, privacy practices and potential export control restrictions, please refer to our Generative AI Service Terms of Use and Generative AI Service Privacy Information. As this is a test version, please let us know if something irritating comes up. Like you get recommended a chocolate fudge ice cream instead of an energy managing application. If that occurs, please use the feedback button in our contact form!
Skip to content
Insights Hub and Industrial IoT

Insights Hub drives smart manufacturing through the industrial Internet of Things. Gain actionable insights with asset and operational data and improve your processes.

IoT TS Aggregates Client for Python¶

Introduction¶

The IoT TS Aggregates Service allows you to query aggregated time series data. Refer to IoT TS Aggregates for more information about the service.

Further implementation of the IOT TS Aggregate SDK library has been shown in a sample project that you can download and test in local or on Insights Hub application. Please refer to this repository: industrial-iot-python-sdk-examples

Hint

In the IoT context, assets are referred to as entity and aspects as propertyset.
Placeholders in the following samples are indicated by angular brackets < >.

TS Aggregates Operations¶

Client name: AggregatesClient

Read Aggregated Time Series¶

This method returns aggregated data of a specific aspect of an asset from the specified time range. This feature is only available if aspect data is available within the specified time range.

Note

A query can only return up to 200 aggregate intervals in one response.
Aggregates can only be created from up to 5,000 raw time series entries.

# Import the RestClientConfig and UserToken from mindsphere_core module
from mindsphere_core import RestClientConfig
from mindsphere_core import UserToken

# Import the MindsphereError from mindsphere_core.exceptions module
from mindsphere_core.exceptions import MindsphereError

# Import the AggregatesClient from tsaggregates module
from tsaggregates import AggregatesClient

# Import all required models from tsaggregates.models
from tsaggregates import GetAggregateTimeseriesRequest

# Instantiate the RestClientConfig and UserToken objects
config = RestClientConfig(proxy_host = "<proxy_host>", proxy_port = <proxy_port>)
credentials = UserToken(authorization = "<bearer_token>")

# Create the AggregatesClient object using the RestClientConfig and UserToken objects
aggregatesClient = AggregatesClient(rest_client_config = config, mindsphere_credentials = credentials)

try:
    # Create the request object
    request = GetAggregateTimeseriesRequest(
            _from="<start_time>",
            to="<end_time>",
            interval_value="<inteval_value>",
            interval_unit="<interval_unit>",
            select="<select_value>",
            entity="<entity_id>",
            propertyset="<property_set_name>",
        )

    # Initiate the API call to read time series aggregates
    response = get_aggregate_timeseries(request)

except MindsphereError as err:
    # Exception Handling