eta_utility.connectors.eneffco module
Utility functions for connecting to the EnEffCo database and reading data.
- class eta_utility.connectors.eneffco.EnEffCoConnection(url: str, usr: str | None, pwd: str | None, *, api_token: str, nodes: Nodes[NodeEnEffCo] | None = None)[source]
Bases:
SeriesConnection
[NodeEnEffCo
]EnEffCoConnection is a class to download and upload multiple features from and to the EnEffCo database as timeseries.
- Parameters:
url – URL of the server with scheme (https://).
usr – Username in EnEffco for login.
pwd – Password in EnEffco for login.
api_token – Token for API authentication.
nodes – Nodes to select in connection.
- classmethod from_ids(ids: Sequence[str], url: str, usr: str, pwd: str, api_token: str) EnEffCoConnection [source]
Initialize the connection object from an EnEffCo protocol through the node IDs
- Parameters:
ids – Identification of the Node.
url – URL for EnEffco connection.
usr – Username for EnEffCo login.
pwd – Password for EnEffCo login.
api_token – Token for API authentication.
- Returns:
EnEffCoConnection object.
- read(nodes: Nodes[NodeEnEffCo] | None = None) pd.DataFrame [source]
Download current value from the EnEffCo Database
- Parameters:
nodes – List of nodes to read values from.
- Returns:
pandas.DataFrame containing the data read from the connection.
- write(values: Mapping[NodeEnEffCo, Any] | pd.Series[datetime, Any], time_interval: timedelta | None = None) None [source]
Writes some values to the EnEffCo Database
- Parameters:
values – Dictionary of nodes and data to write {node: value}.
time_interval – Interval between datapoints (i.e. between “From” and “To” in EnEffCo Upload) (default 1s).
- read_info(nodes: Nodes[NodeEnEffCo] | None = None) pd.DataFrame [source]
Read additional datapoint information from Database.
- Parameters:
nodes – List of nodes to read values from.
- Returns:
pandas.DataFrame containing the data read from the connection.
- subscribe(handler: SubscriptionHandler, nodes: Nodes[NodeEnEffCo] | 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[NodeEnEffCo] | None = None, interval: TimeStep = 1, **kwargs: Any) pd.DataFrame [source]
Download timeseries data from the EnEffCo Database
- Parameters:
nodes – List of nodes to read values from.
from_time – Starting time to begin reading (included in output).
to_time – Time to stop reading at (not included in output).
interval – Interval between time steps. It is interpreted as seconds if given as integer.
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[NodeEnEffCo] | 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.