eta_utility.connectors.cumulocity module
- class eta_utility.connectors.cumulocity.CumulocityConnection(url: str, usr: str | None, pwd: str | None, *, tenant: str, nodes: Nodes | None = None)[source]
Bases:
BaseSeriesConnection
CumulocityConnection is a class to download and upload multiple features from and to the Cumulocity database as timeseries.
- Parameters:
url – URL of the server without scheme (https://).
usr – Username in Cumulocity for login.
pwd – Password in Cumulocity for login.
tenant – Cumulocity tenant.
nodes – Nodes to select in connection.
- read(nodes: Nodes | None = None) pd.DataFrame [source]
Download current value from the Cumulocity Database
- Parameters:
nodes – List of nodes to read values from.
- Returns:
pandas.DataFrame containing the data read from the connection.
- write(values: Mapping[AnyNode, Any] | pd.Series[datetime, Any], time_interval: timedelta | None = None) None [source]
Write data to a list of nodes
- Parameters:
values – Dictionary of nodes and data to write {node: value}.
- subscribe(handler: SubscriptionHandler, nodes: Nodes | None = None, interval: TimeStep = 1) None [source]
Subscribe to nodes and call handler when new data is available. This will return only the last available values.
- Parameters:
handler – SubscriptionHandler object with a push method that accepts node, value pairs.
interval – Interval for receiving new data. It is interpreted as seconds when given as an integer.
nodes – Identifiers for the nodes to subscribe to.
- read_series(from_time: datetime, to_time: datetime, nodes: Nodes | None = None, interval: TimeStep | None = None, **kwargs: Any) pd.DataFrame [source]
Download timeseries data from the Cumulocity Database
- Parameters:
nodes – List of nodes to read values from.
from_time – Starting time to begin reading.
to_time – Time to stop reading at.
interval – Interval between time steps. It is interpreted as seconds if given as integer (ignored by this connector).
kwargs – Other parameters (ignored by this connector).
- Returns:
Pandas DataFrame containing the data read from the connection.
- subscribe_series(handler: SubscriptionHandler, req_interval: TimeStep, offset: TimeStep | None = None, nodes: Nodes | None = None, interval: TimeStep = 1, data_interval: TimeStep = 1, **kwargs: Any) None [source]
Subscribe to nodes and call handler when new data is available. This will always return a series of values. If nodes with different intervals should be subscribed, multiple connection objects are needed.
- Parameters:
handler – SubscriptionHandler object with a push method that accepts node, value pairs.
req_interval – Duration covered by requested data (time interval). Interpreted as seconds if given as int.
offset – Offset from datetime.now from which to start requesting data (time interval). Interpreted as seconds if given as int. Use negative values to go to past timestamps.
data_interval – Time interval between values in returned data. Interpreted as seconds if given as int.
interval – interval (between requests) for receiving new data. It is interpreted as seconds when given as an integer.
nodes – Identifiers for the nodes to subscribe to.
kwargs – Other, ignored parameters.
- timestr_from_datetime(dt: datetime) str [source]
Create an Cumulocity compatible time string.
- Parameters:
dt – Datetime object to convert to string.
- Returns:
Cumulocity compatible time string.
- get_auth_header(node: NodeCumulocity) dict [source]
- exc: BaseException | None