IoT TS Aggregates Client for Python¶
The IoT TS Aggregates Service allows you to query aggregated time series data. Refer to IoT TS Aggregates for more information about the service.
In the IoT context, assets are referred to as
entity and aspects as
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.
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
# 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.clients.aggregates_client import AggregatesClient # Import all required models from tsaggregates.models from tsaggregates.models 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
Any questions left?
Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.