Index
frequenz.client.assets ¤
Assets API client.
Classes¤
frequenz.client.assets.AssetsApiClient ¤
Bases: BaseApiClient[PlatformAssetsStub]
A client for the Assets API.
Source code in frequenz/client/assets/_client.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
Attributes¤
channel
property
¤
The underlying gRPC channel used to communicate with the server.
Warning
This channel is provided as a last resort for advanced users. It is not recommended to use this property directly unless you know what you are doing and you don't care about being tied to a specific gRPC library.
RAISES | DESCRIPTION |
---|---|
ClientNotConnected
|
If the client is not connected to the server. |
channel_defaults
property
¤
The default options for the gRPC channel.
stub
property
¤
The gRPC stub for the Assets API.
RETURNS | DESCRIPTION |
---|---|
PlatformAssetsAsyncStub
|
The gRPC stub for the Assets API. |
RAISES | DESCRIPTION |
---|---|
ClientNotConnected
|
If the client is not connected to the server. |
Functions¤
__aexit__
async
¤
__aexit__(
_exc_type: type[BaseException] | None,
_exc_val: BaseException | None,
_exc_tb: Any | None,
) -> bool | None
Exit a context manager.
Source code in frequenz/client/base/client.py
__init__ ¤
__init__(
server_url: str,
*,
auth_key: str | None = None,
sign_secret: str | None = None,
channel_defaults: ChannelOptions = ChannelOptions(),
connect: bool = True
) -> None
Initialize the AssetsApiClient.
PARAMETER | DESCRIPTION |
---|---|
server_url
|
The location of the microgrid API server in the form of a URL.
The following format is expected:
"grpc://hostname{:
TYPE:
|
auth_key
|
The authentication key to use for the connection.
TYPE:
|
sign_secret
|
The secret to use for signing requests.
TYPE:
|
channel_defaults
|
The default options use to create the channel when not specified in the URL.
TYPE:
|
connect
|
Whether to connect to the server as soon as a client instance is
created. If
TYPE:
|
Source code in frequenz/client/assets/_client.py
connect ¤
connect(
server_url: str | None = None,
*,
auth_key: str | None | EllipsisType = ...,
sign_secret: str | None | EllipsisType = ...
) -> None
Connect to the server, possibly using a new URL.
If the client is already connected and the URL is the same as the previous URL, this method does nothing. If you want to force a reconnection, you can call disconnect() first.
PARAMETER | DESCRIPTION |
---|---|
server_url
|
The URL of the server to connect to. If not provided, the previously used URL is used.
TYPE:
|
auth_key
|
The API key to use when connecting to the service. If an Ellipsis is provided, the previously used auth_key is used.
TYPE:
|
sign_secret
|
The secret to use when creating message HMAC. If an Ellipsis is provided,
TYPE:
|
Source code in frequenz/client/base/client.py
disconnect
async
¤
Disconnect from the server.
If the client is not connected, this method does nothing.
get_microgrid
async
¤
Get the details of a microgrid.
PARAMETER | DESCRIPTION |
---|---|
microgrid_id
|
The ID of the microgrid to get the details of.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Microgrid
|
The details of the microgrid. |
RAISES | DESCRIPTION |
---|---|
ApiClientError
|
If there are any errors communicating with the Assets API, most likely a subclass of GrpcError. |
Source code in frequenz/client/assets/_client.py
list_microgrid_electrical_components
async
¤
list_microgrid_electrical_components(
microgrid_id: int,
) -> list[ElectricalComponent]
Get the electrical components of a microgrid.
PARAMETER | DESCRIPTION |
---|---|
microgrid_id
|
The ID of the microgrid to get the electrical components of.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[ElectricalComponent]
|
The electrical components of the microgrid. |
Source code in frequenz/client/assets/_client.py
frequenz.client.assets.DeliveryArea
dataclass
¤
A geographical or administrative region where electricity deliveries occur.
DeliveryArea represents the geographical or administrative region, usually defined and maintained by a Transmission System Operator (TSO), where electricity deliveries for a contract occur.
The concept is important to energy trading as it delineates the agreed-upon delivery location. Delivery areas can have different codes based on the jurisdiction in which they operate.
Jurisdictional Differences
This is typically represented by specific codes according to local jurisdiction.
In Europe, this is represented by an EIC (Energy Identification Code). List of EICs.
Source code in frequenz/client/assets/_delivery_area.py
Attributes¤
code
instance-attribute
¤
code: str | None
The code representing the unique identifier for the delivery area.
code_type
instance-attribute
¤
code_type: EnergyMarketCodeType | int
Type of code used for identifying the delivery area itself.
This code could be extended in the future, in case an unknown code type is encountered, a plain integer value is used to represent it.
Functions¤
frequenz.client.assets.EnergyMarketCodeType ¤
Bases: Enum
The identification code types used in the energy market.
CodeType specifies the type of identification code used for uniquely identifying various entities such as delivery areas, market participants, and grid components within the energy market.
This enumeration aims to offer compatibility across different jurisdictional standards.
Understanding Code Types
Different regions or countries may have their own standards for uniquely identifying various entities within the energy market. For example, in Europe, the Energy Identification Code (EIC) is commonly used for this purpose.
Extensibility
New code types can be added to this enum to accommodate additional regional standards, enhancing the API's adaptability.
Validation Required
The chosen code type should correspond correctly with the code
field in
the relevant message objects, such as DeliveryArea
or Counterparty
.
Failure to match the code type with the correct code could lead to
processing errors.
Source code in frequenz/client/assets/_delivery_area.py
Attributes¤
EUROPE_EIC
class-attribute
instance-attribute
¤
European Energy Identification Code Standard.
UNSPECIFIED
class-attribute
instance-attribute
¤
Unspecified type. This value is a placeholder and should not be used.
US_NERC
class-attribute
instance-attribute
¤
North American Electric Reliability Corporation identifiers.
frequenz.client.assets.Location
dataclass
¤
A location of a microgrid.
Source code in frequenz/client/assets/_location.py
Attributes¤
country_code
instance-attribute
¤
country_code: str | None
The country code of the microgrid in ISO 3166-1 Alpha 2 format.
Functions¤
__str__ ¤
__str__() -> str
Return the short string representation of this instance.
Source code in frequenz/client/assets/_location.py
frequenz.client.assets.Microgrid
dataclass
¤
A localized grouping of electricity generation, energy storage, and loads.
A microgrid is a localized grouping of electricity generation, energy storage, and loads that normally operates connected to a traditional centralized grid.
Each microgrid has a unique identifier and is associated with an enterprise account.
A key feature is that it has a physical location and is situated in a delivery area.
Key Concepts
- Physical Location: Geographical coordinates specify the exact physical location of the microgrid.
- Delivery Area: Each microgrid is part of a broader delivery area, which is crucial for energy trading and compliance.
Source code in frequenz/client/assets/_microgrid.py
Attributes¤
create_timestamp
instance-attribute
¤
create_timestamp: datetime
The UTC timestamp indicating when the microgrid was initially created.
delivery_area
instance-attribute
¤
delivery_area: DeliveryArea | None
The delivery area where the microgrid is located, as identified by a specific code.
enterprise_id
instance-attribute
¤
The unique identifier linking this microgrid to its parent enterprise account.
location
instance-attribute
¤
location: Location | None
Physical location of the microgrid, in geographical co-ordinates.
Functions¤
frequenz.client.assets.MicrogridStatus ¤
Bases: Enum
The possible statuses for a microgrid.