eta_nexus.connections.eneffco_connection module
- class eta_nexus.connections.eneffco_connection.EneffcoConnection(url: str, usr: str, pwd: str, *, nodes: Nodes[EneffcoNode] | None = None, retry_total: int = 3, retry_backoff_factor: float = 1.0)[source]
Bases:
RESTConnection[EneffcoNode],Connection[EneffcoNode],StatusReadable[EneffcoNode],StatusWritable[EneffcoNode],StatusSubscribable[EneffcoNode],SeriesReadable[EneffcoNode],SeriesSubscribable[EneffcoNode]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.
nodes – Nodes to select in connection.
retry_total – Total number of retries for failed HTTP requests (default: 3).
retry_backoff_factor – Backoff factor for retries (default: 1s-> e.g. 1s, 2s, 4s for 3 retries).
- logger: Logger = <Logger eta_nexus.connections.eneffco_connection (WARNING)>
- property authentication: HTTPBasicAuth
Return the authentication method for the API.
- classmethod from_ids(ids: Sequence[str], url: str, usr: str, pwd: 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.
- Returns:
EneffcoConnection object.
- read(nodes: EneffcoNode | Nodes[EneffcoNode] | 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[EneffcoNode, Primitive] | pd.Series[datetime, Primitive], 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: EneffcoNode | Nodes[EneffcoNode] | 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: EneffcoNode | Nodes[EneffcoNode] | 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: EneffcoNode | Nodes[EneffcoNode] | 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 connection).
- Returns:
Pandas DataFrame containing the data read from the connection.
- read_node(node: EneffcoNode, from_time: datetime, to_time: datetime, interval: timedelta, **kwargs: Any) pd.DataFrame[source]
Read data from a REST API endpoint.
- Parameters:
node – Node to read data from.
from_time – Start of the time series (timezone-aware).
to_time – End of the time series (timezone-aware).
interval – Time interval between data points.
kwargs – Additional subclass-specific arguments.
- Returns:
DataFrame containing the data read from the API.
- subscribe_series(handler: SubscriptionHandler, req_interval: TimeStep, offset: TimeStep | None = None, nodes: EneffcoNode | Nodes[EneffcoNode] | 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.