Index
frequenz.client.assets ¤
Assets API client.
Classes¤
frequenz.client.assets.AssetsApiClient ¤
Bases: BaseApiClient[PlatformAssetsStub]
A client for the Assets API.
Source code in src/frequenz/client/assets/_client.py
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 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
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 src/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:
|
raise_on_errors
|
If True, raise an InvalidMicrogridError when major validation issues are found instead of just logging them.
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. |
InvalidMicrogridError
|
If |
Source code in src/frequenz/client/assets/_client.py
list_microgrid_electrical_component_connections
async
¤
list_microgrid_electrical_component_connections(
microgrid_id: MicrogridId,
source_component_ids: Iterable[
ElectricalComponentId
] = (),
destination_component_ids: Iterable[
ElectricalComponentId
] = (),
*,
raise_on_errors: bool = False
) -> list[ComponentConnection]
Get the electrical component connections of a microgrid.
| PARAMETER | DESCRIPTION |
|---|---|
microgrid_id
|
The ID of the microgrid to get the electrical component connections of.
TYPE:
|
source_component_ids
|
Only return connections that originate from these component IDs. If None or empty, no filtering is applied.
TYPE:
|
destination_component_ids
|
Only return connections that terminate at these component IDs. If None or empty, no filtering is applied.
TYPE:
|
raise_on_errors
|
If True, raise an
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[ComponentConnection]
|
The electrical component connections of the microgrid. |
| RAISES | DESCRIPTION |
|---|---|
ExceptionGroup
|
If |
Source code in src/frequenz/client/assets/_client.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
list_microgrid_electrical_components
async
¤
list_microgrid_electrical_components(
microgrid_id: MicrogridId,
*,
raise_on_errors: bool = False
) -> 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:
|
raise_on_errors
|
If True, raise an
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[ElectricalComponent]
|
The electrical components of the microgrid. |
| RAISES | DESCRIPTION |
|---|---|
ExceptionGroup
|
If |
Source code in src/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 src/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 src/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.Lifetime
dataclass
¤
An active operational period of a microgrid asset.
Warning
The end timestamp indicates that the
asset has been permanently removed from the system.
Source code in src/frequenz/client/assets/_lifetime.py
Attributes¤
end
class-attribute
instance-attribute
¤
end: datetime | None = None
The moment when the asset's operational activity ceased.
If None, the asset is considered to be active with no plans to be deactivated.
start
class-attribute
instance-attribute
¤
start: datetime | None = None
The moment when the asset became operationally active.
If None, the asset is considered to be active in any past moment previous to the
end.
Functions¤
__post_init__ ¤
Validate this lifetime.
Source code in src/frequenz/client/assets/_lifetime.py
is_operational_at ¤
Check whether this lifetime is active at a specific timestamp.
Source code in src/frequenz/client/assets/_lifetime.py
frequenz.client.assets.Location
dataclass
¤
A location of a microgrid.
Source code in src/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 src/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 src/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.