EnEffco Connection
EnEffCoConnection
- class eta_utility.connectors.EnEffCoConnection(url: str, usr: str | None, pwd: str | None, *, api_token: str | None = None, nodes: Nodes[NodeEnEffCo] | None = None)[source]
- 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. 
 
 - API_PATH: str = '/API/v1.0'
 - classmethod from_ids(ids: Sequence[str], url: str, usr: str, pwd: str, api_token: str | None = None) 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: NodeEnEffCo | Nodes[NodeEnEffCo] | None = None) pd.DataFrame[source]
- Download current value from the EnEffCo Database - Parameters:
- nodes – Single node or list/set 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: NodeEnEffCo | Nodes[NodeEnEffCo] | None = None) pd.DataFrame[source]
- Read additional datapoint information from Database. - Parameters:
- nodes – Single node or list/set of nodes values from. 
- Returns:
- pandas.DataFrame containing the data read from the connection. 
 
 - subscribe(handler: SubscriptionHandler, nodes: NodeEnEffCo | 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 – Single node or list/set of nodes to subscribe to. 
 
 
 - read_series(from_time: datetime, to_time: datetime, nodes: NodeEnEffCo | Nodes[NodeEnEffCo] | None = None, interval: TimeStep = 1, **kwargs: Any) pd.DataFrame[source]
- Download timeseries data from the EnEffCo Database - Parameters:
- nodes – Single node or list/set 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: NodeEnEffCo | 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 – Single node or list/set of nodes to subscribe to. 
- kwargs – Other, ignored parameters. 
 
 
 - id_from_code(code: str, raw_datapoint: bool = False) str[source]
- Function to get the raw EnEffCo ID corresponding to a specific (raw) datapoint - Parameters:
- code – Exact EnEffCo code. 
- raw_datapoint – Returns raw datapoint ID. 
 
 
 - timestr_from_datetime(dt: datetime) str[source]
- Create an EnEffCo compatible time string. - Parameters:
- dt – Datetime object to convert to string. 
- Returns:
- EnEffCo compatible time string. 
 
 - exc: BaseException | None
 
NodeEnEffCo
- class eta_utility.connectors.node.NodeEnEffCo(name: str, url: str, protocol: str, *args: Any, **kwargs: Any)[source]
- Node for the EnEffCo API. - eneffco_code: str
- EnEffCo datapoint code / ID. 
 - name: str
- Name for the node. 
 - url: str
- URL of the connection. 
 - url_parsed: ParseResult
- Parse result object of the URL (in case more post-processing is required). 
 - dtype: Callable | None
- Data type of the node (for value conversion). Note that strings will be interpreted as utf-8 encoded. If you do not want this behaviour, use ‘bytes’. 
 
Example Usage
A simple example using the EnEffCo connection:
# Create the connection object
connection = EnEffCoConnection.from_ids(
    ["CH1.Elek_U.L1-N", "Pu3.425.ThHy_Q"],
    url="https://someurl.com/",
    usr="username",
    pwd="password",
    api_token="your_api_token",
)
# Read series data within a specified time interval
from_time = datetime.fromisoformat("2019-01-01 00:00:00")
to_time = datetime.fromisoformat("2019-01-02 00:00:00")
return connection.read_series(from_time, to_time, interval=900)