Skip to content

component

frequenz.client.microgrid.component ¤

All classes and functions related to microgrid components.

Attributes¤

frequenz.client.microgrid.component.BatteryTypes module-attribute ¤

All possible battery types.

frequenz.client.microgrid.component.ComponentTypes module-attribute ¤

All possible component types.

frequenz.client.microgrid.component.EvChargerTypes module-attribute ¤

All possible EV charger types.

frequenz.client.microgrid.component.ProblematicComponentTypes module-attribute ¤

ProblematicComponentTypes: TypeAlias = (
    MismatchedCategoryComponent
    | UnrecognizedComponentTypes
    | UnspecifiedComponentTypes
)

All possible component types that has a problem.

frequenz.client.microgrid.component.UnspecifiedComponentTypes module-attribute ¤

All unspecified component types.

Classes¤

frequenz.client.microgrid.component.AcEvCharger dataclass ¤

Bases: EvCharger

An EV charger that supports AC charging only.

Source code in frequenz/client/microgrid/component/_ev_charger.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class AcEvCharger(EvCharger):
    """An EV charger that supports AC charging only."""

    type: Literal[EvChargerType.AC] = EvChargerType.AC
    """The type of this EV charger.

    Note:
        This should not be used normally, you should test if a EV charger
        [`isinstance`][] of a concrete component class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about the new EV charger type yet (i.e. for use with
        [`UnrecognizedEvCharger`][frequenz.client.microgrid.component.UnrecognizedEvCharger]).
    """
Attributes¤
category class-attribute instance-attribute ¤

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete EV charger class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type class-attribute instance-attribute ¤
type: Literal[AC] = AC

The type of this EV charger.

Note

This should not be used normally, you should test if a EV charger isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about the new EV charger type yet (i.e. for use with UnrecognizedEvCharger).

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_ev_charger.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is EvCharger:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.Battery dataclass ¤

Bases: Component

An abstract battery component.

Source code in frequenz/client/microgrid/component/_battery.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class Battery(Component):
    """An abstract battery component."""

    category: Literal[ComponentCategory.BATTERY] = ComponentCategory.BATTERY
    """The category of this component.

    Note:
        This should not be used normally, you should test if a component
        [`isinstance`][] of a concrete component class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about a new category yet (i.e. for use with
        [`UnrecognizedComponent`][frequenz.client.microgrid.component.UnrecognizedComponent])
        and in case some low level code needs to know the category of a component.
    """

    type: BatteryType | int
    """The type of this battery.

    Note:
        This should not be used normally, you should test if a battery
        [`isinstance`][] of a concrete battery class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about the new battery type yet (i.e. for use with
        [`UnrecognizedBattery`][frequenz.client.microgrid.component.UnrecognizedBattery]).
    """

    # pylint: disable-next=unused-argument
    def __new__(cls, *args: Any, **kwargs: Any) -> Self:
        """Prevent instantiation of this class."""
        if cls is Battery:
            raise TypeError(f"Cannot instantiate {cls.__name__} directly")
        return super().__new__(cls)
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[BATTERY] = BATTERY

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type instance-attribute ¤
type: BatteryType | int

The type of this battery.

Note

This should not be used normally, you should test if a battery isinstance of a concrete battery class instead.

It is only provided for using with a newer version of the API where the client doesn't know about the new battery type yet (i.e. for use with UnrecognizedBattery).

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_battery.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Battery:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.BatteryInverter dataclass ¤

Bases: Inverter

A battery inverter.

Source code in frequenz/client/microgrid/component/_inverter.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class BatteryInverter(Inverter):
    """A battery inverter."""

    type: Literal[InverterType.BATTERY] = InverterType.BATTERY
    """The type of this inverter.

    Note:
        This should not be used normally, you should test if a inverter
        [`isinstance`][] of a concrete inverter class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about the new inverter type yet (i.e. for use with
        [`UnrecognizedInverter`][frequenz.client.microgrid.component.UnrecognizedInverter]).
    """
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[INVERTER] = INVERTER

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type class-attribute instance-attribute ¤

The type of this inverter.

Note

This should not be used normally, you should test if a inverter isinstance of a concrete inverter class instead.

It is only provided for using with a newer version of the API where the client doesn't know about the new inverter type yet (i.e. for use with UnrecognizedInverter).

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_inverter.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Inverter:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.BatteryType ¤

Bases: Enum

The known types of batteries.

Source code in frequenz/client/microgrid/component/_battery.py
@enum.unique
class BatteryType(enum.Enum):
    """The known types of batteries."""

    UNSPECIFIED = electrical_components_pb2.BATTERY_TYPE_UNSPECIFIED
    """The battery type is unspecified."""

    LI_ION = electrical_components_pb2.BATTERY_TYPE_LI_ION
    """Lithium-ion (Li-ion) battery."""

    NA_ION = electrical_components_pb2.BATTERY_TYPE_NA_ION
    """Sodium-ion (Na-ion) battery."""
Attributes¤
LI_ION class-attribute instance-attribute ¤
LI_ION = BATTERY_TYPE_LI_ION

Lithium-ion (Li-ion) battery.

NA_ION class-attribute instance-attribute ¤
NA_ION = BATTERY_TYPE_NA_ION

Sodium-ion (Na-ion) battery.

UNSPECIFIED class-attribute instance-attribute ¤
UNSPECIFIED = BATTERY_TYPE_UNSPECIFIED

The battery type is unspecified.

frequenz.client.microgrid.component.Chp dataclass ¤

Bases: Component

A combined heat and power (CHP) component.

Source code in frequenz/client/microgrid/component/_chp.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class Chp(Component):
    """A combined heat and power (CHP) component."""

    category: Literal[ComponentCategory.CHP] = ComponentCategory.CHP
    """The category of this component."""
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[CHP] = CHP

The category of this component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

Functions¤
__new__ ¤
__new__(*_: Any, **__: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_component.py
def __new__(cls, *_: Any, **__: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Component:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.Component dataclass ¤

A base class for all components.

Source code in frequenz/client/microgrid/component/_component.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class Component:  # pylint: disable=too-many-instance-attributes
    """A base class for all components."""

    id: ComponentId
    """This component's ID."""

    microgrid_id: MicrogridId
    """The ID of the microgrid this component belongs to."""

    category: ComponentCategory | int
    """The category of this component.

    Note:
        This should not be used normally, you should test if a component
        [`isinstance`][] of a concrete component class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about a new category yet (i.e. for use with
        [`UnrecognizedComponent`][frequenz.client.microgrid.component.UnrecognizedComponent])
        and in case some low level code needs to know the category of a component.
        """

    name: str | None = None
    """The name of this component."""

    manufacturer: str | None = None
    """The manufacturer of this component."""

    model_name: str | None = None
    """The model name of this component."""

    operational_lifetime: Lifetime = dataclasses.field(default_factory=Lifetime)
    """The operational lifetime of this component."""

    rated_bounds: Mapping[Metric | int, Bounds] = dataclasses.field(
        default_factory=dict,
        # dict is not hashable, so we don't use this field to calculate the hash. This
        # shouldn't be a problem since it is very unlikely that two components with all
        # other attributes being equal would have different category specific metadata,
        # so hash collisions should be still very unlikely.
        hash=False,
    )
    """List of rated bounds present for the component identified by Metric."""

    category_specific_metadata: Mapping[str, Any] = dataclasses.field(
        default_factory=dict,
        # dict is not hashable, so we don't use this field to calculate the hash. This
        # shouldn't be a problem since it is very unlikely that two components with all
        # other attributes being equal would have different category specific metadata,
        # so hash collisions should be still very unlikely.
        hash=False,
    )
    """The category specific metadata of this component.

    Note:
        This should not be used normally, it is only useful when accessing a newer
        version of the API where the client doesn't know about the new metadata fields
        yet (i.e. for use with
        [`UnrecognizedComponent`][frequenz.client.microgrid.component.UnrecognizedComponent]).
    """

    def __new__(cls, *_: Any, **__: Any) -> Self:
        """Prevent instantiation of this class."""
        if cls is Component:
            raise TypeError(f"Cannot instantiate {cls.__name__} directly")
        return super().__new__(cls)

    def is_operational_at(self, timestamp: datetime) -> bool:
        """Check whether this component is operational at a specific timestamp.

        Args:
            timestamp: The timestamp to check.

        Returns:
            Whether this component is operational at the given timestamp.
        """
        return self.operational_lifetime.is_operational_at(timestamp)

    def is_operational_now(self) -> bool:
        """Check whether this component is currently operational.

        Returns:
            Whether this component is operational at the current time.
        """
        return self.is_operational_at(datetime.now(timezone.utc))

    @property
    def identity(self) -> tuple[ComponentId, MicrogridId]:
        """The identity of this component.

        This uses the component ID and microgrid ID to identify a component
        without considering the other attributes, so even if a component state
        changed, the identity remains the same.
        """
        return (self.id, self.microgrid_id)

    def __str__(self) -> str:
        """Return a human-readable string representation of this instance."""
        name = f":{self.name}" if self.name else ""
        return f"{self.id}<{type(self).__name__}>{name}"
Attributes¤
category instance-attribute ¤
category: ComponentCategory | int

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

Functions¤
__new__ ¤
__new__(*_: Any, **__: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_component.py
def __new__(cls, *_: Any, **__: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Component:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.ComponentCategory ¤

Bases: Enum

The known categories of components that can be present in a microgrid.

Source code in frequenz/client/microgrid/component/_category.py
@enum.unique
class ComponentCategory(enum.Enum):
    """The known categories of components that can be present in a microgrid."""

    UNSPECIFIED = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_UNSPECIFIED
    """The component category is unspecified, probably due to an error in the message."""

    GRID_CONNECTION_POINT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_GRID_CONNECTION_POINT
    )
    """The point where the local microgrid is connected to the grid."""

    GRID = enum.deprecated_member(
        electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_GRID_CONNECTION_POINT,
        "GRID is deprecated, use GRID_CONNECTION_POINT instead",
    )
    """The point where the local microgrid is connected to the grid (deprecated).

    Deprecated: Deprecated in v0.18.0
        Use
        [`GRID_CONNECTION_POINT`][frequenz.client.microgrid.component.ComponentCategory.GRID_CONNECTION_POINT]
        instead.
    """

    METER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_METER
    """A meter, for measuring electrical metrics, e.g., current, voltage, etc."""

    INVERTER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_INVERTER
    """An electricity generator, with batteries or solar energy."""

    CONVERTER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_CONVERTER
    """A DC-DC converter."""

    BATTERY = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_BATTERY
    """A storage system for electrical energy, used by inverters."""

    EV_CHARGER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_EV_CHARGER
    """A station for charging electrical vehicles."""

    CRYPTO_MINER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_CRYPTO_MINER
    """A crypto miner."""

    ELECTROLYZER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_ELECTROLYZER
    """An electrolyzer for converting water into hydrogen and oxygen."""

    CHP = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_CHP
    """A heat and power combustion plant (CHP stands for combined heat and power)."""

    RELAY = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_BREAKER
    """A relay.

    Relays generally have two states: open (connected) and closed (disconnected).
    They are generally placed in front of a component, e.g., an inverter, to
    control whether the component is connected to the grid or not.
    """

    PRECHARGER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_PRECHARGER
    """A precharge module.

    Precharging involves gradually ramping up the DC voltage to prevent any
    potential damage to sensitive electrical components like capacitors.

    While many inverters and batteries come equipped with in-built precharging
    mechanisms, some may lack this feature. In such cases, we need to use
    external precharging modules.
    """

    POWER_TRANSFORMER = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_POWER_TRANSFORMER
    )
    """A power transformer.

    A power transformer is designed for the bulk transfer of electrical energy. Its main
    job is to "step-up" or "step-down" voltage levels for efficient transmission and
    distribution of power.

    Since power transformers try to keep the output power same as the input
    power (ignoring losses), when they step-up the voltage, the current gets
    proportionally reduced, and vice versa.
    """

    VOLTAGE_TRANSFORMER = enum.deprecated_member(
        electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_POWER_TRANSFORMER,
        "VOLTAGE_TRANSFORMER is deprecated, use POWER_TRANSFORMER instead",
    )
    """A voltage transformer (deprecated).

    Deprecated: Deprecated in v0.18.0
        Use
        [`POWER_TRANSFORMER`][frequenz.client.microgrid.component.ComponentCategory.POWER_TRANSFORMER]
        instead.
    """

    HVAC = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_HVAC
    """A Heating, Ventilation, and Air Conditioning (HVAC) system."""
Attributes¤
BATTERY class-attribute instance-attribute ¤
BATTERY = ELECTRICAL_COMPONENT_CATEGORY_BATTERY

A storage system for electrical energy, used by inverters.

CHP class-attribute instance-attribute ¤
CHP = ELECTRICAL_COMPONENT_CATEGORY_CHP

A heat and power combustion plant (CHP stands for combined heat and power).

CONVERTER class-attribute instance-attribute ¤
CONVERTER = ELECTRICAL_COMPONENT_CATEGORY_CONVERTER

A DC-DC converter.

CRYPTO_MINER class-attribute instance-attribute ¤
CRYPTO_MINER = ELECTRICAL_COMPONENT_CATEGORY_CRYPTO_MINER

A crypto miner.

ELECTROLYZER class-attribute instance-attribute ¤
ELECTROLYZER = ELECTRICAL_COMPONENT_CATEGORY_ELECTROLYZER

An electrolyzer for converting water into hydrogen and oxygen.

EV_CHARGER class-attribute instance-attribute ¤
EV_CHARGER = ELECTRICAL_COMPONENT_CATEGORY_EV_CHARGER

A station for charging electrical vehicles.

GRID class-attribute instance-attribute ¤
GRID = deprecated_member(
    ELECTRICAL_COMPONENT_CATEGORY_GRID_CONNECTION_POINT,
    "GRID is deprecated, use GRID_CONNECTION_POINT instead",
)

The point where the local microgrid is connected to the grid (deprecated).

Deprecated in v0.18.0

Use GRID_CONNECTION_POINT instead.

GRID_CONNECTION_POINT class-attribute instance-attribute ¤
GRID_CONNECTION_POINT = (
    ELECTRICAL_COMPONENT_CATEGORY_GRID_CONNECTION_POINT
)

The point where the local microgrid is connected to the grid.

HVAC class-attribute instance-attribute ¤
HVAC = ELECTRICAL_COMPONENT_CATEGORY_HVAC

A Heating, Ventilation, and Air Conditioning (HVAC) system.

INVERTER class-attribute instance-attribute ¤
INVERTER = ELECTRICAL_COMPONENT_CATEGORY_INVERTER

An electricity generator, with batteries or solar energy.

METER class-attribute instance-attribute ¤
METER = ELECTRICAL_COMPONENT_CATEGORY_METER

A meter, for measuring electrical metrics, e.g., current, voltage, etc.

POWER_TRANSFORMER class-attribute instance-attribute ¤
POWER_TRANSFORMER = (
    ELECTRICAL_COMPONENT_CATEGORY_POWER_TRANSFORMER
)

A power transformer.

A power transformer is designed for the bulk transfer of electrical energy. Its main job is to "step-up" or "step-down" voltage levels for efficient transmission and distribution of power.

Since power transformers try to keep the output power same as the input power (ignoring losses), when they step-up the voltage, the current gets proportionally reduced, and vice versa.

PRECHARGER class-attribute instance-attribute ¤
PRECHARGER = ELECTRICAL_COMPONENT_CATEGORY_PRECHARGER

A precharge module.

Precharging involves gradually ramping up the DC voltage to prevent any potential damage to sensitive electrical components like capacitors.

While many inverters and batteries come equipped with in-built precharging mechanisms, some may lack this feature. In such cases, we need to use external precharging modules.

RELAY class-attribute instance-attribute ¤
RELAY = ELECTRICAL_COMPONENT_CATEGORY_BREAKER

A relay.

Relays generally have two states: open (connected) and closed (disconnected). They are generally placed in front of a component, e.g., an inverter, to control whether the component is connected to the grid or not.

UNSPECIFIED class-attribute instance-attribute ¤
UNSPECIFIED = ELECTRICAL_COMPONENT_CATEGORY_UNSPECIFIED

The component category is unspecified, probably due to an error in the message.

VOLTAGE_TRANSFORMER class-attribute instance-attribute ¤
VOLTAGE_TRANSFORMER = deprecated_member(
    ELECTRICAL_COMPONENT_CATEGORY_POWER_TRANSFORMER,
    "VOLTAGE_TRANSFORMER is deprecated, use POWER_TRANSFORMER instead",
)

A voltage transformer (deprecated).

Deprecated in v0.18.0

Use POWER_TRANSFORMER instead.

frequenz.client.microgrid.component.ComponentConnection dataclass ¤

A single electrical link between two components within a microgrid.

A component connection represents the physical wiring as viewed from the grid connection point, if one exists, or from the islanding point, in case of an islanded microgrids.

Physical Representation

This object is not about data flow but rather about the physical electrical connections between components. Therefore, the IDs for the source and destination 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] (https://en.wikipedia.org/wiki/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 frequenz/client/microgrid/component/_connection.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class ComponentConnection:
    """A single electrical link between two components within a microgrid.

    A component connection represents the physical wiring as viewed from the grid
    connection point, if one exists, or from the islanding point, in case of an islanded
    microgrids.

    Note: Physical Representation
        This object is not about data flow but rather about the physical
        electrical connections between components. Therefore, the IDs for the
        source and destination components correspond to the actual setup within
        the microgrid.

    Note: 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]
        (https://en.wikipedia.org/wiki/Passive_sign_convention).

    Note: 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: ComponentId
    """The unique identifier of the 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.
    """

    destination: ComponentId
    """The unique ID of the component where the connection terminates.

    This is the component towards which the current flows.
    """

    operational_lifetime: Lifetime = dataclasses.field(default_factory=Lifetime)
    """The operational lifetime of the connection."""

    def __post_init__(self) -> None:
        """Ensure that the source and destination components are different."""
        if self.source == self.destination:
            raise ValueError("Source and destination components must be different")

    def is_operational_at(self, timestamp: datetime) -> bool:
        """Check whether this connection is operational at a specific timestamp."""
        return self.operational_lifetime.is_operational_at(timestamp)

    def is_operational_now(self) -> bool:
        """Whether this connection is currently operational."""
        return self.is_operational_at(datetime.now(timezone.utc))

    def __str__(self) -> str:
        """Return a human-readable string representation of this instance."""
        return f"{self.source}->{self.destination}"
Attributes¤
destination instance-attribute ¤
destination: ComponentId

The unique ID of the component where the connection terminates.

This is the component towards which the current flows.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of the connection.

source instance-attribute ¤
source: ComponentId

The unique identifier of the 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.

Functions¤
__post_init__ ¤
__post_init__() -> None

Ensure that the source and destination components are different.

Source code in frequenz/client/microgrid/component/_connection.py
def __post_init__(self) -> None:
    """Ensure that the source and destination components are different."""
    if self.source == self.destination:
        raise ValueError("Source and destination components must be different")
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_connection.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    return f"{self.source}->{self.destination}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this connection is operational at a specific timestamp.

Source code in frequenz/client/microgrid/component/_connection.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this connection is operational at a specific timestamp."""
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Whether this connection is currently operational.

Source code in frequenz/client/microgrid/component/_connection.py
def is_operational_now(self) -> bool:
    """Whether this connection is currently operational."""
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.ComponentDataSamples dataclass ¤

An aggregate of multiple metrics, states, and errors of a component.

Source code in frequenz/client/microgrid/component/_data_samples.py
@dataclass(frozen=True, kw_only=True)
class ComponentDataSamples:
    """An aggregate of multiple metrics, states, and errors of a component."""

    component_id: ComponentId
    """The unique identifier of the component."""

    metric_samples: list[MetricSample]
    """The metrics sampled from the component."""

    states: list[ComponentStateSample]
    """The states sampled from the component."""
Attributes¤
component_id instance-attribute ¤
component_id: ComponentId

The unique identifier of the component.

metric_samples instance-attribute ¤
metric_samples: list[MetricSample]

The metrics sampled from the component.

states instance-attribute ¤

The states sampled from the component.

frequenz.client.microgrid.component.ComponentErrorCode ¤

Bases: Enum

The various errors that a component can report.

Source code in frequenz/client/microgrid/component/_state_sample.py
@enum.unique
class ComponentErrorCode(enum.Enum):
    """The various errors that a component can report."""

    UNSPECIFIED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNSPECIFIED
    )
    """The error is unspecified (this should not be normally used)."""

    UNKNOWN = electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNKNOWN
    """The component is reporting an unknown or undefined error.

    This is used when the error can be retrieved from the component but it doesn't match
    any known error.
    """

    SWITCH_ON_FAULT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_SWITCH_ON_FAULT
    )
    """The component could not be switched on."""

    UNDERVOLTAGE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNDERVOLTAGE
    )
    """The component is operating under the minimum rated voltage."""

    OVERVOLTAGE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERVOLTAGE
    )
    """The component is operating over the maximum rated voltage."""

    OVERCURRENT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERCURRENT
    )
    """The component is drawing more current than the maximum rated value."""

    OVERCURRENT_CHARGING = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERCURRENT_CHARGING
    )
    """The component's consumption current is over the maximum rated value during charging."""

    OVERCURRENT_DISCHARGING = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERCURRENT_DISCHARGING
    )
    """The component's production current is over the maximum rated value during discharging."""

    OVERTEMPERATURE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERTEMPERATURE
    )
    """The component is operating over the maximum rated temperature."""

    UNDERTEMPERATURE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNDERTEMPERATURE
    )
    """The component is operating under the minimum rated temperature."""

    HIGH_HUMIDITY = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_HIGH_HUMIDITY
    )
    """The component is exposed to high humidity levels over the maximum rated value."""

    FUSE_ERROR = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_FUSE_ERROR
    )
    """The component's fuse has blown."""

    PRECHARGE_ERROR = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PRECHARGE_ERROR
    )
    """The component's precharge unit has failed."""

    PLAUSIBILITY_ERROR = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PLAUSIBILITY_ERROR
    )
    """Plausibility issues within the system involving this component."""

    UNDERVOLTAGE_SHUTDOWN = enum.deprecated_member(
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNDERVOLTAGE,
        "UNDERVOLTAGE_SHUTDOWN is deprecated, use UNDERVOLTAGE instead",
    )
    """System shutdown due to undervoltage involving this component.

    Deprecated: Deprecated in v0.18.0
        Use
        [`UNDERVOLTAGE`][frequenz.client.microgrid.component.ComponentErrorCode.UNDERVOLTAGE]
        instead.
    """

    EV_UNEXPECTED_PILOT_FAILURE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_UNEXPECTED_PILOT_FAILURE
    )
    """Unexpected pilot failure in an electric vehicle component."""

    FAULT_CURRENT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_FAULT_CURRENT
    )
    """Fault current detected in the component."""

    SHORT_CIRCUIT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_SHORT_CIRCUIT
    )
    """Short circuit detected in the component."""

    CONFIG_ERROR = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_CONFIG_ERROR
    )
    """Configuration error related to the component."""

    ILLEGAL_ELECTRICAL_COMPONENT_STATE_CODE_REQUESTED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_ILLEGAL_COMPONENT_STATE_CODE_REQUESTED  # noqa: E501
    )
    """Illegal state requested for the component."""

    HARDWARE_INACCESSIBLE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_HARDWARE_INACCESSIBLE
    )
    """Hardware of the component is inaccessible."""

    INTERNAL = electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_INTERNAL
    """Internal error within the component."""

    UNAUTHORIZED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNAUTHORIZED
    )
    """The component is unauthorized to perform the last requested action."""

    EV_CHARGING_CABLE_UNPLUGGED_FROM_STATION = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_UNPLUGGED_FROM_STATION  # noqa: E501
    )
    """EV cable was abruptly unplugged from the charging station."""

    EV_CHARGING_CABLE_UNPLUGGED_FROM_EV = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_UNPLUGGED_FROM_EV  # noqa: E501
    )
    """EV cable was abruptly unplugged from the vehicle."""

    EV_CHARGING_CABLE_LOCK_FAILED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_LOCK_FAILED
    )
    """EV cable lock failure."""

    EV_CHARGING_CABLE_INVALID = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_INVALID
    )
    """Invalid EV cable."""

    EV_CONSUMER_INCOMPATIBLE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CONSUMER_INCOMPATIBLE
    )
    """Incompatible EV plug."""

    BATTERY_IMBALANCE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_IMBALANCE
    )
    """Battery system imbalance."""

    BATTERY_LOW_SOH = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_LOW_SOH
    )
    """Low state of health (SOH) detected in the battery."""

    BATTERY_BLOCK_ERROR = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_BLOCK_ERROR
    )
    """Battery block error."""

    BATTERY_CONTROLLER_ERROR = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_CONTROLLER_ERROR
    )
    """Battery controller error."""

    BATTERY_RELAY_ERROR = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_RELAY_ERROR
    )
    """Battery relay error."""

    BATTERY_CALIBRATION_NEEDED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_CALIBRATION_NEEDED
    )
    """Battery calibration is needed."""

    RELAY_CYCLE_LIMIT_REACHED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_RELAY_CYCLE_LIMIT_REACHED
    )
    """Relays have been cycled for the maximum number of times."""
Attributes¤
BATTERY_BLOCK_ERROR class-attribute instance-attribute ¤
BATTERY_BLOCK_ERROR = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_BLOCK_ERROR
)

Battery block error.

BATTERY_CALIBRATION_NEEDED class-attribute instance-attribute ¤
BATTERY_CALIBRATION_NEEDED = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_CALIBRATION_NEEDED

Battery calibration is needed.

BATTERY_CONTROLLER_ERROR class-attribute instance-attribute ¤
BATTERY_CONTROLLER_ERROR = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_CONTROLLER_ERROR

Battery controller error.

BATTERY_IMBALANCE class-attribute instance-attribute ¤
BATTERY_IMBALANCE = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_IMBALANCE
)

Battery system imbalance.

BATTERY_LOW_SOH class-attribute instance-attribute ¤
BATTERY_LOW_SOH = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_LOW_SOH
)

Low state of health (SOH) detected in the battery.

BATTERY_RELAY_ERROR class-attribute instance-attribute ¤
BATTERY_RELAY_ERROR = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_RELAY_ERROR
)

Battery relay error.

CONFIG_ERROR class-attribute instance-attribute ¤
CONFIG_ERROR = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_CONFIG_ERROR
)

Configuration error related to the component.

EV_CHARGING_CABLE_INVALID class-attribute instance-attribute ¤
EV_CHARGING_CABLE_INVALID = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_INVALID

Invalid EV cable.

EV_CHARGING_CABLE_LOCK_FAILED class-attribute instance-attribute ¤
EV_CHARGING_CABLE_LOCK_FAILED = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_LOCK_FAILED

EV cable lock failure.

EV_CHARGING_CABLE_UNPLUGGED_FROM_EV class-attribute instance-attribute ¤
EV_CHARGING_CABLE_UNPLUGGED_FROM_EV = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_UNPLUGGED_FROM_EV

EV cable was abruptly unplugged from the vehicle.

EV_CHARGING_CABLE_UNPLUGGED_FROM_STATION class-attribute instance-attribute ¤
EV_CHARGING_CABLE_UNPLUGGED_FROM_STATION = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_UNPLUGGED_FROM_STATION

EV cable was abruptly unplugged from the charging station.

EV_CONSUMER_INCOMPATIBLE class-attribute instance-attribute ¤
EV_CONSUMER_INCOMPATIBLE = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CONSUMER_INCOMPATIBLE

Incompatible EV plug.

EV_UNEXPECTED_PILOT_FAILURE class-attribute instance-attribute ¤
EV_UNEXPECTED_PILOT_FAILURE = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_UNEXPECTED_PILOT_FAILURE

Unexpected pilot failure in an electric vehicle component.

FAULT_CURRENT class-attribute instance-attribute ¤
FAULT_CURRENT = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_FAULT_CURRENT
)

Fault current detected in the component.

FUSE_ERROR class-attribute instance-attribute ¤
FUSE_ERROR = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_FUSE_ERROR

The component's fuse has blown.

HARDWARE_INACCESSIBLE class-attribute instance-attribute ¤
HARDWARE_INACCESSIBLE = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_HARDWARE_INACCESSIBLE

Hardware of the component is inaccessible.

HIGH_HUMIDITY class-attribute instance-attribute ¤
HIGH_HUMIDITY = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_HIGH_HUMIDITY
)

The component is exposed to high humidity levels over the maximum rated value.

ILLEGAL_ELECTRICAL_COMPONENT_STATE_CODE_REQUESTED class-attribute instance-attribute ¤
ILLEGAL_ELECTRICAL_COMPONENT_STATE_CODE_REQUESTED = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_ILLEGAL_COMPONENT_STATE_CODE_REQUESTED

Illegal state requested for the component.

INTERNAL class-attribute instance-attribute ¤
INTERNAL = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_INTERNAL

Internal error within the component.

OVERCURRENT class-attribute instance-attribute ¤
OVERCURRENT = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERCURRENT
)

The component is drawing more current than the maximum rated value.

OVERCURRENT_CHARGING class-attribute instance-attribute ¤
OVERCURRENT_CHARGING = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERCURRENT_CHARGING

The component's consumption current is over the maximum rated value during charging.

OVERCURRENT_DISCHARGING class-attribute instance-attribute ¤
OVERCURRENT_DISCHARGING = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERCURRENT_DISCHARGING

The component's production current is over the maximum rated value during discharging.

OVERTEMPERATURE class-attribute instance-attribute ¤
OVERTEMPERATURE = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERTEMPERATURE
)

The component is operating over the maximum rated temperature.

OVERVOLTAGE class-attribute instance-attribute ¤
OVERVOLTAGE = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERVOLTAGE
)

The component is operating over the maximum rated voltage.

PLAUSIBILITY_ERROR class-attribute instance-attribute ¤
PLAUSIBILITY_ERROR = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PLAUSIBILITY_ERROR
)

Plausibility issues within the system involving this component.

PRECHARGE_ERROR class-attribute instance-attribute ¤
PRECHARGE_ERROR = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PRECHARGE_ERROR
)

The component's precharge unit has failed.

RELAY_CYCLE_LIMIT_REACHED class-attribute instance-attribute ¤
RELAY_CYCLE_LIMIT_REACHED = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_RELAY_CYCLE_LIMIT_REACHED

Relays have been cycled for the maximum number of times.

SHORT_CIRCUIT class-attribute instance-attribute ¤
SHORT_CIRCUIT = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_SHORT_CIRCUIT
)

Short circuit detected in the component.

SWITCH_ON_FAULT class-attribute instance-attribute ¤
SWITCH_ON_FAULT = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_SWITCH_ON_FAULT
)

The component could not be switched on.

UNAUTHORIZED class-attribute instance-attribute ¤
UNAUTHORIZED = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNAUTHORIZED
)

The component is unauthorized to perform the last requested action.

UNDERTEMPERATURE class-attribute instance-attribute ¤
UNDERTEMPERATURE = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNDERTEMPERATURE
)

The component is operating under the minimum rated temperature.

UNDERVOLTAGE class-attribute instance-attribute ¤
UNDERVOLTAGE = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNDERVOLTAGE
)

The component is operating under the minimum rated voltage.

UNDERVOLTAGE_SHUTDOWN class-attribute instance-attribute ¤
UNDERVOLTAGE_SHUTDOWN = deprecated_member(
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNDERVOLTAGE,
    "UNDERVOLTAGE_SHUTDOWN is deprecated, use UNDERVOLTAGE instead",
)

System shutdown due to undervoltage involving this component.

Deprecated in v0.18.0

Use UNDERVOLTAGE instead.

UNKNOWN class-attribute instance-attribute ¤
UNKNOWN = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNKNOWN

The component is reporting an unknown or undefined error.

This is used when the error can be retrieved from the component but it doesn't match any known error.

UNSPECIFIED class-attribute instance-attribute ¤
UNSPECIFIED = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNSPECIFIED
)

The error is unspecified (this should not be normally used).

frequenz.client.microgrid.component.ComponentStateCode ¤

Bases: Enum

The various states that a component can be in.

Source code in frequenz/client/microgrid/component/_state_sample.py
@enum.unique
class ComponentStateCode(enum.Enum):
    """The various states that a component can be in."""

    UNSPECIFIED = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_UNSPECIFIED
    """The state is unspecified (this should not be normally used)."""

    UNKNOWN = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_UNKNOWN
    """The component is in an unknown or undefined condition.

    This is used when the state can be retrieved from the component but it doesn't match
    any known state.
    """

    UNAVAILABLE = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_UNAVAILABLE
    """The component is temporarily unavailable for operation."""

    SWITCHING_OFF = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_SWITCHING_OFF
    )
    """The component is in the process of switching off."""

    OFF = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_OFF
    """The component has successfully switched off."""

    SWITCHING_ON = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_SWITCHING_ON
    )
    """The component is in the process of switching on."""

    STANDBY = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_STANDBY
    """The component is in standby mode and not immediately ready for operation."""

    READY = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_READY
    """The component is fully operational and ready for use."""

    CHARGING = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_CHARGING
    """The component is actively consuming energy."""

    DISCHARGING = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_DISCHARGING
    """The component is actively producing or releasing energy."""

    ERROR = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_ERROR
    """The component is in an error state and may need attention."""

    EV_CHARGING_CABLE_UNPLUGGED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_UNPLUGGED
    )
    """The EV charging cable is unplugged from the charging station."""

    EV_CHARGING_CABLE_PLUGGED_AT_STATION = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_PLUGGED_AT_STATION  # noqa: E501
    )
    """The EV charging cable is plugged into the charging station."""

    EV_CHARGING_CABLE_PLUGGED_AT_EV = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_PLUGGED_AT_EV
    )
    """The EV charging cable is plugged into the vehicle."""

    EV_CHARGING_CABLE_LOCKED_AT_STATION = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_LOCKED_AT_STATION  # noqa: E501
    )
    """The EV charging cable is locked at the charging station end."""

    EV_CHARGING_CABLE_LOCKED_AT_EV = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_LOCKED_AT_EV
    )
    """The EV charging cable is locked at the vehicle end."""

    RELAY_OPEN = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_RELAY_OPEN
    """The relay is in an open state, meaning no current can flow through."""

    RELAY_CLOSED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_RELAY_CLOSED
    )
    """The relay is in a closed state, allowing current to flow."""

    PRECHARGER_OPEN = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_PRECHARGER_OPEN
    )
    """The precharger circuit is open, meaning it's not currently active."""

    PRECHARGER_PRECHARGING = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_PRECHARGER_PRECHARGING
    )
    """The precharger is in a precharging state, preparing the main circuit for activation."""

    PRECHARGER_CLOSED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_PRECHARGER_CLOSED
    )
    """The precharger circuit is closed, allowing full current to flow to the main circuit."""
Attributes¤
CHARGING class-attribute instance-attribute ¤
CHARGING = ELECTRICAL_COMPONENT_STATE_CODE_CHARGING

The component is actively consuming energy.

DISCHARGING class-attribute instance-attribute ¤
DISCHARGING = ELECTRICAL_COMPONENT_STATE_CODE_DISCHARGING

The component is actively producing or releasing energy.

ERROR class-attribute instance-attribute ¤
ERROR = ELECTRICAL_COMPONENT_STATE_CODE_ERROR

The component is in an error state and may need attention.

EV_CHARGING_CABLE_LOCKED_AT_EV class-attribute instance-attribute ¤
EV_CHARGING_CABLE_LOCKED_AT_EV = ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_LOCKED_AT_EV

The EV charging cable is locked at the vehicle end.

EV_CHARGING_CABLE_LOCKED_AT_STATION class-attribute instance-attribute ¤
EV_CHARGING_CABLE_LOCKED_AT_STATION = ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_LOCKED_AT_STATION

The EV charging cable is locked at the charging station end.

EV_CHARGING_CABLE_PLUGGED_AT_EV class-attribute instance-attribute ¤
EV_CHARGING_CABLE_PLUGGED_AT_EV = ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_PLUGGED_AT_EV

The EV charging cable is plugged into the vehicle.

EV_CHARGING_CABLE_PLUGGED_AT_STATION class-attribute instance-attribute ¤
EV_CHARGING_CABLE_PLUGGED_AT_STATION = ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_PLUGGED_AT_STATION

The EV charging cable is plugged into the charging station.

EV_CHARGING_CABLE_UNPLUGGED class-attribute instance-attribute ¤
EV_CHARGING_CABLE_UNPLUGGED = ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_UNPLUGGED

The EV charging cable is unplugged from the charging station.

OFF class-attribute instance-attribute ¤
OFF = ELECTRICAL_COMPONENT_STATE_CODE_OFF

The component has successfully switched off.

PRECHARGER_CLOSED class-attribute instance-attribute ¤
PRECHARGER_CLOSED = (
    ELECTRICAL_COMPONENT_STATE_CODE_PRECHARGER_CLOSED
)

The precharger circuit is closed, allowing full current to flow to the main circuit.

PRECHARGER_OPEN class-attribute instance-attribute ¤
PRECHARGER_OPEN = (
    ELECTRICAL_COMPONENT_STATE_CODE_PRECHARGER_OPEN
)

The precharger circuit is open, meaning it's not currently active.

PRECHARGER_PRECHARGING class-attribute instance-attribute ¤
PRECHARGER_PRECHARGING = (
    ELECTRICAL_COMPONENT_STATE_CODE_PRECHARGER_PRECHARGING
)

The precharger is in a precharging state, preparing the main circuit for activation.

READY class-attribute instance-attribute ¤
READY = ELECTRICAL_COMPONENT_STATE_CODE_READY

The component is fully operational and ready for use.

RELAY_CLOSED class-attribute instance-attribute ¤
RELAY_CLOSED = ELECTRICAL_COMPONENT_STATE_CODE_RELAY_CLOSED

The relay is in a closed state, allowing current to flow.

RELAY_OPEN class-attribute instance-attribute ¤
RELAY_OPEN = ELECTRICAL_COMPONENT_STATE_CODE_RELAY_OPEN

The relay is in an open state, meaning no current can flow through.

STANDBY class-attribute instance-attribute ¤
STANDBY = ELECTRICAL_COMPONENT_STATE_CODE_STANDBY

The component is in standby mode and not immediately ready for operation.

SWITCHING_OFF class-attribute instance-attribute ¤
SWITCHING_OFF = (
    ELECTRICAL_COMPONENT_STATE_CODE_SWITCHING_OFF
)

The component is in the process of switching off.

SWITCHING_ON class-attribute instance-attribute ¤
SWITCHING_ON = ELECTRICAL_COMPONENT_STATE_CODE_SWITCHING_ON

The component is in the process of switching on.

UNAVAILABLE class-attribute instance-attribute ¤
UNAVAILABLE = ELECTRICAL_COMPONENT_STATE_CODE_UNAVAILABLE

The component is temporarily unavailable for operation.

UNKNOWN class-attribute instance-attribute ¤
UNKNOWN = ELECTRICAL_COMPONENT_STATE_CODE_UNKNOWN

The component is in an unknown or undefined condition.

This is used when the state can be retrieved from the component but it doesn't match any known state.

UNSPECIFIED class-attribute instance-attribute ¤
UNSPECIFIED = ELECTRICAL_COMPONENT_STATE_CODE_UNSPECIFIED

The state is unspecified (this should not be normally used).

frequenz.client.microgrid.component.ComponentStateSample dataclass ¤

A collection of the state, warnings, and errors for a component at a specific time.

Source code in frequenz/client/microgrid/component/_state_sample.py
@dataclass(frozen=True, kw_only=True)
class ComponentStateSample:
    """A collection of the state, warnings, and errors for a component at a specific time."""

    sampled_at: datetime
    """The time at which this state was sampled."""

    states: frozenset[ComponentStateCode | int]
    """The set of states of the component.

    If the reported state is not known by the client (it could happen when using an
    older version of the client with a newer version of the server), it will be
    represented as an `int` and **not** the
    [`ComponentStateCode.UNKNOWN`][frequenz.client.microgrid.component.ComponentStateCode.UNKNOWN]
    value (this value is used only when the state is not known by the server).
    """

    warnings: frozenset[ComponentErrorCode | int]
    """The set of warnings for the component."""

    errors: frozenset[ComponentErrorCode | int]
    """The set of errors for the component.

    This set will only contain errors if the component is in an error state.
    """
Attributes¤
errors instance-attribute ¤

The set of errors for the component.

This set will only contain errors if the component is in an error state.

sampled_at instance-attribute ¤
sampled_at: datetime

The time at which this state was sampled.

states instance-attribute ¤

The set of states of the component.

If the reported state is not known by the client (it could happen when using an older version of the client with a newer version of the server), it will be represented as an int and not the ComponentStateCode.UNKNOWN value (this value is used only when the state is not known by the server).

warnings instance-attribute ¤

The set of warnings for the component.

frequenz.client.microgrid.component.Converter dataclass ¤

Bases: Component

An AC-DC converter component.

Source code in frequenz/client/microgrid/component/_converter.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class Converter(Component):
    """An AC-DC converter component."""

    category: Literal[ComponentCategory.CONVERTER] = ComponentCategory.CONVERTER
    """The category of this component."""
Attributes¤
category class-attribute instance-attribute ¤

The category of this component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

Functions¤
__new__ ¤
__new__(*_: Any, **__: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_component.py
def __new__(cls, *_: Any, **__: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Component:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.CryptoMiner dataclass ¤

Bases: Component

A crypto miner component.

Source code in frequenz/client/microgrid/component/_crypto_miner.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class CryptoMiner(Component):
    """A crypto miner component."""

    category: Literal[ComponentCategory.CRYPTO_MINER] = ComponentCategory.CRYPTO_MINER
    """The category of this component."""
Attributes¤
category class-attribute instance-attribute ¤

The category of this component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

Functions¤
__new__ ¤
__new__(*_: Any, **__: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_component.py
def __new__(cls, *_: Any, **__: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Component:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.DcEvCharger dataclass ¤

Bases: EvCharger

An EV charger that supports DC charging only.

Source code in frequenz/client/microgrid/component/_ev_charger.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class DcEvCharger(EvCharger):
    """An EV charger that supports DC charging only."""

    type: Literal[EvChargerType.DC] = EvChargerType.DC
    """The type of this EV charger.

    Note:
        This should not be used normally, you should test if a EV charger
        [`isinstance`][] of a concrete component class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about the new EV charger type yet (i.e. for use with
        [`UnrecognizedEvCharger`][frequenz.client.microgrid.component.UnrecognizedEvCharger]).
    """
Attributes¤
category class-attribute instance-attribute ¤

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete EV charger class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type class-attribute instance-attribute ¤
type: Literal[DC] = DC

The type of this EV charger.

Note

This should not be used normally, you should test if a EV charger isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about the new EV charger type yet (i.e. for use with UnrecognizedEvCharger).

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_ev_charger.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is EvCharger:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.Electrolyzer dataclass ¤

Bases: Component

An electrolyzer component.

Source code in frequenz/client/microgrid/component/_electrolyzer.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class Electrolyzer(Component):
    """An electrolyzer component."""

    category: Literal[ComponentCategory.ELECTROLYZER] = ComponentCategory.ELECTROLYZER
    """The category of this component."""
Attributes¤
category class-attribute instance-attribute ¤

The category of this component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

Functions¤
__new__ ¤
__new__(*_: Any, **__: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_component.py
def __new__(cls, *_: Any, **__: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Component:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.EvCharger dataclass ¤

Bases: Component

An abstract EV charger component.

Source code in frequenz/client/microgrid/component/_ev_charger.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class EvCharger(Component):
    """An abstract EV charger component."""

    category: Literal[ComponentCategory.EV_CHARGER] = ComponentCategory.EV_CHARGER
    """The category of this component.

    Note:
        This should not be used normally, you should test if a component
        [`isinstance`][] of a concrete EV charger class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about a new category yet (i.e. for use with
        [`UnrecognizedComponent`][frequenz.client.microgrid.component.UnrecognizedComponent])
        and in case some low level code needs to know the category of a component.
    """

    type: EvChargerType | int
    """The type of this EV charger.

    Note:
        This should not be used normally, you should test if a EV charger
        [`isinstance`][] of a concrete component class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about the new EV charger type yet (i.e. for use with
        [`UnrecognizedEvCharger`][frequenz.client.microgrid.component.UnrecognizedEvCharger]).
    """

    # pylint: disable-next=unused-argument
    def __new__(cls, *args: Any, **kwargs: Any) -> Self:
        """Prevent instantiation of this class."""
        if cls is EvCharger:
            raise TypeError(f"Cannot instantiate {cls.__name__} directly")
        return super().__new__(cls)
Attributes¤
category class-attribute instance-attribute ¤

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete EV charger class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type instance-attribute ¤

The type of this EV charger.

Note

This should not be used normally, you should test if a EV charger isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about the new EV charger type yet (i.e. for use with UnrecognizedEvCharger).

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_ev_charger.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is EvCharger:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.EvChargerType ¤

Bases: Enum

The known types of electric vehicle (EV) chargers.

Source code in frequenz/client/microgrid/component/_ev_charger.py
@enum.unique
class EvChargerType(enum.Enum):
    """The known types of electric vehicle (EV) chargers."""

    UNSPECIFIED = electrical_components_pb2.EV_CHARGER_TYPE_UNSPECIFIED
    """The type of the EV charger is unspecified."""

    AC = electrical_components_pb2.EV_CHARGER_TYPE_AC
    """The EV charging station supports AC charging only."""

    DC = electrical_components_pb2.EV_CHARGER_TYPE_DC
    """The EV charging station supports DC charging only."""

    HYBRID = electrical_components_pb2.EV_CHARGER_TYPE_HYBRID
    """The EV charging station supports both AC and DC."""
Attributes¤
AC class-attribute instance-attribute ¤
AC = EV_CHARGER_TYPE_AC

The EV charging station supports AC charging only.

DC class-attribute instance-attribute ¤
DC = EV_CHARGER_TYPE_DC

The EV charging station supports DC charging only.

HYBRID class-attribute instance-attribute ¤
HYBRID = EV_CHARGER_TYPE_HYBRID

The EV charging station supports both AC and DC.

UNSPECIFIED class-attribute instance-attribute ¤
UNSPECIFIED = EV_CHARGER_TYPE_UNSPECIFIED

The type of the EV charger is unspecified.

frequenz.client.microgrid.component.GridConnectionPoint dataclass ¤

Bases: Component

A point where a microgrid 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 is more specific in terms of electrical engineering. It refers to the point where a customer's local electrical system (such as a microgrid) 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 frequenz/client/microgrid/component/_grid_connection_point.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class GridConnectionPoint(Component):
    """A point where a microgrid 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 is more specific in terms of electrical engineering.
    It refers to the point where a customer's local electrical system (such as a
    microgrid) 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.
    """

    category: Literal[ComponentCategory.GRID_CONNECTION_POINT] = (
        ComponentCategory.GRID_CONNECTION_POINT
    )
    """The category of this component."""

    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 `i`A at one of the phases of the grid connection
    point must comply with the following constraint:
    `-rated_fuse_current <= i <= rated_fuse_current`
    """

    def __post_init__(self) -> None:
        """Validate the fuse's rated current."""
        if self.rated_fuse_current < 0:
            raise ValueError(
                f"rated_fuse_current must be a positive integer, not {self.rated_fuse_current}"
            )
Attributes¤
category class-attribute instance-attribute ¤

The category of this component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

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

Functions¤
__new__ ¤
__new__(*_: Any, **__: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_component.py
def __new__(cls, *_: Any, **__: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Component:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__post_init__ ¤
__post_init__() -> None

Validate the fuse's rated current.

Source code in frequenz/client/microgrid/component/_grid_connection_point.py
def __post_init__(self) -> None:
    """Validate the fuse's rated current."""
    if self.rated_fuse_current < 0:
        raise ValueError(
            f"rated_fuse_current must be a positive integer, not {self.rated_fuse_current}"
        )
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.Hvac dataclass ¤

Bases: Component

A heating, ventilation, and air conditioning (HVAC) component.

Source code in frequenz/client/microgrid/component/_hvac.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class Hvac(Component):
    """A heating, ventilation, and air conditioning (HVAC) component."""

    category: Literal[ComponentCategory.HVAC] = ComponentCategory.HVAC
    """The category of this component."""
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[HVAC] = HVAC

The category of this component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

Functions¤
__new__ ¤
__new__(*_: Any, **__: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_component.py
def __new__(cls, *_: Any, **__: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Component:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.HybridEvCharger dataclass ¤

Bases: EvCharger

An EV charger that supports both AC and DC charging.

Source code in frequenz/client/microgrid/component/_ev_charger.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class HybridEvCharger(EvCharger):
    """An EV charger that supports both AC and DC charging."""

    type: Literal[EvChargerType.HYBRID] = EvChargerType.HYBRID
    """The type of this EV charger.

    Note:
        This should not be used normally, you should test if a EV charger
        [`isinstance`][] of a concrete component class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about the new EV charger type yet (i.e. for use with
        [`UnrecognizedEvCharger`][frequenz.client.microgrid.component.UnrecognizedEvCharger]).
    """
Attributes¤
category class-attribute instance-attribute ¤

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete EV charger class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type class-attribute instance-attribute ¤

The type of this EV charger.

Note

This should not be used normally, you should test if a EV charger isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about the new EV charger type yet (i.e. for use with UnrecognizedEvCharger).

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_ev_charger.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is EvCharger:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.HybridInverter dataclass ¤

Bases: Inverter

A hybrid inverter.

Source code in frequenz/client/microgrid/component/_inverter.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class HybridInverter(Inverter):
    """A hybrid inverter."""

    type: Literal[InverterType.HYBRID] = InverterType.HYBRID
    """The type of this inverter.

    Note:
        This should not be used normally, you should test if a inverter
        [`isinstance`][] of a concrete inverter class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about the new inverter type yet (i.e. for use with
        [`UnrecognizedInverter`][frequenz.client.microgrid.component.UnrecognizedInverter]).
    """
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[INVERTER] = INVERTER

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type class-attribute instance-attribute ¤

The type of this inverter.

Note

This should not be used normally, you should test if a inverter isinstance of a concrete inverter class instead.

It is only provided for using with a newer version of the API where the client doesn't know about the new inverter type yet (i.e. for use with UnrecognizedInverter).

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_inverter.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Inverter:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.Inverter dataclass ¤

Bases: Component

An abstract inverter component.

Source code in frequenz/client/microgrid/component/_inverter.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class Inverter(Component):
    """An abstract inverter component."""

    category: Literal[ComponentCategory.INVERTER] = ComponentCategory.INVERTER
    """The category of this component.

    Note:
        This should not be used normally, you should test if a component
        [`isinstance`][] of a concrete component class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about a new category yet (i.e. for use with
        [`UnrecognizedComponent`][frequenz.client.microgrid.component.UnrecognizedComponent])
        and in case some low level code needs to know the category of a component.
    """

    type: InverterType | int
    """The type of this inverter.

    Note:
        This should not be used normally, you should test if a inverter
        [`isinstance`][] of a concrete inverter class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about the new inverter type yet (i.e. for use with
        [`UnrecognizedInverter`][frequenz.client.microgrid.component.UnrecognizedInverter]).
    """

    # pylint: disable-next=unused-argument
    def __new__(cls, *args: Any, **kwargs: Any) -> Self:
        """Prevent instantiation of this class."""
        if cls is Inverter:
            raise TypeError(f"Cannot instantiate {cls.__name__} directly")
        return super().__new__(cls)
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[INVERTER] = INVERTER

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type instance-attribute ¤
type: InverterType | int

The type of this inverter.

Note

This should not be used normally, you should test if a inverter isinstance of a concrete inverter class instead.

It is only provided for using with a newer version of the API where the client doesn't know about the new inverter type yet (i.e. for use with UnrecognizedInverter).

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_inverter.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Inverter:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.InverterType ¤

Bases: Enum

The known types of inverters.

Source code in frequenz/client/microgrid/component/_inverter.py
@enum.unique
class InverterType(enum.Enum):
    """The known types of inverters."""

    UNSPECIFIED = electrical_components_pb2.INVERTER_TYPE_UNSPECIFIED
    """The type of the inverter is unspecified."""

    BATTERY = electrical_components_pb2.INVERTER_TYPE_BATTERY
    """The inverter is a battery inverter."""

    SOLAR = electrical_components_pb2.INVERTER_TYPE_PV
    """The inverter is a solar inverter."""

    HYBRID = electrical_components_pb2.INVERTER_TYPE_HYBRID
    """The inverter is a hybrid inverter."""
Attributes¤
BATTERY class-attribute instance-attribute ¤
BATTERY = INVERTER_TYPE_BATTERY

The inverter is a battery inverter.

HYBRID class-attribute instance-attribute ¤
HYBRID = INVERTER_TYPE_HYBRID

The inverter is a hybrid inverter.

SOLAR class-attribute instance-attribute ¤
SOLAR = INVERTER_TYPE_PV

The inverter is a solar inverter.

UNSPECIFIED class-attribute instance-attribute ¤
UNSPECIFIED = INVERTER_TYPE_UNSPECIFIED

The type of the inverter is unspecified.

frequenz.client.microgrid.component.LiIonBattery dataclass ¤

Bases: Battery

A Li-ion battery.

Source code in frequenz/client/microgrid/component/_battery.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class LiIonBattery(Battery):
    """A Li-ion battery."""

    type: Literal[BatteryType.LI_ION] = BatteryType.LI_ION
    """The type of this battery.

    Note:
        This should not be used normally, you should test if a battery
        [`isinstance`][] of a concrete battery class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about the new battery type yet (i.e. for use with
        [`UnrecognizedBattery`][frequenz.client.microgrid.component.UnrecognizedBattery]).
    """
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[BATTERY] = BATTERY

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type class-attribute instance-attribute ¤

The type of this battery.

Note

This should not be used normally, you should test if a battery isinstance of a concrete battery class instead.

It is only provided for using with a newer version of the API where the client doesn't know about the new battery type yet (i.e. for use with UnrecognizedBattery).

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_battery.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Battery:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.Meter dataclass ¤

Bases: Component

A measuring meter component.

Source code in frequenz/client/microgrid/component/_meter.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class Meter(Component):
    """A measuring meter component."""

    category: Literal[ComponentCategory.METER] = ComponentCategory.METER
    """The category of this component."""
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[METER] = METER

The category of this component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

Functions¤
__new__ ¤
__new__(*_: Any, **__: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_component.py
def __new__(cls, *_: Any, **__: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Component:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.MismatchedCategoryComponent dataclass ¤

Bases: ProblematicComponent

A component with a mismatch in the category.

This component declared a category but carries category specific metadata that doesn't match the declared category.

Source code in frequenz/client/microgrid/component/_problematic.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class MismatchedCategoryComponent(ProblematicComponent):
    """A component with a mismatch in the category.

    This component declared a category but carries category specific metadata that
    doesn't match the declared category.
    """

    category: ComponentCategory | int
    """The category of this component."""
Attributes¤
category instance-attribute ¤
category: ComponentCategory | int

The category of this component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_problematic.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is ProblematicComponent:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.NaIonBattery dataclass ¤

Bases: Battery

A Na-ion battery.

Source code in frequenz/client/microgrid/component/_battery.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class NaIonBattery(Battery):
    """A Na-ion battery."""

    type: Literal[BatteryType.NA_ION] = BatteryType.NA_ION
    """The type of this battery.

    Note:
        This should not be used normally, you should test if a battery
        [`isinstance`][] of a concrete battery class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about the new battery type yet (i.e. for use with
        [`UnrecognizedBattery`][frequenz.client.microgrid.component.UnrecognizedBattery]).
    """
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[BATTERY] = BATTERY

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type class-attribute instance-attribute ¤

The type of this battery.

Note

This should not be used normally, you should test if a battery isinstance of a concrete battery class instead.

It is only provided for using with a newer version of the API where the client doesn't know about the new battery type yet (i.e. for use with UnrecognizedBattery).

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_battery.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Battery:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.Precharger dataclass ¤

Bases: Component

A precharger component.

Source code in frequenz/client/microgrid/component/_precharger.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class Precharger(Component):
    """A precharger component."""

    category: Literal[ComponentCategory.PRECHARGER] = ComponentCategory.PRECHARGER
    """The category of this component."""
Attributes¤
category class-attribute instance-attribute ¤

The category of this component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

Functions¤
__new__ ¤
__new__(*_: Any, **__: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_component.py
def __new__(cls, *_: Any, **__: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Component:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.ProblematicComponent dataclass ¤

Bases: Component

An abstract component with a problem.

Source code in frequenz/client/microgrid/component/_problematic.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class ProblematicComponent(Component):
    """An abstract component with a problem."""

    # pylint: disable-next=unused-argument
    def __new__(cls, *args: Any, **kwargs: Any) -> Self:
        """Prevent instantiation of this class."""
        if cls is ProblematicComponent:
            raise TypeError(f"Cannot instantiate {cls.__name__} directly")
        return super().__new__(cls)
Attributes¤
category instance-attribute ¤
category: ComponentCategory | int

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_problematic.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is ProblematicComponent:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.Relay dataclass ¤

Bases: Component

A relay component.

Source code in frequenz/client/microgrid/component/_relay.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class Relay(Component):
    """A relay component."""

    category: Literal[ComponentCategory.RELAY] = ComponentCategory.RELAY
    """The category of this component."""
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[RELAY] = RELAY

The category of this component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

Functions¤
__new__ ¤
__new__(*_: Any, **__: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_component.py
def __new__(cls, *_: Any, **__: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Component:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.SolarInverter dataclass ¤

Bases: Inverter

A solar inverter.

Source code in frequenz/client/microgrid/component/_inverter.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class SolarInverter(Inverter):
    """A solar inverter."""

    type: Literal[InverterType.SOLAR] = InverterType.SOLAR
    """The type of this inverter.

    Note:
        This should not be used normally, you should test if a inverter
        [`isinstance`][] of a concrete inverter class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about the new inverter type yet (i.e. for use with
        [`UnrecognizedInverter`][frequenz.client.microgrid.component.UnrecognizedInverter]).
    """
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[INVERTER] = INVERTER

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type class-attribute instance-attribute ¤
type: Literal[SOLAR] = SOLAR

The type of this inverter.

Note

This should not be used normally, you should test if a inverter isinstance of a concrete inverter class instead.

It is only provided for using with a newer version of the API where the client doesn't know about the new inverter type yet (i.e. for use with UnrecognizedInverter).

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_inverter.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Inverter:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.UnrecognizedBattery dataclass ¤

Bases: Battery

A battery of an unrecognized type.

Source code in frequenz/client/microgrid/component/_battery.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class UnrecognizedBattery(Battery):
    """A battery of an unrecognized type."""

    type: int
    """The unrecognized type of this battery."""
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[BATTERY] = BATTERY

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type instance-attribute ¤
type: int

The unrecognized type of this battery.

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_battery.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Battery:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.UnrecognizedComponent dataclass ¤

Bases: ProblematicComponent

A component of an unrecognized type.

Source code in frequenz/client/microgrid/component/_problematic.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class UnrecognizedComponent(ProblematicComponent):
    """A component of an unrecognized type."""

    category: int
    """The category of this component."""
Attributes¤
category instance-attribute ¤
category: int

The category of this component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_problematic.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is ProblematicComponent:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.UnrecognizedEvCharger dataclass ¤

Bases: EvCharger

An EV charger of an unrecognized type.

Source code in frequenz/client/microgrid/component/_ev_charger.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class UnrecognizedEvCharger(EvCharger):
    """An EV charger of an unrecognized type."""

    type: int
    """The unrecognized type of this EV charger."""
Attributes¤
category class-attribute instance-attribute ¤

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete EV charger class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type instance-attribute ¤
type: int

The unrecognized type of this EV charger.

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_ev_charger.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is EvCharger:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.UnrecognizedInverter dataclass ¤

Bases: Inverter

An inverter component.

Source code in frequenz/client/microgrid/component/_inverter.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class UnrecognizedInverter(Inverter):
    """An inverter component."""

    type: int
    """The unrecognized type of this inverter."""
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[INVERTER] = INVERTER

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type instance-attribute ¤
type: int

The unrecognized type of this inverter.

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_inverter.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Inverter:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.UnspecifiedBattery dataclass ¤

Bases: Battery

A battery of a unspecified type.

Source code in frequenz/client/microgrid/component/_battery.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class UnspecifiedBattery(Battery):
    """A battery of a unspecified type."""

    type: Literal[BatteryType.UNSPECIFIED] = BatteryType.UNSPECIFIED
    """The type of this battery.

    Note:
        This should not be used normally, you should test if a battery
        [`isinstance`][] of a concrete battery class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about the new battery type yet (i.e. for use with
        [`UnrecognizedBattery`][frequenz.client.microgrid.component.UnrecognizedBattery]).
    """
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[BATTERY] = BATTERY

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type class-attribute instance-attribute ¤

The type of this battery.

Note

This should not be used normally, you should test if a battery isinstance of a concrete battery class instead.

It is only provided for using with a newer version of the API where the client doesn't know about the new battery type yet (i.e. for use with UnrecognizedBattery).

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_battery.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Battery:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.UnspecifiedComponent dataclass ¤

Bases: ProblematicComponent

A component of unspecified type.

Source code in frequenz/client/microgrid/component/_problematic.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class UnspecifiedComponent(ProblematicComponent):
    """A component of unspecified type."""

    category: Literal[ComponentCategory.UNSPECIFIED] = ComponentCategory.UNSPECIFIED
    """The category of this component."""
Attributes¤
category class-attribute instance-attribute ¤

The category of this component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_problematic.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is ProblematicComponent:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.UnspecifiedEvCharger dataclass ¤

Bases: EvCharger

An EV charger of an unspecified type.

Source code in frequenz/client/microgrid/component/_ev_charger.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class UnspecifiedEvCharger(EvCharger):
    """An EV charger of an unspecified type."""

    type: Literal[EvChargerType.UNSPECIFIED] = EvChargerType.UNSPECIFIED
    """The type of this EV charger.

    Note:
        This should not be used normally, you should test if a EV charger
        [`isinstance`][] of a concrete component class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about the new EV charger type yet (i.e. for use with
        [`UnrecognizedEvCharger`][frequenz.client.microgrid.component.UnrecognizedEvCharger]).
    """
Attributes¤
category class-attribute instance-attribute ¤

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete EV charger class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type class-attribute instance-attribute ¤

The type of this EV charger.

Note

This should not be used normally, you should test if a EV charger isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about the new EV charger type yet (i.e. for use with UnrecognizedEvCharger).

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_ev_charger.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is EvCharger:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.UnspecifiedInverter dataclass ¤

Bases: Inverter

An inverter of an unspecified type.

Source code in frequenz/client/microgrid/component/_inverter.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class UnspecifiedInverter(Inverter):
    """An inverter of an unspecified type."""

    type: Literal[InverterType.UNSPECIFIED] = InverterType.UNSPECIFIED
    """The type of this inverter.

    Note:
        This should not be used normally, you should test if a inverter
        [`isinstance`][] of a concrete inverter class instead.

        It is only provided for using with a newer version of the API where the client
        doesn't know about the new inverter type yet (i.e. for use with
        [`UnrecognizedInverter`][frequenz.client.microgrid.component.UnrecognizedInverter]).
    """
Attributes¤
category class-attribute instance-attribute ¤
category: Literal[INVERTER] = INVERTER

The category of this component.

Note

This should not be used normally, you should test if a component isinstance of a concrete component class instead.

It is only provided for using with a newer version of the API where the client doesn't know about a new category yet (i.e. for use with UnrecognizedComponent) and in case some low level code needs to know the category of a component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

type class-attribute instance-attribute ¤

The type of this inverter.

Note

This should not be used normally, you should test if a inverter isinstance of a concrete inverter class instead.

It is only provided for using with a newer version of the API where the client doesn't know about the new inverter type yet (i.e. for use with UnrecognizedInverter).

Functions¤
__new__ ¤
__new__(*args: Any, **kwargs: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_inverter.py
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Inverter:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))

frequenz.client.microgrid.component.VoltageTransformer dataclass ¤

Bases: Component

A voltage transformer component.

Voltage 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

Voltage transformers have efficiency losses, so the output power is always less than the input power.

Source code in frequenz/client/microgrid/component/_voltage_transformer.py
@dataclasses.dataclass(frozen=True, kw_only=True)
class VoltageTransformer(Component):
    """A voltage transformer component.

    Voltage 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:
        Voltage transformers have efficiency losses, so the output power is always less
        than the input power.
    """

    category: Literal[ComponentCategory.POWER_TRANSFORMER] = (
        ComponentCategory.POWER_TRANSFORMER
    )
    """The category of this component."""

    primary_voltage: float
    """The primary voltage of the transformer, in volts.

    This is the input voltage that is stepped up or down.
    """

    secondary_voltage: float
    """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.
    """
Attributes¤
category class-attribute instance-attribute ¤

The category of this component.

category_specific_metadata class-attribute instance-attribute ¤
category_specific_metadata: Mapping[str, Any] = field(
    default_factory=dict, hash=False
)

The category specific metadata of this component.

Note

This should not be used normally, it is only useful when accessing a newer version of the API where the client doesn't know about the new metadata fields yet (i.e. for use with UnrecognizedComponent).

id instance-attribute ¤
id: ComponentId

This component's ID.

identity property ¤
identity: tuple[ComponentId, MicrogridId]

The identity of this component.

This uses the component ID and microgrid ID to identify a component without considering the other attributes, so even if a component state changed, the identity remains the same.

manufacturer class-attribute instance-attribute ¤
manufacturer: str | None = None

The manufacturer of this component.

microgrid_id instance-attribute ¤
microgrid_id: MicrogridId

The ID of the microgrid this component belongs to.

model_name class-attribute instance-attribute ¤
model_name: str | None = None

The model name of this component.

name class-attribute instance-attribute ¤
name: str | None = None

The name of this component.

operational_lifetime class-attribute instance-attribute ¤
operational_lifetime: Lifetime = field(
    default_factory=Lifetime
)

The operational lifetime of this component.

primary_voltage instance-attribute ¤
primary_voltage: float

The primary voltage of the transformer, in volts.

This is the input voltage that is stepped up or down.

rated_bounds class-attribute instance-attribute ¤
rated_bounds: Mapping[Metric | int, Bounds] = field(
    default_factory=dict, hash=False
)

List of rated bounds present for the component identified by Metric.

secondary_voltage instance-attribute ¤
secondary_voltage: float

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.

Functions¤
__new__ ¤
__new__(*_: Any, **__: Any) -> Self

Prevent instantiation of this class.

Source code in frequenz/client/microgrid/component/_component.py
def __new__(cls, *_: Any, **__: Any) -> Self:
    """Prevent instantiation of this class."""
    if cls is Component:
        raise TypeError(f"Cannot instantiate {cls.__name__} directly")
    return super().__new__(cls)
__str__ ¤
__str__() -> str

Return a human-readable string representation of this instance.

Source code in frequenz/client/microgrid/component/_component.py
def __str__(self) -> str:
    """Return a human-readable string representation of this instance."""
    name = f":{self.name}" if self.name else ""
    return f"{self.id}<{type(self).__name__}>{name}"
is_operational_at ¤
is_operational_at(timestamp: datetime) -> bool

Check whether this component is operational at a specific timestamp.

PARAMETER DESCRIPTION
timestamp

The timestamp to check.

TYPE: datetime

RETURNS DESCRIPTION
bool

Whether this component is operational at the given timestamp.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_at(self, timestamp: datetime) -> bool:
    """Check whether this component is operational at a specific timestamp.

    Args:
        timestamp: The timestamp to check.

    Returns:
        Whether this component is operational at the given timestamp.
    """
    return self.operational_lifetime.is_operational_at(timestamp)
is_operational_now ¤
is_operational_now() -> bool

Check whether this component is currently operational.

RETURNS DESCRIPTION
bool

Whether this component is operational at the current time.

Source code in frequenz/client/microgrid/component/_component.py
def is_operational_now(self) -> bool:
    """Check whether this component is currently operational.

    Returns:
        Whether this component is operational at the current time.
    """
    return self.is_operational_at(datetime.now(timezone.utc))