Index
frequenz.client.common.microgrid.electrical_components ¤
Defines the electrical components that can be used in a microgrid.
Attributes¤
frequenz.client.common.microgrid.electrical_components.BatteryTypes
module-attribute
¤
BatteryTypes: TypeAlias = (
LiIonBattery
| NaIonBattery
| UnrecognizedBattery
| UnspecifiedBattery
)
All possible battery types.
frequenz.client.common.microgrid.electrical_components.DefaultT
module-attribute
¤
DefaultT = TypeVar('DefaultT')
A type variable for the default value of dict-like getters.
frequenz.client.common.microgrid.electrical_components.ElectricalComponentConnectionTypes
module-attribute
¤
ElectricalComponentConnectionTypes: TypeAlias = (
ElectricalComponentConnection
| ProblematicElectricalComponentConnectionTypes
)
All concrete electrical component connection types.
These are the concrete leaf types of electrical component connections that can
be actually instantiated. Match against this union to exhaustively handle
every kind of connection returned by the *_from_proto converters.
frequenz.client.common.microgrid.electrical_components.ElectricalComponentTypes
module-attribute
¤
ElectricalComponentTypes: TypeAlias = (
BatteryTypes
| Breaker
| CapacitorBank
| Chp
| Converter
| CryptoMiner
| Electrolyzer
| EvChargerTypes
| GridConnectionPoint
| Hvac
| InverterTypes
| Meter
| MismatchedCategoryElectricalComponent
| Plc
| PowerTransformer
| Precharger
| StaticTransferSwitch
| SteamBoiler
| UninterruptiblePowerSupply
| UnrecognizedElectricalComponent
| UnspecifiedElectricalComponent
| WindTurbine
)
All concrete electrical component types.
These are the concrete leaf types of electrical components than can be actually instantiated.
frequenz.client.common.microgrid.electrical_components.EvChargerTypes
module-attribute
¤
EvChargerTypes: TypeAlias = (
UnspecifiedEvCharger
| AcEvCharger
| DcEvCharger
| HybridEvCharger
| UnrecognizedEvCharger
)
All possible EV charger types.
frequenz.client.common.microgrid.electrical_components.InverterTypes
module-attribute
¤
InverterTypes: TypeAlias = (
UnspecifiedInverter
| BatteryInverter
| PvInverter
| HybridInverter
| UnrecognizedInverter
)
All possible inverter types.
frequenz.client.common.microgrid.electrical_components.ProblematicElectricalComponentConnectionTypes
module-attribute
¤
ProblematicElectricalComponentConnectionTypes: TypeAlias = (
SelfReferencingElectricalComponentConnection
)
All possible electrical component connection types that have a problem.
frequenz.client.common.microgrid.electrical_components.ProblematicElectricalComponentTypes
module-attribute
¤
ProblematicElectricalComponentTypes: TypeAlias = (
MismatchedCategoryElectricalComponent
| UnrecognizedElectricalComponentTypes
| UnspecifiedElectricalComponentTypes
)
All possible electrical component types that have a problem.
frequenz.client.common.microgrid.electrical_components.UnrecognizedElectricalComponentTypes
module-attribute
¤
UnrecognizedElectricalComponentTypes: TypeAlias = (
UnrecognizedBattery
| UnrecognizedElectricalComponent
| UnrecognizedEvCharger
| UnrecognizedInverter
)
All unrecognized electrical component types.
frequenz.client.common.microgrid.electrical_components.UnspecifiedElectricalComponentTypes
module-attribute
¤
UnspecifiedElectricalComponentTypes: TypeAlias = (
UnspecifiedBattery
| UnspecifiedElectricalComponent
| UnspecifiedEvCharger
| UnspecifiedInverter
)
All unspecified electrical component types.
Classes¤
frequenz.client.common.microgrid.electrical_components.AcEvCharger
dataclass
¤
Bases: EvCharger
An EV charger that supports AC charging only.
Source code in src/frequenz/client/common/microgrid/electrical_components/_ev_charger.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_ev_charger.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.BaseElectricalComponentConnection
dataclass
¤
A base class for all electrical component connections.
This is the common supertype of every kind of connection, both
well-formed (see
ElectricalComponentConnection) and
problematic (see
ProblematicElectricalComponentConnection).
It cannot be instantiated directly; use one of its concrete subclasses
instead, or obtain instances via the corresponding *_from_proto
converter.
Physical Representation
This object is not about data flow but rather about the physical electrical connections between electrical components. Therefore, the IDs for the source and destination electrical components correspond to the actual setup within the microgrid.
Direction
The direction of the connection follows the flow of current away from the grid connection point, or in case of islands, away from the islanding point. This direction is aligned with positive current according to the Passive Sign Convention.
Historical Data
The timestamps of when a connection was created and terminated allow for tracking the changes over time to a microgrid, providing insights into when and how the microgrid infrastructure has been modified.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 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 | |
Attributes¤
destination_id
instance-attribute
¤
destination_id: ElectricalComponentId
The unique ID of the electrical component where the connection terminates.
This is the electrical component towards which the current flows.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of the connection.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
source_id
instance-attribute
¤
source_id: ElectricalComponentId
The unique identifier of the electrical component where the connection originates.
This is aligned with the direction of current flow away from the grid connection point, or in case of islands, away from the islanding point.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
is_operational_at ¤
Check whether this connection is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check against the operational lifetime.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this connection is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
is_operational_now ¤
is_operational_now() -> bool
Whether this connection is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this connection is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
frequenz.client.common.microgrid.electrical_components.Battery
dataclass
¤
Bases: ElectricalComponent
An abstract battery electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_battery.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_battery.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.BatteryInverter
dataclass
¤
Bases: Inverter
A battery inverter.
Source code in src/frequenz/client/common/microgrid/electrical_components/_inverter.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_inverter.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.Breaker
dataclass
¤
Bases: ElectricalComponent
A breaker electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_breaker.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.CapacitorBank
dataclass
¤
Bases: ElectricalComponent
A capacitor bank electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_capacitor_bank.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.CategorySpecificInfo
dataclass
¤
The category specific info carried by an electrical component.
A protobuf electrical component may carry a category_specific_info variant
with extra fields tied to its category. Fields this library version
understands are translated into typed attributes on the concrete component
(e.g. the battery type). Anything left over — either because the component's
category is not recognized, or because a newer API version added fields this
client doesn't know yet — is preserved here so callers can still inspect the
raw values.
Source code in src/frequenz/client/common/microgrid/electrical_components/_category_specific_info.py
frequenz.client.common.microgrid.electrical_components.Chp
dataclass
¤
Bases: ElectricalComponent
A combined heat and power (CHP) electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_chp.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.Converter
dataclass
¤
Bases: ElectricalComponent
An AC-DC converter electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_converter.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.CryptoMiner
dataclass
¤
Bases: ElectricalComponent
A crypto miner electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_crypto_miner.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.DcEvCharger
dataclass
¤
Bases: EvCharger
An EV charger that supports DC charging only.
Source code in src/frequenz/client/common/microgrid/electrical_components/_ev_charger.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_ev_charger.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.ElectricalComponent
dataclass
¤
A base class for all electrical components.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
22 23 24 25 26 27 28 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 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 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.ElectricalComponentCategory ¤
Bases: Enum
Possible types of microgrid electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_category.py
Attributes¤
BATTERY
class-attribute
instance-attribute
¤
BATTERY = deprecated_member(5, _member_message('BATTERY'))
A battery energy storage system.
BREAKER
class-attribute
instance-attribute
¤
BREAKER = deprecated_member(7, _member_message('BREAKER'))
A circuit breaker, providing protection and switching by disconnecting circuits.
CAPACITOR_BANK
class-attribute
instance-attribute
¤
CAPACITOR_BANK = deprecated_member(
17, _member_message("CAPACITOR_BANK")
)
A capacitor bank, used for power factor correction and reactive power compensation.
CHP
class-attribute
instance-attribute
¤
CHP = deprecated_member(9, _member_message('CHP'))
A combined heat and power (CHP) plant.
It generates electricity and useful heat from a single energy source.
CONVERTER
class-attribute
instance-attribute
¤
CONVERTER = deprecated_member(
4, _member_message("CONVERTER")
)
An electricity converter, e.g., a DC-DC converter.
CRYPTO_MINER
class-attribute
instance-attribute
¤
CRYPTO_MINER = deprecated_member(
14, _member_message("CRYPTO_MINER")
)
A device for mining cryptocurrencies.
ELECTROLYZER
class-attribute
instance-attribute
¤
ELECTROLYZER = deprecated_member(
10, _member_message("ELECTROLYZER")
)
A device for splitting water into hydrogen and oxygen using electricity.
EV_CHARGER
class-attribute
instance-attribute
¤
EV_CHARGER = deprecated_member(
6, _member_message("EV_CHARGER")
)
A station for charging electrical vehicles.
GRID_CONNECTION_POINT
class-attribute
instance-attribute
¤
GRID_CONNECTION_POINT = deprecated_member(
1, _member_message("GRID_CONNECTION_POINT")
)
The point where the local microgrid is connected to the grid.
HVAC
class-attribute
instance-attribute
¤
HVAC = deprecated_member(12, _member_message('HVAC'))
A heating, ventilation, and air conditioning (HVAC) system.
INVERTER
class-attribute
instance-attribute
¤
INVERTER = deprecated_member(3, _member_message("INVERTER"))
An inverter that converts DC to AC power and vice versa.
METER
class-attribute
instance-attribute
¤
METER = deprecated_member(2, _member_message('METER'))
A meter, for measuring electrical metrics, e.g., current, voltage, etc.
PLC
class-attribute
instance-attribute
¤
PLC = deprecated_member(13, _member_message('PLC'))
A programmable logic controller (PLC).
POWER_TRANSFORMER
class-attribute
instance-attribute
¤
POWER_TRANSFORMER = deprecated_member(
11, _member_message("POWER_TRANSFORMER")
)
A transformer, used for changing the voltage of electrical circuits.
PRECHARGER
class-attribute
instance-attribute
¤
PRECHARGER = deprecated_member(
8, _member_message("PRECHARGER")
)
A precharger, used for preparing electrical circuits for switching on.
STATIC_TRANSFER_SWITCH
class-attribute
instance-attribute
¤
STATIC_TRANSFER_SWITCH = deprecated_member(
15, _member_message("STATIC_TRANSFER_SWITCH")
)
A static transfer switch, used for switching between power sources.
STEAM_BOILER
class-attribute
instance-attribute
¤
STEAM_BOILER = deprecated_member(
19, _member_message("STEAM_BOILER")
)
A steam boiler, used to generate steam for heating or industrial processes.
UNINTERRUPTIBLE_POWER_SUPPLY
class-attribute
instance-attribute
¤
UNINTERRUPTIBLE_POWER_SUPPLY = deprecated_member(
16, _member_message("UNINTERRUPTIBLE_POWER_SUPPLY")
)
An uninterruptible power supply (UPS), used to provide backup power.
UNSPECIFIED
class-attribute
instance-attribute
¤
UNSPECIFIED = deprecated_member(
0, _member_message("UNSPECIFIED")
)
The component category is unspecified. This should not be used.
WIND_TURBINE
class-attribute
instance-attribute
¤
WIND_TURBINE = deprecated_member(
18, _member_message("WIND_TURBINE")
)
A wind turbine, used to generate electricity from wind energy.
frequenz.client.common.microgrid.electrical_components.ElectricalComponentConnection
dataclass
¤
Bases: BaseElectricalComponentConnection
A single electrical link between two distinct electrical components in a microgrid.
This is the well-formed case of an electrical component connection: the
source and destination are guaranteed to be different components.
Malformed cases (e.g. self-loops) are represented by dedicated
subclasses of
ProblematicElectricalComponentConnection
instead.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
Attributes¤
destination_id
instance-attribute
¤
destination_id: ElectricalComponentId
The unique ID of the electrical component where the connection terminates.
This is the electrical component towards which the current flows.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of the connection.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
source_id
instance-attribute
¤
source_id: ElectricalComponentId
The unique identifier of the electrical component where the connection originates.
This is aligned with the direction of current flow away from the grid connection point, or in case of islands, away from the islanding point.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
__post_init__ ¤
Ensure that the source and destination electrical components are different.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
is_operational_at ¤
Check whether this connection is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check against the operational lifetime.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this connection is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
is_operational_now ¤
is_operational_now() -> bool
Whether this connection is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this connection is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
frequenz.client.common.microgrid.electrical_components.ElectricalComponentDiagnosticCode ¤
Bases: Enum
All diagnostics that can occur across electrical component categories.
Source code in src/frequenz/client/common/microgrid/electrical_components/_diagnostic_code.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 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 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 | |
Attributes¤
BATTERY_BLOCK_ERROR
class-attribute
instance-attribute
¤
Battery block error detected.
BATTERY_CALIBRATION_NEEDED
class-attribute
instance-attribute
¤
Battery calibration is needed.
BATTERY_CONTROLLER_ERROR
class-attribute
instance-attribute
¤
Battery controller error detected.
BATTERY_IMBALANCE
class-attribute
instance-attribute
¤
Battery system imbalance detected.
BATTERY_LOW_SOH
class-attribute
instance-attribute
¤
Low state of health (SOH) detected in the battery.
BATTERY_RELAY_ERROR
class-attribute
instance-attribute
¤
Battery relay error detected.
CONFIG_ERROR
class-attribute
instance-attribute
¤
Configuration error related to the component.
EV_CHARGING_CABLE_INVALID
class-attribute
instance-attribute
¤
Invalid electric vehicle (EV) cable.
EV_CHARGING_CABLE_LOCK_FAILED
class-attribute
instance-attribute
¤
Electric vehicle (EV) cable lock failure.
EV_CHARGING_CABLE_UNPLUGGED_FROM_EV
class-attribute
instance-attribute
¤
Electric vehicle (EV) cable was abruptly unplugged from the vehicle.
EV_CHARGING_CABLE_UNPLUGGED_FROM_STATION
class-attribute
instance-attribute
¤
Electric vehicle (EV) cable was abruptly unplugged from the charging station.
EV_CONSUMER_INCOMPATIBLE
class-attribute
instance-attribute
¤
Incompatible electric vehicle (EV) plug.
EV_UNEXPECTED_PILOT_FAILURE
class-attribute
instance-attribute
¤
Unexpected pilot failure in an electric vehicle (EV) component.
EXCESS_LEAKAGE_CURRENT
class-attribute
instance-attribute
¤
Excess leakage current detected, over the threshold defined by the manufacturer.
FAULT_CURRENT
class-attribute
instance-attribute
¤
Fault current detected in the component.
GRID_ABNORMAL
class-attribute
instance-attribute
¤
The component is inoperable due to the grid being in a non-standard configuration.
GRID_DISCONNECTED
class-attribute
instance-attribute
¤
The component is inoperable due to the grid being disconnected.
This happens despite the AC relay being closed.
GRID_OVERFREQUENCY
class-attribute
instance-attribute
¤
The component is inoperable due to the grid frequency being too high.
GRID_OVERVOLTAGE
class-attribute
instance-attribute
¤
The component is inoperable due to the grid voltage being too high.
GRID_UNDERFREQUENCY
class-attribute
instance-attribute
¤
The component is inoperable due to the grid frequency being too low.
GRID_UNDERVOLTAGE
class-attribute
instance-attribute
¤
The component is inoperable due to the grid voltage being too low.
GRID_VOLTAGE_IMBALANCE
class-attribute
instance-attribute
¤
The component is inoperable due to the grid voltage being imbalanced.
This happens when the voltage of one or more phases is outside the acceptable range.
GROUND_FAULT
class-attribute
instance-attribute
¤
Ground fault detected in the component.
HARDWARE_FAULT
class-attribute
instance-attribute
¤
Hardware fault detected in the component.
HARDWARE_INACCESSIBLE
class-attribute
instance-attribute
¤
The hardware of the component is inaccessible.
HIGH_HUMIDITY
class-attribute
instance-attribute
¤
The component is exposed to high humidity levels over the maximum rated value.
ILLEGAL_COMPONENT_STATE_CODE_REQUESTED
class-attribute
instance-attribute
¤
An illegal state was requested for the component.
INVERTER_DC_OVERVOLTAGE
class-attribute
instance-attribute
¤
The inverter is inoperable due to the DC voltage being too high.
INVERTER_DC_UNDERVOLTAGE
class-attribute
instance-attribute
¤
The inverter is inoperable due to the DC voltage being too low.
LOW_SYSTEM_INSULATION_RESISTANCE
class-attribute
instance-attribute
¤
The component is inoperable due to the insulation resistance being too low.
The threshold is defined by the manufacturer or configured by the user.
OVERCURRENT
class-attribute
instance-attribute
¤
The component is drawing more current than the maximum rated value.
OVERCURRENT_CHARGING
class-attribute
instance-attribute
¤
The component's consumption current is over the maximum rated value during charging.
OVERCURRENT_DISCHARGING
class-attribute
instance-attribute
¤
The component's production current is over the maximum rated value during discharging.
OVERTEMPERATURE
class-attribute
instance-attribute
¤
The component is operating over the maximum rated temperature.
OVERVOLTAGE
class-attribute
instance-attribute
¤
The component is operating over the maximum rated voltage.
PLAUSIBILITY_ERROR
class-attribute
instance-attribute
¤
Plausibility issues within the component, causing its internal sanity checks to fail.
PRECHARGE_ERROR
class-attribute
instance-attribute
¤
The component's precharge unit has failed.
PROTECTIVE_SHUTDOWN
class-attribute
instance-attribute
¤
The component performed a protective shutdown.
PV_GROUND_FAULT
class-attribute
instance-attribute
¤
Ground fault detected on the photovoltaic (PV) side.
PV_REVERSAL_POLARITY
class-attribute
instance-attribute
¤
Reverse polarity condition detected on the photovoltaic (PV) side.
PV_REVERSE_CURRENT
class-attribute
instance-attribute
¤
Reverse current condition detected on the photovoltaic (PV) side.
PV_UNDERPERFORMANCE
class-attribute
instance-attribute
¤
The photovoltaic (PV) system is underperforming.
RELAY_CYCLE_LIMIT_REACHED
class-attribute
instance-attribute
¤
The battery's DC contactor or relays have reached end of life.
SHORT_CIRCUIT
class-attribute
instance-attribute
¤
Short circuit detected in the component.
SWITCH_ON_FAULT
class-attribute
instance-attribute
¤
The component could not be switched on.
UNAUTHORIZED
class-attribute
instance-attribute
¤
The component is unauthorized to perform the last requested action.
UNDERTEMPERATURE
class-attribute
instance-attribute
¤
The component is operating under the minimum rated temperature.
UNDERVOLTAGE
class-attribute
instance-attribute
¤
The component is operating under the minimum rated voltage.
UNKNOWN
class-attribute
instance-attribute
¤
The component is reporting an unknown or an undefined error.
The sender cannot parse the component error to any of the variants below.
UNSPECIFIED
class-attribute
instance-attribute
¤
UNSPECIFIED = deprecated_member(
0,
"ElectricalComponentDiagnosticCode.UNSPECIFIED is deprecated; use the `int` value `0` instead if you really need to check for this low-level value.",
)
Default value. No specific error is specified.
frequenz.client.common.microgrid.electrical_components.ElectricalComponentId ¤
Bases: BaseId
A unique identifier for a microgrid electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_ids.py
Attributes¤
Methods:¤
__eq__ ¤
Check if this instance is equal to another object.
Equality is defined as being of the exact same type and having the same underlying ID.
| PARAMETER | DESCRIPTION |
|---|---|
other
|
The object to compare against.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if |
bool
|
|
Source code in frequenz/core/id.py
__hash__ ¤
__hash__() -> int
Return the hash of this instance.
The hash is based on the exact type and the underlying ID to ensure that IDs of different types but with the same numeric value have different hashes.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The hash of this instance. |
Source code in frequenz/core/id.py
__init__ ¤
__init__(id_: int) -> None
Initialize this instance.
| PARAMETER | DESCRIPTION |
|---|---|
id_
|
The numeric unique identifier.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the ID is negative. |
Source code in frequenz/core/id.py
__init_subclass__ ¤
Initialize a subclass, set its string prefix, and perform checks.
| PARAMETER | DESCRIPTION |
|---|---|
str_prefix
|
The string prefix for the ID type (e.g., "MID"). Must be unique across all ID types.
TYPE:
|
allow_custom_name
|
If True, bypasses the check that the class name must end with "Id". Defaults to False.
TYPE:
|
**kwargs
|
Forwarded to the parent's init_subclass.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If |
Source code in frequenz/core/id.py
__lt__ ¤
Check if this instance is less than another object.
Comparison is only defined between instances of the exact same type.
| PARAMETER | DESCRIPTION |
|---|---|
other
|
The object to compare against.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if this instance is less than |
bool
|
|
Source code in frequenz/core/id.py
__new__ ¤
Create a new instance of the ID class, only if it is a subclass of BaseId.
frequenz.client.common.microgrid.electrical_components.ElectricalComponentStateCode ¤
Bases: Enum
All possible states of a microgrid electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_state_code.py
Attributes¤
CHARGING
class-attribute
instance-attribute
¤
The component is actively consuming energy.
DISCHARGING
class-attribute
instance-attribute
¤
The component is actively producing or releasing energy.
ERROR
class-attribute
instance-attribute
¤
The component is in an error state and may need attention.
EV_CHARGING_CABLE_LOCKED_AT_EV
class-attribute
instance-attribute
¤
The EV charging cable is locked at the vehicle end, indicating that charging is active.
EV_CHARGING_CABLE_LOCKED_AT_STATION
class-attribute
instance-attribute
¤
The EV charging cable is locked at the charging station end, ready for charging.
EV_CHARGING_CABLE_PLUGGED_AT_EV
class-attribute
instance-attribute
¤
The EV charging cable is plugged into the vehicle.
EV_CHARGING_CABLE_PLUGGED_AT_STATION
class-attribute
instance-attribute
¤
The EV charging cable is plugged into the charging station.
EV_CHARGING_CABLE_UNPLUGGED
class-attribute
instance-attribute
¤
The Electric Vehicle (EV) charging cable is unplugged from the charging station.
PRECHARGER_CLOSED
class-attribute
instance-attribute
¤
The precharger circuit is closed, allowing full current to flow to the main circuit.
PRECHARGER_OPEN
class-attribute
instance-attribute
¤
The precharger circuit is open, meaning it's not currently active.
PRECHARGER_PRECHARGING
class-attribute
instance-attribute
¤
The precharger is in a precharging state, preparing the main circuit for activation.
READY
class-attribute
instance-attribute
¤
The component is fully operational and ready for use.
RELAY_CLOSED
class-attribute
instance-attribute
¤
The relay is in a closed state, allowing current to flow.
RELAY_OPEN
class-attribute
instance-attribute
¤
The relay is in an open state, meaning no current can flow through.
STANDBY
class-attribute
instance-attribute
¤
The component is in standby mode, and not immediately ready for operation.
SWITCHING_OFF
class-attribute
instance-attribute
¤
The component is in the process of switching off.
SWITCHING_ON
class-attribute
instance-attribute
¤
The component is in the process of switching on from an off state.
UNAVAILABLE
class-attribute
instance-attribute
¤
The component is temporarily unavailable for operation.
UNKNOWN
class-attribute
instance-attribute
¤
The component is in an unknown or undefined condition.
This is used when the sender is unable to classify the component into any other state.
UNSPECIFIED
class-attribute
instance-attribute
¤
UNSPECIFIED = deprecated_member(
0,
"ElectricalComponentStateCode.UNSPECIFIED is deprecated; use the `int` value `0` instead if you really need to check for this low-level value.",
)
Default value when the component state is not explicitly set.
frequenz.client.common.microgrid.electrical_components.Electrolyzer
dataclass
¤
Bases: ElectricalComponent
An electrolyzer electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrolyzer.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.EvCharger
dataclass
¤
Bases: ElectricalComponent
An abstract EV charger electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_ev_charger.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_ev_charger.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.GridConnectionPoint
dataclass
¤
Bases: ElectricalComponent
A point where a local electrical system connects to the grid.
The terms "Grid Connection Point" and "Point of Common Coupling" (PCC) are commonly used in the context.
While both terms describe a connection point to the grid, the
GridConnectionPoint is specifically the physical connection point of the
generation facility to the grid, often concerned with the technical and
ownership aspects of the connection.
In contrast, the PCC is more specific in terms of electrical engineering. It refers to the point where a customer's local electrical system connects to the utility distribution grid in such a way that it can affect other customers’ systems connected to the same network. It is the point where the grid and customer's electrical systems interface and where issues like power quality and supply regulations are assessed.
The term GridConnectionPoint is used to make it clear that what is referred
to here is the physical connection point of the local facility to the grid.
Note that this may also be the PCC in some cases.
Source code in src/frequenz/client/common/microgrid/electrical_components/_grid_connection_point.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
rated_fuse_current
instance-attribute
¤
rated_fuse_current: int
The maximum amount of electrical current that can flow through this connection, in amperes.
The rated maximum amount of current the fuse at the grid connection point is designed to safely carry under normal operating conditions.
This limit applies to currents both flowing in or out of each of the 3 phases individually.
In other words, a current iA at one of the phases of the grid connection
point must comply with the following constraint:
-rated_fuse_current <= i <= rated_fuse_current.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Run the base construction gate and validate the fuse's rated current.
Source code in src/frequenz/client/common/microgrid/electrical_components/_grid_connection_point.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.Hvac
dataclass
¤
Bases: ElectricalComponent
A heating, ventilation, and air conditioning (HVAC) electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_hvac.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.HybridEvCharger
dataclass
¤
Bases: EvCharger
An EV charger that supports both AC and DC charging.
Source code in src/frequenz/client/common/microgrid/electrical_components/_ev_charger.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_ev_charger.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.HybridInverter
dataclass
¤
Bases: Inverter
A hybrid inverter.
Source code in src/frequenz/client/common/microgrid/electrical_components/_inverter.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_inverter.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.Inverter
dataclass
¤
Bases: ElectricalComponent
An abstract inverter electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_inverter.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_inverter.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.LiIonBattery
dataclass
¤
Bases: Battery
A Li-ion battery.
Source code in src/frequenz/client/common/microgrid/electrical_components/_battery.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_battery.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.Meter
dataclass
¤
Bases: ElectricalComponent
A measuring meter electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_meter.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.MismatchedCategoryElectricalComponent
dataclass
¤
Bases: ProblematicElectricalComponent
An electrical component with a mismatch in the category.
This electrical component declared a category but carries category specific info that doesn't match the declared category.
Source code in src/frequenz/client/common/microgrid/electrical_components/_problematic.py
Attributes¤
category
instance-attribute
¤
category: int
The raw category declared by this component.
It doesn't match the carried category specific info.
category_name
class-attribute
instance-attribute
¤
category_name: str | None = None
The short protobuf name of the declared category, or None if unknown.
This is the protobuf enum name without its long prefix (e.g. "BATTERY").
It is normally set, since a mismatched component declares a recognized
category.
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_problematic.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__str__ ¤
__str__() -> str
Return a string representation exposing the category mismatch.
Source code in src/frequenz/client/common/microgrid/electrical_components/_problematic.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.NaIonBattery
dataclass
¤
Bases: Battery
A Na-ion battery.
Source code in src/frequenz/client/common/microgrid/electrical_components/_battery.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_battery.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.Plc
dataclass
¤
Bases: ElectricalComponent
A programmable logic controller (PLC) electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_plc.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.PowerTransformer
dataclass
¤
Bases: ElectricalComponent
A power transformer electrical component.
Power transformers are used to step up or step down the voltage, keeping the power somewhat constant by increasing or decreasing the current.
If voltage is stepped up, current is stepped down, and vice versa.
Note
Power transformers have efficiency losses, so the output power is always less than the input power.
Source code in src/frequenz/client/common/microgrid/electrical_components/_power_transformer.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
primary_voltage
instance-attribute
¤
primary_voltage: FloatInt
The primary voltage of the transformer, in volts.
This is the input voltage that is stepped up or down.
secondary_voltage
instance-attribute
¤
secondary_voltage: FloatInt
The secondary voltage of the transformer, in volts.
This is the output voltage that is the result of stepping the primary voltage up or down.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.Precharger
dataclass
¤
Bases: ElectricalComponent
A precharger electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_precharger.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.ProblematicElectricalComponent
dataclass
¤
Bases: ElectricalComponent
An abstract electrical component with a problem.
Source code in src/frequenz/client/common/microgrid/electrical_components/_problematic.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_problematic.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.ProblematicElectricalComponentConnection
dataclass
¤
Bases: BaseElectricalComponentConnection
An abstract electrical component connection with a problem.
This is the base class for connections that carry a data-integrity issue.
Problematic connections are siblings of the well-formed
ElectricalComponentConnection: both
extend
BaseElectricalComponentConnection.
Source code in src/frequenz/client/common/microgrid/electrical_components/_problematic_connection.py
Attributes¤
destination_id
instance-attribute
¤
destination_id: ElectricalComponentId
The unique ID of the electrical component where the connection terminates.
This is the electrical component towards which the current flows.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of the connection.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
source_id
instance-attribute
¤
source_id: ElectricalComponentId
The unique identifier of the electrical component where the connection originates.
This is aligned with the direction of current flow away from the grid connection point, or in case of islands, away from the islanding point.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_problematic_connection.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
is_operational_at ¤
Check whether this connection is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check against the operational lifetime.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this connection is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
is_operational_now ¤
is_operational_now() -> bool
Whether this connection is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this connection is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
frequenz.client.common.microgrid.electrical_components.PvInverter
dataclass
¤
Bases: Inverter
A PV inverter.
Source code in src/frequenz/client/common/microgrid/electrical_components/_inverter.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_inverter.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.SelfReferencingElectricalComponentConnection
dataclass
¤
Bases: ProblematicElectricalComponentConnection
An electrical component connection whose source and destination are the same.
This represents a self-loop in the microgrid topology, which is physically
impossible and normally invalid. Instances of this class are produced by
the *_from_proto converters when they receive a connection whose
source and destination component IDs are identical, so that the
problematic data is exposed to the caller instead of being silently
discarded.
Source code in src/frequenz/client/common/microgrid/electrical_components/_problematic_connection.py
Attributes¤
destination_id
instance-attribute
¤
destination_id: ElectricalComponentId
The unique ID of the electrical component where the connection terminates.
This is the electrical component towards which the current flows.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of the connection.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
source_id
instance-attribute
¤
source_id: ElectricalComponentId
The unique identifier of the electrical component where the connection originates.
This is aligned with the direction of current flow away from the grid connection point, or in case of islands, away from the islanding point.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_problematic_connection.py
__post_init__ ¤
Ensure that source and destination refer to the same component.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_problematic_connection.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
is_operational_at ¤
Check whether this connection is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check against the operational lifetime.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this connection is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
is_operational_now ¤
is_operational_now() -> bool
Whether this connection is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this connection is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component_connection.py
frequenz.client.common.microgrid.electrical_components.StaticTransferSwitch
dataclass
¤
Bases: ElectricalComponent
A static transfer switch electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_static_transfer_switch.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.SteamBoiler
dataclass
¤
Bases: ElectricalComponent
A steam boiler electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_steam_boiler.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.UninterruptiblePowerSupply
dataclass
¤
Bases: ElectricalComponent
An uninterruptible power supply (UPS) electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_uninterruptible_power_supply.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.UnrecognizedBattery
dataclass
¤
Bases: Battery, ProblematicElectricalComponent
A battery of an unrecognized type.
Source code in src/frequenz/client/common/microgrid/electrical_components/_battery.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
type
instance-attribute
¤
type: int
The raw type of this battery, not recognized by this library version.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_battery.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.UnrecognizedElectricalComponent
dataclass
¤
Bases: ProblematicElectricalComponent
An electrical component of an unrecognized type.
This is used for components whose category is not known to this version of the library.
Source code in src/frequenz/client/common/microgrid/electrical_components/_problematic.py
Attributes¤
category
instance-attribute
¤
category: int
The raw category of this component, not recognized by this library version.
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_problematic.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.UnrecognizedEvCharger
dataclass
¤
Bases: EvCharger, ProblematicElectricalComponent
An EV charger of an unrecognized type.
Source code in src/frequenz/client/common/microgrid/electrical_components/_ev_charger.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
type
instance-attribute
¤
type: int
The raw type of this EV charger, not recognized by this library version.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_ev_charger.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.UnrecognizedInverter
dataclass
¤
Bases: Inverter, ProblematicElectricalComponent
An inverter of an unrecognized type.
Source code in src/frequenz/client/common/microgrid/electrical_components/_inverter.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
type
instance-attribute
¤
type: int
The raw type of this inverter, not recognized by this library version.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_inverter.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.UnspecifiedBattery
dataclass
¤
Bases: Battery, ProblematicElectricalComponent
A battery of an unspecified type.
Source code in src/frequenz/client/common/microgrid/electrical_components/_battery.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_battery.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.UnspecifiedElectricalComponent
dataclass
¤
Bases: ProblematicElectricalComponent
An electrical component of unspecified type.
Source code in src/frequenz/client/common/microgrid/electrical_components/_problematic.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_problematic.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.UnspecifiedEvCharger
dataclass
¤
Bases: EvCharger, ProblematicElectricalComponent
An EV charger of an unspecified type.
Source code in src/frequenz/client/common/microgrid/electrical_components/_ev_charger.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_ev_charger.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.UnspecifiedInverter
dataclass
¤
Bases: Inverter, ProblematicElectricalComponent
An inverter of an unspecified type.
Source code in src/frequenz/client/common/microgrid/electrical_components/_inverter.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_inverter.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
frequenz.client.common.microgrid.electrical_components.WindTurbine
dataclass
¤
Bases: ElectricalComponent
A wind turbine electrical component.
Source code in src/frequenz/client/common/microgrid/electrical_components/_wind_turbine.py
Attributes¤
category_specific_info
class-attribute
instance-attribute
¤
category_specific_info: CategorySpecificInfo | None = None
The category specific info carried by this component, if any.
This is None when the wire carried no category-specific info variant.
Otherwise it holds a
CategorySpecificInfo recording the variant
kind together with any fields that were not translated into typed
attributes on this component. The leftover fields are empty when everything
was translated, and non-empty when the category or its variant is not
recognized, or when a newer API version added fields this client version
doesn't know yet.
identity
property
¤
identity: tuple[ElectricalComponentId, MicrogridId]
The identity of this electrical component.
This uses the component ID and microgrid ID to identify an electrical component without considering the other attributes, so even if an electrical component state changed, the identity remains the same.
metric_config_bounds
class-attribute
instance-attribute
¤
metric_config_bounds: Mapping[
Metric | int, BoundsSet | InvalidBoundsSet
] = dataclasses.field(default_factory=dict, hash=False)
The metric configuration bounds for this electrical component, keyed by metric.
These bounds may be derived from the component configuration, manufacturer limits, or limits of other devices.
Each metric maps to the aggregate of all the bounds configured for it: a
BoundsSet when every one is well-formed, or an
InvalidBoundsSet preserving all the raw
bounds when any is malformed.
If an unspecified metric is received, it is stored as the plain int key 0 when
loading from protobuf. Metrics unknown to this client version may also appear
as plain int keys for forward-compatibility.
Warning
A Metric and its numeric value are distinct keys: Metric is not an
int subclass, so a Metric argument only matches Metric-keyed
entries and an int argument only matches int-keyed entries. int
metrics should only be used to look up unrecognized metrics, including
the raw 0 used for an unspecified metric.
Tip
Prefer get_metric_config_bounds()
when a valid BoundsSet is required.
microgrid_id
instance-attribute
¤
microgrid_id: MicrogridId
The ID of the microgrid this electrical component belongs to.
model
instance-attribute
¤
model: str
The model of this electrical component.
This includes both the manufacturer and the model name.
operational_lifetime
class-attribute
instance-attribute
¤
operational_lifetime: Lifetime | InvalidLifetime = (
dataclasses.field(default_factory=Lifetime)
)
The operational lifetime of this electrical component.
An InvalidLifetime preserves malformed wire data.
Tip
Prefer get_operational_lifetime() when
a valid lifetime is required.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
__post_init__ ¤
Reject direct construction of this read-only type.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the instance was not created via the corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
accepts_control ¤
accepts_control() -> bool
Check whether this electrical component accepts control commands.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component accepts control commands. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_metric_config_bounds ¤
Return the configured bounds for a metric as a valid BoundsSet.
An absent entry returns an unbounded metric, so when no bounds are
configured for metric this returns an unbounded
BoundsSet by default. Pass
default to return a different value for absent entries instead,
mimicking dict.get().
Warning
A Metric and its numeric value are distinct keys: Metric is not
an int subclass, so a Metric argument only matches
Metric-keyed entries and an int argument only matches
int-keyed entries. int metrics should only be used to look up
unrecognized metrics, including the raw 0 used for an unspecified
metric.
Example
To check if a metric has valid configured bounds, you can use:
component: ElectricalComponent
metric: Metric
if component.get_metric_config_bounds(metric, default=None) is not None:
print(f"{metric} has valid configured bounds")
This is similar to accessing
metric_config_bounds
directly, but avoid the special handling of invalid bounds.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric whose bounds to retrieve. A raw |
default
|
The value to return when no bounds are configured for
|
| RETURNS | DESCRIPTION |
|---|---|
object
|
The valid |
| RAISES | DESCRIPTION |
|---|---|
InvalidBoundsSetError
|
If the bounds configured for |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
get_operational_lifetime ¤
get_operational_lifetime() -> Lifetime
Return the operational lifetime as a valid Lifetime.
| RETURNS | DESCRIPTION |
|---|---|
Lifetime
|
The valid operational lifetime. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_at ¤
Check whether this electrical component is operational at a specific timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
timestamp
|
The timestamp to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the given timestamp. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
is_operational_now ¤
is_operational_now() -> bool
Check whether this electrical component is currently operational.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component is operational at the current time. |
| RAISES | DESCRIPTION |
|---|---|
InvalidLifetimeError
|
If malformed lifetime data was received. The
offending value is available on the exception's |
Source code in src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py
provides_telemetry ¤
provides_telemetry() -> bool
Check whether this electrical component provides telemetry data.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether this electrical component provides telemetry data. |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the operational mode is unspecified. |
UnrecognizedEnumValueError
|
If the operational mode is not recognized.
The raw value is available on the error's |